-
Notifications
You must be signed in to change notification settings - Fork 234
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2728 from aeternity/polymorphism-checks
Polymorphism and higher-order checks
- Loading branch information
Showing
8 changed files
with
98 additions
and
7 deletions.
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
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// - + * / mod arithmetic operators | ||
// bnot band bor bxor bsl bsr bitwise operators | ||
// ! && || logical operators | ||
// == != < > =< >= comparison operators | ||
// :: ++ list operators | ||
|
||
contract Operators = | ||
entrypoint int_op(a : int, b : int, op : string) = | ||
switch(op) | ||
"+" => a + b | ||
"-" => a - b | ||
"*" => a * b | ||
"/" => a / b | ||
"mod" => a mod b | ||
"^" => a ^ b | ||
|
||
entrypoint bool_op(a : bool, b : bool, op : string) = | ||
switch(op) | ||
"!" => !a | ||
"&&" => a && b | ||
"||" => a || b | ||
|
||
entrypoint cmp_op(a : int, b : int, op : string) = | ||
switch(op) | ||
"==" => a == b | ||
"!=" => a != b | ||
"<" => a < b | ||
">" => a > b | ||
"=<" => a =< b | ||
">=" => a >= b | ||
|
||
entrypoint cons(a : int, l) = a :: l | ||
entrypoint concat(l1, l2) : list(int) = l1 ++ l2 | ||
|
||
entrypoint hash(s) = // String.sha3(s) | ||
let x = String.sha3(s) | ||
let y = String.sha3(s) | ||
(x, y) |
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,53 @@ | ||
contract Remote = | ||
entrypoint id : ('a) => 'a | ||
entrypoint missing : ('a) => 'a | ||
entrypoint bogus_string_string_arg : (string) => string | ||
entrypoint bogus_string_string_ret : (string) => string | ||
entrypoint bogus_id : ('a) => ('a) | ||
|
||
contract Main = | ||
|
||
type state = int | ||
|
||
entrypoint init() = 0 | ||
|
||
entrypoint next_state() = state + 1 | ||
|
||
entrypoint id(x : int) = | ||
x | ||
|
||
entrypoint bogus_id(x : int) = | ||
(x, x) | ||
|
||
entrypoint bogus_string_string_arg(x : int) = | ||
"hello" | ||
|
||
entrypoint bogus_string_string_ret(x : string) = | ||
42 | ||
|
||
entrypoint remote_id(r : Remote, x : int) = | ||
r.id(x) | ||
|
||
entrypoint remote_missing(r : Remote, x : int) = | ||
r.missing(x) | ||
|
||
entrypoint remote_wrong_arg(r : Remote, x) = | ||
r.bogus_string_string_arg(x) | ||
|
||
entrypoint remote_wrong_ret(r : Remote, x) = | ||
(r.bogus_string_string_ret(x), r.bogus_string_string_ret(x)) | ||
|
||
entrypoint remote_wrong_ret_tailcall(r : Remote, x) : string = | ||
r.bogus_string_string_ret(x) | ||
|
||
entrypoint remote_wrong_ret_tailcall_type_vars(r : Remote, x : string) = | ||
r.bogus_id(x) | ||
|
||
stateful entrypoint remote_wrong_put(r : Remote, x : int) = | ||
put(r.bogus_id(x)) | ||
|
||
function call_bogus_id(r : Remote, x : int) : int = r.bogus_id(x) | ||
|
||
stateful entrypoint remote_wrong_put_polymorphic(r : Remote, x : int) = | ||
put(call_bogus_id(r, x)) | ||
|