Fix some tests. Remove optimization of singleton tuples
This commit is contained in:
parent
5c43be22b9
commit
b1b2dc849a
@ -208,10 +208,13 @@ namespace List =
|
||||
[] => false
|
||||
h::t => if(p(h)) true else any(p, t)
|
||||
|
||||
function sum(l : list(int)) : int = foldl ((a, b) => a + b, 0, l)
|
||||
|
||||
function product(l : list(int)) : int = foldl((a, b) => a * b, 1, l)
|
||||
function sum(l : list(int)) : int = switch(l)
|
||||
[] => 0
|
||||
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.
|
||||
* 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, ?CONSTRUCTOR_MOCK_NAME},
|
||||
contract_call_type(
|
||||
case [ {fun_t, [stateful,payable|Sys], [], [ArgT || {typed, _, _, ArgT} <- Args], {id, Sys, "void"}}
|
||||
|| {letfun, _, {id, _, "init"}, Args, _, _} <- Contents] of
|
||||
case [ [ArgT || {typed, _, _, ArgT} <- Args]
|
||||
|| {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"}};
|
||||
[T] -> T
|
||||
[Args] -> {fun_t, [stateful,payable|Sys], [], Args, {id, Sys, "void"}}
|
||||
end
|
||||
)
|
||||
}
|
||||
|
@ -715,14 +715,14 @@ expr_to_fcode(Env, Type, {app, _, Fun = {typed, _, FunE, {fun_t, _, NamedArgsT,
|
||||
case ArgsT of
|
||||
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])
|
||||
end;
|
||||
{builtin_u, chain_create, _Ar} ->
|
||||
case {ArgsT, Type} of
|
||||
{var_args, _} -> fcode_error({var_args_not_set, FunE});
|
||||
{_, {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]);
|
||||
{_, _} -> fcode_error({not_a_contract_type, Type})
|
||||
end;
|
||||
|
@ -125,7 +125,6 @@ type_to_scode(bits) -> bits;
|
||||
type_to_scode(any) -> any;
|
||||
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({tuple, [Type]}) -> type_to_scode(Type);
|
||||
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({function, _Args, _Res}) -> {tuple, [string, any]};
|
||||
@ -590,9 +589,6 @@ builtin_to_scode(Env, chain_create,
|
||||
[Code, TypeRep, Value | InitArgs]
|
||||
).
|
||||
|
||||
|
||||
|
||||
|
||||
%% -- Operators --
|
||||
|
||||
op_to_scode('+') -> aeb_fate_ops:add(?a, ?a, ?a);
|
||||
|
@ -127,9 +127,9 @@ compile(Backend, Name, Options) ->
|
||||
%% compilable_contracts() -> [ContractName].
|
||||
%% The currently compilable contracts.
|
||||
|
||||
compilable_contracts() -> ["test"]; % FIXME remove
|
||||
compilable_contracts() ->
|
||||
["complex_types",
|
||||
["test",
|
||||
"complex_types",
|
||||
"counter",
|
||||
"dutch_auction",
|
||||
"environment",
|
||||
@ -182,7 +182,7 @@ compilable_contracts() ->
|
||||
"protected_call",
|
||||
"hermetization_turnoff",
|
||||
"multiple_contracts",
|
||||
"clone", "clone_simple"
|
||||
"clone", "clone_simple", "create"
|
||||
].
|
||||
|
||||
not_compilable_on(fate) -> [];
|
||||
|
@ -5,13 +5,15 @@ contract interface HigherOrderState =
|
||||
stateful entrypoint inc : int => unit
|
||||
|
||||
contract interface LowerDisorderAnarchy =
|
||||
entrypoint init : int => void
|
||||
entrypoint init : (int) => void
|
||||
|
||||
|
||||
main contract C =
|
||||
// both `s` and `l` should be of type `HigherOrderState` in this test
|
||||
stateful entrypoint run_clone(s : HigherOrderState, l : LowerDisorderAnarchy) : HigherOrderState =
|
||||
let s1 = Chain.clone(ref=s)
|
||||
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 s3 = Chain.clone(ref=s1)
|
||||
require(s1.apply(2137) == 2137, "APPLY_S1_0")
|
||||
|
@ -2,6 +2,6 @@ contract interface I =
|
||||
entrypoint init : () => void
|
||||
|
||||
contract C =
|
||||
entrypoint f(i : I) =
|
||||
stateful entrypoint f(i : I) =
|
||||
let Some(c1) = Chain.clone(ref=i, protected = true)
|
||||
2
|
@ -1,28 +1,14 @@
|
||||
contract T =
|
||||
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()
|
||||
include "List.aes"
|
||||
|
||||
/*
|
||||
contract IntegerAdder =
|
||||
entrypoint init() = ()
|
||||
entrypoint addIntegers(x, y) = x + y
|
||||
|
||||
contract IntegerAdderHolder =
|
||||
type state = IntegerAdder
|
||||
entrypoint init() = Chain.create() : IntegerAdder
|
||||
contract IntegerHolder =
|
||||
type state = int
|
||||
entrypoint init(x) = x
|
||||
entrypoint get() = state
|
||||
|
||||
namespace IntegerAdderFactory =
|
||||
function new() =
|
||||
let i = Chain.create() : IntegerAdderHolder
|
||||
i.get()
|
||||
|
||||
main contract EnterpriseContract =
|
||||
entrypoint calculateSomething(x) =
|
||||
let adder = IntegerAdderFactory.new()
|
||||
adder.addIntegers(x, 2137)
|
||||
*/
|
||||
main contract IntegerCollection =
|
||||
record state = {template: IntegerHolder, payload: list(IntegerHolder)}
|
||||
stateful entrypoint init() = {template = Chain.create(0), payload = []}
|
||||
stateful entrypoint add(x) =
|
||||
put(state{payload @ p = Chain.clone(ref=state.template, x) :: p})
|
||||
x
|
||||
entrypoint sum() = List.sum(List.map((h) => h.get(), state.payload))
|
Loading…
x
Reference in New Issue
Block a user