diff --git a/rebar.config b/rebar.config index 5f75d04..99ed2cd 100644 --- a/rebar.config +++ b/rebar.config @@ -6,7 +6,7 @@ {deps, [ {eblake2, "1.0.0"} , {aeserialization, {git, "https://github.com/aeternity/aeserialization.git", - {ref, "6dce265"}}} + {ref, "816bf99"}}} , {getopt, "1.0.1"} ]}. diff --git a/rebar.lock b/rebar.lock index 0e58139..188572f 100644 --- a/rebar.lock +++ b/rebar.lock @@ -1,7 +1,7 @@ {"1.1.0", [{<<"aeserialization">>, {git,"https://github.com/aeternity/aeserialization.git", - {ref,"6dce265753af4e651f77746e77ea125145c85dd3"}}, + {ref,"816bf994ffb5cee218c3f22dc5fea296c9e0882e"}}, 0}, {<<"base58">>, {git,"https://github.com/aeternity/erl-base58.git", diff --git a/src/aeb_fate_generate_ops.erl b/src/aeb_fate_generate_ops.erl index 5c224ca..8909a05 100644 --- a/src/aeb_fate_generate_ops.erl +++ b/src/aeb_fate_generate_ops.erl @@ -30,9 +30,9 @@ ops_defs() -> %% Opname, Opcode, args, end_bb, gas, format, Constructor, Documentation [ { 'RETURN', 16#00, 0, true, 2, atomic, return, "Return from function call pop stack to arg0. The type of the retun value has to match the return type of the function."} , { 'RETURNR', 16#01, 1, true, 2, [a], returnr, "Return from function call copy Arg0 to arg0. The type of the retun value has to match the return type of the function."} - , { 'CALL', 16#02, 1, true, 4, [is], call, "Call given function with args on stack. The types of the arguments has to match the argument typs of the function."} + , { 'CALL', 16#02, 1, true, 4, [a], call, "Call the function Arg0 with args on stack. The types of the arguments has to match the argument typs of the function."} , { 'CALL_R', 16#03, 2, true, 8, [a,is], call_r, "Remote call to given contract and function. The types of the arguments has to match the argument typs of the function."} - , { 'CALL_T', 16#04, 1, true, 4, [is], call_t, "Tail call to given function. The types of the arguments has to match the argument typs of the function. And the return type of the called function has to match the type of the current function."} + , { 'CALL_T', 16#04, 1, true, 4, [a], call_t, "Tail call to function Arg0. The types of the arguments has to match the argument typs of the function. And the return type of the called function has to match the type of the current function."} , { 'CALL_TR', 16#05, 2, true, 8, [a,is], call_tr, "Remote tail call to given contract and function. The types of the arguments has to match the argument typs of the function. And the return type of the called function has to match the type of the current function."} , { 'JUMP', 16#06, 1, true, 3, [ii], jump, "Jump to a basic block. The basic block has to exist in the current function."} , { 'JUMPIF', 16#07, 2, true, 4, [a,ii], jumpif, "Conditional jump to a basic block. If Arg0 then jump to Arg1."} @@ -78,7 +78,7 @@ ops_defs() -> , { 'HD', 16#35, 2, false, 3, [a,a], hd, "Arg0 := head of list Arg1."} , { 'TL', 16#36, 2, false, 3, [a,a], tl, "Arg0 := tail of list Arg1."} , { 'LENGTH', 16#37, 2, false, 3, [a,a], length, "Arg0 := length of list Arg1."} - , { 'STR_EQ', 16#38, 3, false, 3, [a,a,a], str_eq, "Arg0 := true iff the strings Arg1 and Arg2 are the same."} + , { 'APPEND', 16#38, 3, false, 3, [a,a,a], append, "Arg0 := Arg1 ++ Arg2."} , { 'STR_JOIN', 16#39, 3, false, 3, [a,a,a], str_join, "Arg0 := string Arg1 followed by string Arg2."} , { 'INT_TO_STR', 16#40, 2, false, 3, [a,a], int_to_str, "Arg0 := turn integer Arg1 into a string."} , { 'ADDR_TO_STR', 16#41, 2, false, 3, [a,a], addr_to_str, "Arg0 := turn address Arg1 into a string."} @@ -287,7 +287,7 @@ gen_arg_uses(_, []) -> gen_arg_uses(N, [a]) -> io_lib:format("Arg~w", [N]); gen_arg_uses(N, [is]) -> io_lib:format("{immediate, Arg~w}", [N]); gen_arg_uses(N, [ii]) -> io_lib:format("{immediate, Arg~w}", [N]); -gen_arg_uses(N, [li]) -> io_lib:format("[{immediate, I} || I <- Arg~w]", [N]); +gen_arg_uses(N, [li]) -> io_lib:format("{immediate, Arg~w}", [N]); gen_arg_uses(N, [t]) -> io_lib:format("Arg~w", [N]); gen_arg_uses(N, [a | Args]) -> io_lib:format("Arg~w, ", [N]) ++ gen_arg_uses(N+1, Args); @@ -381,7 +381,7 @@ expand_types([T|Ts]) ->expand_type(T) ++ ", " ++ expand_types(Ts). expand_type(a) -> "fate_arg()"; expand_type(is) -> "fate_arg_immediate(aeb_fate_data:fate_string())"; expand_type(ii) -> "fate_arg_immediate(aeb_fate_data:fate_integer())"; -expand_type(li) -> "[fate_arg_immediate(aeb_fate_data:fate_integer())]"; +expand_type(li) -> "fate_arg_immediate([aeb_fate_data:fate_integer()])"; expand_type(t) -> "aeb_fate_data:fate_type_type()". generate_scanner(TemplateFile, Outfile, Path, Ops) -> @@ -427,17 +427,13 @@ gen_asm_pp(Module, Path, Ops) -> "format_arg(a, {stack, 0}) -> \"a\";\n" "format_arg(a, {stack, N}) -> io_lib:format(\"a~~p\", [N]).\n\n" "lookup(Name, Symbols) ->\n" - " maps:get(Name, Symbols, io_lib:format(\"~~w\",[Name])).\n\n" + " maps:get(Name, Symbols, io_lib:format(\"~~p\",[Name])).\n\n" "~s" , [Formats]), io:format(File, "format_op(Op, _Symbols) -> io_lib:format(\";; Bad Op: ~~w\\n\", [Op]).\n", []), file:close(File). -gen_format(#{opname := Name}) when ('CALL' =:= Name) or (Name =:= 'CALL_T') -> - io_lib:format("format_op({~w, {immediate, Function}}, Symbols) ->\n" - "[\"~s \", lookup(Function, Symbols)];", - [Name, atom_to_list(Name)]); gen_format(#{opname := Name}) when (Name =:= 'CALL_R') or (Name =:= 'CALL_TR') -> io_lib:format("format_op({~w, {immediate, Contract}, {immediate, Function}}, Symbols) ->\n" "[\"~s \", lookup(Contract, Symbols), \".\", lookup(Function, Symbols)];\n" diff --git a/test/asm_code/all_instructions.fate b/test/asm_code/all_instructions.fate index 1cdfeb0..472f9fe 100644 --- a/test/asm_code/all_instructions.fate +++ b/test/asm_code/all_instructions.fate @@ -8,11 +8,11 @@ FUNCTION foo () : {tuple, []} RETURNR a13 - CALL foo + CALL "foo" CALL_R arg125 foo - CALL_T foo + CALL_T "foo" CALL_TR arg245 foo @@ -104,7 +104,7 @@ FUNCTION foo () : {tuple, []} LENGTH var216 a143 - STR_EQ { 203961992615221001243597889146034217896 => 0x1f53a1843} 281217554184165828643225535776787296845 a177 + APPEND { 203961992615221001243597889146034217896 => 0x1f53a1843} 281217554184165828643225535776787296845 a177 STR_JOIN a a 7144184027126178769820155907121270843348 diff --git a/test/asm_code/memory.fate b/test/asm_code/memory.fate index e162daa..ede1e57 100644 --- a/test/asm_code/memory.fate +++ b/test/asm_code/memory.fate @@ -2,7 +2,7 @@ FUNCTION call(integer):integer STORE var1 arg0 PUSH 0 - CALL write + CALL "write" PUSH var1 RETURN diff --git a/test/asm_code/test.fate b/test/asm_code/test.fate index aae9102..e08c0eb 100644 --- a/test/asm_code/test.fate +++ b/test/asm_code/test.fate @@ -19,14 +19,14 @@ FUNCTION inc(integer) -> integer FUNCTION call(integer) -> integer INCA - CALL inc + CALL "inc" INCA RETURN FUNCTION tailcall(integer) -> integer INCA - CALL_T inc + CALL_T "inc" FUNCTION remote_call(integer) : integer PUSH arg0 @@ -42,4 +42,4 @@ FUNCTION remote_tailcall(integer) : integer ;; _build/default/rel/aessembler/bin/aessembler console ;; aeb_aefa:file("../../../../test/asm_code/test.fate", []). -;; f(Asm), f(Env), f(BC), Asm = aefa_asm:read_file("../../../../test/asm_code/test.fate"), {Env, BC} = aefa_asm:asm_to_bytecode(Asm, []), aefa_asm:bytecode_to_fate_code(BC, []). \ No newline at end of file +;; f(Asm), f(Env), f(BC), Asm = aefa_asm:read_file("../../../../test/asm_code/test.fate"), {Env, BC} = aefa_asm:asm_to_bytecode(Asm, []), aefa_asm:bytecode_to_fate_code(BC, []).