Fix some tests. Remove optimization of singleton tuples
This commit is contained in:
parent
5c43be22b9
commit
b1b2dc849a
@ -208,10 +208,13 @@ namespace List =
|
|||||||
[] => false
|
[] => false
|
||||||
h::t => if(p(h)) true else any(p, t)
|
h::t => if(p(h)) true else any(p, t)
|
||||||
|
|
||||||
function sum(l : list(int)) : int = foldl ((a, b) => a + b, 0, l)
|
function sum(l : list(int)) : int = switch(l)
|
||||||
|
[] => 0
|
||||||
function product(l : list(int)) : int = foldl((a, b) => a * b, 1, l)
|
h::t => h + sum(t)
|
||||||
|
|
||||||
|
function product(l : list(int)) : int = switch(l)
|
||||||
|
[] => 1
|
||||||
|
h::t => h * sum(t)
|
||||||
|
|
||||||
/** Zips two list by applying bimapping function on respective elements.
|
/** Zips two list by applying bimapping function on respective elements.
|
||||||
* Drops the tail of the longer list.
|
* Drops the tail of the longer list.
|
||||||
|
@ -283,10 +283,13 @@ bind_contract({Contract, Ann, Id, Contents}, Env)
|
|||||||
[ {field_t, Sys, {id, Sys, "address"}, {id, Sys, "address"}} ] ++
|
[ {field_t, Sys, {id, Sys, "address"}, {id, Sys, "address"}} ] ++
|
||||||
[ {field_t, Sys, {id, Sys, ?CONSTRUCTOR_MOCK_NAME},
|
[ {field_t, Sys, {id, Sys, ?CONSTRUCTOR_MOCK_NAME},
|
||||||
contract_call_type(
|
contract_call_type(
|
||||||
case [ {fun_t, [stateful,payable|Sys], [], [ArgT || {typed, _, _, ArgT} <- Args], {id, Sys, "void"}}
|
case [ [ArgT || {typed, _, _, ArgT} <- Args]
|
||||||
|| {letfun, _, {id, _, "init"}, Args, _, _} <- Contents] of
|
|| {letfun, _, {id, _, "init"}, Args, _, _} <- Contents]
|
||||||
|
++ [ Args || {fun_decl, _, {id, _, "init"}, {fun_t, _, _, Args, _}} <- Contents]
|
||||||
|
++ [ Args || {fun_decl, _, {id, _, "init"}, {type_sig, _, _, _, Args, _}} <- Contents]
|
||||||
|
of
|
||||||
[] -> {fun_t, [stateful,payable|Sys], [], [], {id, Sys, "void"}};
|
[] -> {fun_t, [stateful,payable|Sys], [], [], {id, Sys, "void"}};
|
||||||
[T] -> T
|
[Args] -> {fun_t, [stateful,payable|Sys], [], Args, {id, Sys, "void"}}
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -715,14 +715,14 @@ expr_to_fcode(Env, Type, {app, _, Fun = {typed, _, FunE, {fun_t, _, NamedArgsT,
|
|||||||
case ArgsT of
|
case ArgsT of
|
||||||
var_args -> fcode_error({var_args_not_set, FunE});
|
var_args -> fcode_error({var_args_not_set, FunE});
|
||||||
_ ->
|
_ ->
|
||||||
FInitArgsT = {typerep, {tuple, [type_to_fcode(Env, T) || T <- ArgsT]}},
|
FInitArgsT = aeb_fate_data:make_typerep({tuple, [type_to_fcode(Env, T) || T <- ArgsT]}),
|
||||||
builtin_to_fcode(state_layout(Env), chain_clone, [{lit, FInitArgsT}|FArgs])
|
builtin_to_fcode(state_layout(Env), chain_clone, [{lit, FInitArgsT}|FArgs])
|
||||||
end;
|
end;
|
||||||
{builtin_u, chain_create, _Ar} ->
|
{builtin_u, chain_create, _Ar} ->
|
||||||
case {ArgsT, Type} of
|
case {ArgsT, Type} of
|
||||||
{var_args, _} -> fcode_error({var_args_not_set, FunE});
|
{var_args, _} -> fcode_error({var_args_not_set, FunE});
|
||||||
{_, {con, _, Contract}} ->
|
{_, {con, _, Contract}} ->
|
||||||
FInitArgsT = {typerep, {tuple, [type_to_fcode(Env, T) || T <- ArgsT]}},
|
FInitArgsT = aeb_fate_data:make_typerep({tuple, [type_to_fcode(Env, T) || T <- ArgsT]}),
|
||||||
builtin_to_fcode(state_layout(Env), chain_create, [{lit, {contract_code, Contract}}, {lit, FInitArgsT}|FArgs]);
|
builtin_to_fcode(state_layout(Env), chain_create, [{lit, {contract_code, Contract}}, {lit, FInitArgsT}|FArgs]);
|
||||||
{_, _} -> fcode_error({not_a_contract_type, Type})
|
{_, _} -> fcode_error({not_a_contract_type, Type})
|
||||||
end;
|
end;
|
||||||
|
@ -125,7 +125,6 @@ type_to_scode(bits) -> bits;
|
|||||||
type_to_scode(any) -> any;
|
type_to_scode(any) -> any;
|
||||||
type_to_scode({variant, Cons}) -> {variant, [{tuple, types_to_scode(Con)} || Con <- Cons]};
|
type_to_scode({variant, Cons}) -> {variant, [{tuple, types_to_scode(Con)} || Con <- Cons]};
|
||||||
type_to_scode({list, Type}) -> {list, type_to_scode(Type)};
|
type_to_scode({list, Type}) -> {list, type_to_scode(Type)};
|
||||||
type_to_scode({tuple, [Type]}) -> type_to_scode(Type);
|
|
||||||
type_to_scode({tuple, Types}) -> {tuple, types_to_scode(Types)};
|
type_to_scode({tuple, Types}) -> {tuple, types_to_scode(Types)};
|
||||||
type_to_scode({map, Key, Val}) -> {map, type_to_scode(Key), type_to_scode(Val)};
|
type_to_scode({map, Key, Val}) -> {map, type_to_scode(Key), type_to_scode(Val)};
|
||||||
type_to_scode({function, _Args, _Res}) -> {tuple, [string, any]};
|
type_to_scode({function, _Args, _Res}) -> {tuple, [string, any]};
|
||||||
@ -590,9 +589,6 @@ builtin_to_scode(Env, chain_create,
|
|||||||
[Code, TypeRep, Value | InitArgs]
|
[Code, TypeRep, Value | InitArgs]
|
||||||
).
|
).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
%% -- Operators --
|
%% -- Operators --
|
||||||
|
|
||||||
op_to_scode('+') -> aeb_fate_ops:add(?a, ?a, ?a);
|
op_to_scode('+') -> aeb_fate_ops:add(?a, ?a, ?a);
|
||||||
|
@ -127,9 +127,9 @@ compile(Backend, Name, Options) ->
|
|||||||
%% compilable_contracts() -> [ContractName].
|
%% compilable_contracts() -> [ContractName].
|
||||||
%% The currently compilable contracts.
|
%% The currently compilable contracts.
|
||||||
|
|
||||||
compilable_contracts() -> ["test"]; % FIXME remove
|
|
||||||
compilable_contracts() ->
|
compilable_contracts() ->
|
||||||
["complex_types",
|
["test",
|
||||||
|
"complex_types",
|
||||||
"counter",
|
"counter",
|
||||||
"dutch_auction",
|
"dutch_auction",
|
||||||
"environment",
|
"environment",
|
||||||
@ -182,7 +182,7 @@ compilable_contracts() ->
|
|||||||
"protected_call",
|
"protected_call",
|
||||||
"hermetization_turnoff",
|
"hermetization_turnoff",
|
||||||
"multiple_contracts",
|
"multiple_contracts",
|
||||||
"clone", "clone_simple"
|
"clone", "clone_simple", "create"
|
||||||
].
|
].
|
||||||
|
|
||||||
not_compilable_on(fate) -> [];
|
not_compilable_on(fate) -> [];
|
||||||
|
@ -5,13 +5,15 @@ contract interface HigherOrderState =
|
|||||||
stateful entrypoint inc : int => unit
|
stateful entrypoint inc : int => unit
|
||||||
|
|
||||||
contract interface LowerDisorderAnarchy =
|
contract interface LowerDisorderAnarchy =
|
||||||
entrypoint init : int => void
|
entrypoint init : (int) => void
|
||||||
|
|
||||||
|
|
||||||
main contract C =
|
main contract C =
|
||||||
|
// both `s` and `l` should be of type `HigherOrderState` in this test
|
||||||
stateful entrypoint run_clone(s : HigherOrderState, l : LowerDisorderAnarchy) : HigherOrderState =
|
stateful entrypoint run_clone(s : HigherOrderState, l : LowerDisorderAnarchy) : HigherOrderState =
|
||||||
let s1 = Chain.clone(ref=s)
|
let s1 = Chain.clone(ref=s)
|
||||||
let Some(s2) = Chain.clone(ref=s, protected=true)
|
let Some(s2) = Chain.clone(ref=s, protected=true)
|
||||||
|
let None = Chain.clone(ref=s, protected=true, gas=1)
|
||||||
let None = Chain.clone(ref=l, protected=true, 123)
|
let None = Chain.clone(ref=l, protected=true, 123)
|
||||||
let s3 = Chain.clone(ref=s1)
|
let s3 = Chain.clone(ref=s1)
|
||||||
require(s1.apply(2137) == 2137, "APPLY_S1_0")
|
require(s1.apply(2137) == 2137, "APPLY_S1_0")
|
||||||
|
@ -2,6 +2,6 @@ contract interface I =
|
|||||||
entrypoint init : () => void
|
entrypoint init : () => void
|
||||||
|
|
||||||
contract C =
|
contract C =
|
||||||
entrypoint f(i : I) =
|
stateful entrypoint f(i : I) =
|
||||||
let Some(c1) = Chain.clone(ref=i, protected = true)
|
let Some(c1) = Chain.clone(ref=i, protected = true)
|
||||||
2
|
2
|
@ -1,28 +1,14 @@
|
|||||||
contract T =
|
include "List.aes"
|
||||||
entrypoint f(x, y) = 3
|
|
||||||
main contract IntegerAdderFactory =
|
|
||||||
stateful payable entrypoint calculateSomething(x, t) =
|
|
||||||
// let t = Chain.create(value = 5555) : T
|
|
||||||
t.f(protected = true, gas = 999999999, value = 777777, 111, 222)
|
|
||||||
// t.f()
|
|
||||||
|
|
||||||
/*
|
contract IntegerHolder =
|
||||||
contract IntegerAdder =
|
type state = int
|
||||||
entrypoint init() = ()
|
entrypoint init(x) = x
|
||||||
entrypoint addIntegers(x, y) = x + y
|
|
||||||
|
|
||||||
contract IntegerAdderHolder =
|
|
||||||
type state = IntegerAdder
|
|
||||||
entrypoint init() = Chain.create() : IntegerAdder
|
|
||||||
entrypoint get() = state
|
entrypoint get() = state
|
||||||
|
|
||||||
namespace IntegerAdderFactory =
|
main contract IntegerCollection =
|
||||||
function new() =
|
record state = {template: IntegerHolder, payload: list(IntegerHolder)}
|
||||||
let i = Chain.create() : IntegerAdderHolder
|
stateful entrypoint init() = {template = Chain.create(0), payload = []}
|
||||||
i.get()
|
stateful entrypoint add(x) =
|
||||||
|
put(state{payload @ p = Chain.clone(ref=state.template, x) :: p})
|
||||||
main contract EnterpriseContract =
|
x
|
||||||
entrypoint calculateSomething(x) =
|
entrypoint sum() = List.sum(List.map((h) => h.get(), state.payload))
|
||||||
let adder = IntegerAdderFactory.new()
|
|
||||||
adder.addIntegers(x, 2137)
|
|
||||||
*/
|
|
Loading…
x
Reference in New Issue
Block a user