-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[language][compiler][ir_to_bytecode] Function Calls are now Expressions
Converting function calls into expressions. Advantage: - can be used to express programs with unbalanced stack expressions. - expressions now also represent a vector of simple expressions. Limitations: - Any command of an expression (other than function calls) must be parenthesized.
- Loading branch information
1 parent
ffd112a
commit ec4bbfa
Showing
23 changed files
with
691 additions
and
161 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
27 changes: 27 additions & 0 deletions
27
language/functional_tests/tests/testsuite/function_calls/add_function_calls.mvir
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module M { | ||
public foo(u: u64): u64 * u64 * u64 { | ||
let twice: u64; | ||
let quadruple: u64; | ||
twice = 2 * copy(u); | ||
quadruple = 4 * copy(u); | ||
return move(u), move(twice), move(quadruple); | ||
} | ||
|
||
public bar(): u64 { | ||
return 2; | ||
} | ||
} | ||
|
||
//! new-transaction | ||
import {{default}}.M; | ||
|
||
main() { | ||
let x: u64; | ||
let y: u64; | ||
let z: u64; | ||
x, y, z = M.foo(5) + M.bar(); | ||
assert(move(x) == 5, 42); | ||
assert(move(y) == 10, 42); | ||
assert(move(z) == 22, 42); | ||
return; | ||
} |
16 changes: 16 additions & 0 deletions
16
language/functional_tests/tests/testsuite/function_calls/assign_expression_list.mvir
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
main() { | ||
let x: u64; | ||
let y: u64; | ||
let z: u64; | ||
let z_var: u64; | ||
|
||
x, y = (4, 5); | ||
z = (6); | ||
z_var = 6; | ||
|
||
assert(move(x) == 4, 42); | ||
assert(move(y) == 5, 42); | ||
assert(move(z) == 6, 42); | ||
assert(move(z_var) == 6, 42); | ||
return; | ||
} |
23 changes: 23 additions & 0 deletions
23
language/functional_tests/tests/testsuite/function_calls/assign_function_call.mvir
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module A { | ||
public ones_tens(f: u64): u64 * u64 { | ||
let k: u64; | ||
let m: u64; | ||
k = copy(f) % 10; | ||
m = (move(f) % 100) - copy(k); | ||
return move(k), move(m); | ||
} | ||
} | ||
|
||
//! new-transaction | ||
import {{default}}.A; | ||
|
||
main() { | ||
let x: u64; | ||
let y: u64; | ||
let z: u64; | ||
x = 143; | ||
y, z = A.ones_tens(move(x)); | ||
assert(move(y) == 3, 42); | ||
assert(move(z) == 40, 42); | ||
return; | ||
} |
Oops, something went wrong.