-
Notifications
You must be signed in to change notification settings - Fork 918
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FunC v0.5.0: syntax, refactoring, bugfixes, and a testing framework #1026
Open
unserialize
wants to merge
30
commits into
testnet
Choose a base branch
from
func-v0.5.0
base: testnet
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
0bc6305
[FunC] Change some fields to enums instead of integers
unserialize a5d2a10
[FunC] Enrich and refactor testing framework, add negative tests
unserialize cbd7896
[FunC] CMake option -DFUNC_DEBUG for development purposes
unserialize bac4e3d
[FunC] Enrich testing framework, add fif output patterns
unserialize 18050a7
[FunC] Auto-inline functions-wrappers `T f(...args) { return anotherF…
unserialize c74e49d
[FunC] Enrich testing framework, add code hash checking
unserialize a174f85
[FunC] Apply camelCase to some tests to ensure code_hash remains unch…
unserialize 30572c7
[FunC] Support traditional // and /**/ comments
unserialize 4994ae8
[FunC] Convert stdlib.fc to traditional-style //comments
unserialize f217a7d
[FunC] Forbid auto-creating undefined symbols
unserialize a3e9e03
[FunC] Fixed some impure specifiers in stdlib.fc
unserialize 85c60d1
[FunC] Make all functions impure by default, add "pure" specifier
unserialize ef5719d
[FunC] Forbid impure operations inside pure functions
unserialize 0628e17
[FunC] Use td::OptionParser in func-main.cpp
unserialize acf0043
[FunC] Add pragma remove-unused-functions for simple dead code elimin…
unserialize cdef830
[FunC] Add `builtin` keyword to be used in stdlib later on
unserialize de57087
[FunC] Add builtin functions to stdlib.fc
unserialize bb86dc0
[FunC] Add an ability to deprecate pragmas
unserialize aaf3ca3
[FunC] Deprecate pragma allow-post-modification
unserialize 1e4b20a
[FunC] Deprecate pragma compute-asm-ltr
unserialize aee5173
[FunC] Refactor allow-post-modification, stop producing disabled Op::…
unserialize 7afa929
[FunC] Change priority of `& | ^` operators to a more intuitive one
unserialize 7b8268d
[FunC] Deprecate `method_id` specifier, introduce `get` keyword
unserialize 8932c51
[FunC] Produce an error on get methods hash (method_id) collision
unserialize 2da85a6
[FunC] Fix an issue of funcfiftlib.wasm which truncated long fif output
unserialize 49a0d32
[FunC] Drop a folder crypto/func/test, it's unused
unserialize 3520184
[FunC] Fix a bug with << operator to zero value
unserialize 5867d52
[FunC] Bump FunC version to v0.5.0
unserialize 79721d2
[FunC] Require parenthesis in tricky bitwise precedence cases
unserialize e2467b8
[FunC] Reserve '!' for the future, identifiers can't start with it
unserialize File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -223,15 +223,6 @@ void VarDescrList::show(std::ostream& os) const { | |
os << " ]\n"; | ||
} | ||
|
||
void Op::flags_set_clear(int set, int clear) { | ||
flags = (flags | set) & ~clear; | ||
for (auto& op : block0) { | ||
op.flags_set_clear(set, clear); | ||
} | ||
for (auto& op : block1) { | ||
op.flags_set_clear(set, clear); | ||
} | ||
} | ||
void Op::split_vars(const std::vector<TmpVar>& vars) { | ||
split_var_list(left, vars); | ||
split_var_list(right, vars); | ||
|
@@ -296,7 +287,7 @@ void Op::show(std::ostream& os, const std::vector<TmpVar>& vars, std::string pfx | |
if (noreturn()) { | ||
dis += "<noret> "; | ||
} | ||
if (!is_pure()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok |
||
if (impure()) { | ||
dis += "<impure> "; | ||
} | ||
switch (cl) { | ||
|
@@ -469,12 +460,6 @@ void Op::show_block(std::ostream& os, const Op* block, const std::vector<TmpVar> | |
os << pfx << "}"; | ||
} | ||
|
||
void CodeBlob::flags_set_clear(int set, int clear) { | ||
for (auto& op : ops) { | ||
op.flags_set_clear(set, clear); | ||
} | ||
} | ||
|
||
std::ostream& operator<<(std::ostream& os, const CodeBlob& code) { | ||
code.print(os); | ||
return os; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,68 @@ | ||
const fs = require('fs/promises'); | ||
// Usage: `node legacy_tests.js` from current dir, providing some env (see getenv() calls). | ||
// This is a JS version of legacy_tester.py to test FunC compiled to WASM. | ||
|
||
const fs = require('fs'); | ||
const path = require('path') | ||
const process = require('process'); | ||
const { compileWasm, compileFile } = require('./wasm_tests_common'); | ||
|
||
|
||
/** @return {string} */ | ||
function getenv(name, def = null) { | ||
if (name in process.env) | ||
return process.env[name] | ||
if (def === null) { | ||
console.log(`Environment variable ${name} is not set`) | ||
process.exit(1) | ||
} | ||
return def | ||
} | ||
|
||
const FUNCFIFTLIB_MODULE = getenv('FUNCFIFTLIB_MODULE') | ||
const FUNCFIFTLIB_WASM = getenv('FUNCFIFTLIB_WASM') | ||
const TESTS_DIR = "legacy_tests" | ||
|
||
/** | ||
* @return {{filename: string, code_hash: BigInt}[]} | ||
*/ | ||
function load_legacy_tests_list(jsonl_filename) { | ||
let contents = fs.readFileSync(jsonl_filename) | ||
let results = [...contents.toString().matchAll(/^\[\s*"(.*?)"\s*,\s*(.*?)\s*]/gms)] | ||
return results.map((line) => ({ | ||
filename: line[1].trim(), | ||
code_hash: BigInt(line[2]), | ||
})) | ||
} | ||
|
||
async function main() { | ||
const tests = JSON.parse((await fs.readFile('../legacy_tests.json')).toString('utf-8')) | ||
const tests = load_legacy_tests_list('legacy_tests.jsonl') | ||
|
||
for (const [filename, hashstr] of tests) { | ||
if (filename.includes('storage-provider')) continue; | ||
for (let ti = 0; ti < tests.length; ++ti) { | ||
const {filename: filename_rel, code_hash} = tests[ti] | ||
const filename = path.join(TESTS_DIR, filename_rel) | ||
console.log(`Running test ${ti + 1}/${tests.length}: ${filename_rel}`) | ||
|
||
const mod = await compileWasm() | ||
if (filename.includes('storage-provider')) { | ||
console.log(" Skip"); | ||
continue; | ||
} | ||
|
||
const response = await compileFile(mod, filename); | ||
const wasmModule = await compileWasm(FUNCFIFTLIB_MODULE, FUNCFIFTLIB_WASM) | ||
const response = compileFile(wasmModule, filename); | ||
|
||
if (response.status !== 'ok') { | ||
console.error(response); | ||
throw new Error('Could not compile ' + filename); | ||
throw new Error(`Could not compile ${filename}`); | ||
} | ||
|
||
if (BigInt('0x' + response.codeHashHex) !== BigInt(hashstr)) { | ||
throw new Error('Compilation result is different for ' + filename); | ||
if (BigInt('0x' + response.codeHashHex) !== code_hash) { | ||
throw new Error(`Code hash is different for ${filename}`); | ||
} | ||
|
||
console.log(filename, 'ok'); | ||
console.log(' OK '); | ||
} | ||
|
||
console.log(`Done ${tests.length}`) | ||
} | ||
|
||
main() | ||
main().catch(console.error) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.