Less hacky handling of Chain.event

This commit is contained in:
Ulf Norell 2019-02-08 14:48:38 +01:00
parent 236ef6eb89
commit b5b0d30fc4
2 changed files with 5 additions and 5 deletions

View File

@ -193,10 +193,10 @@ bind_state(Env) ->
Env1 = bind_funs([{"state", State}, Env1 = bind_funs([{"state", State},
{"put", {fun_t, Ann, [], [State], Unit}}], Env), {"put", {fun_t, Ann, [], [State], Unit}}], Env),
%% A bit of a hack: we bind Chain.event with the local event type. %% We bind Chain.event in a local 'Chain' namespace.
Env2 = force_bind_fun("event", {fun_t, Ann, [], [Event], Unit}, pop_scope(
Env1#env{ namespace = ["Chain"] }), bind_fun("event", {fun_t, Ann, [], [Event], Unit},
Env2#env{ namespace = Env1#env.namespace }. push_scope(namespace, {con, Ann, "Chain"}, Env1))).
-spec bind_field(name(), field_info(), env()) -> env(). -spec bind_field(name(), field_info(), env()) -> env().
bind_field(X, Info, Env = #env{ fields = Fields }) -> bind_field(X, Info, Env = #env{ fields = Fields }) ->

View File

@ -140,7 +140,7 @@ ast_type(T, Icode) ->
ast_body(?qid_app(["Chain","spend"], [To, Amount], _, _), Icode) -> ast_body(?qid_app(["Chain","spend"], [To, Amount], _, _), Icode) ->
prim_call(?PRIM_CALL_SPEND, ast_body(Amount, Icode), [ast_body(To, Icode)], [word], {tuple, []}); prim_call(?PRIM_CALL_SPEND, ast_body(Amount, Icode), [ast_body(To, Icode)], [word], {tuple, []});
ast_body(?qid_app(["Chain","event"], [Event], _, _), Icode) -> ast_body(?qid_app([Con, "Chain", "event"], [Event], _, _), Icode = #{ contract_name := Con }) ->
aeso_builtins:check_event_type(Icode), aeso_builtins:check_event_type(Icode),
builtin_call({event, maps:get(event_type, Icode)}, [ast_body(Event, Icode)]); builtin_call({event, maps:get(event_type, Icode)}, [ast_body(Event, Icode)]);