diff --git a/src/aefa_asm.erl b/src/aefa_asm.erl index 430761e..afefe04 100644 --- a/src/aefa_asm.erl +++ b/src/aefa_asm.erl @@ -269,7 +269,7 @@ to_bytecode([], Address, Env, Code, Opts) -> to_fun_def([{id, _, Name}, {'(', _} | Rest]) -> - {ArgsType, [{'->', _} | Rest2]} = to_arg_types(Rest), + {ArgsType, [{'to', _} | Rest2]} = to_arg_types(Rest), {RetType, Rest3} = to_type(Rest2), {{Name, ArgsType, RetType}, Rest3}. diff --git a/src/aefa_asm_scan.xrl b/src/aefa_asm_scan.xrl index bbc7290..c252cdf 100644 --- a/src/aefa_asm_scan.xrl +++ b/src/aefa_asm_scan.xrl @@ -132,7 +132,8 @@ COMMENT : {token, {mnemonic, TokenLine, 'COMMENT'}}. %% Symbols -\-\> : {token, {'->', TokenLine}}. +\-\> : {token, {'to', TokenLine}}. +\: : {token, {'to', TokenLine}}. , : {token, {',', TokenLine}}. \. : {token, {'.', TokenLine}}. \( : {token, {'(', TokenLine}}. diff --git a/src/aefa_opcodes.erl b/src/aefa_opcodes.erl index 809601f..48d45f3 100644 --- a/src/aefa_opcodes.erl +++ b/src/aefa_opcodes.erl @@ -30,7 +30,8 @@ mnemonic(?PUSH) -> 'PUSH' ; mnemonic(?JUMP) -> 'JUMP' ; mnemonic(?INC) -> 'INC' ; mnemonic(?CALL) -> 'CALL' ; -mnemonic(OP) -> {OP, nothandled} ; +mnemonic(?CALL_T) -> 'CALL_T' ; +mnemonic(OP) -> {OP, nothandled} ; mnemonic({comment,_}) -> 'COMMENT' . m_to_op('NOP') -> ?NOP ; @@ -40,6 +41,7 @@ m_to_op('PUSH') -> ?PUSH ; m_to_op('JUMP') -> ?JUMP ; m_to_op('INC') -> ?INC ; m_to_op('CALL') -> ?CALL ; +m_to_op('CALL_T') -> ?CALL_T ; m_to_op(Data) when 0= Data. args(?NOP) -> 0; @@ -48,10 +50,12 @@ args(?PUSH) -> 1; args(?JUMP) -> 1; args(?INC) -> 0; args(?CALL) -> hash; +args(?CALL_T) -> hash; args(_) -> 0. %% TODO do not allow this end_bb(?RETURN) -> true; -end_bb(?JUMP) -> true; -end_bb(?CALL) -> true; -end_bb(_) -> false. +end_bb(?JUMP) -> true; +end_bb(?CALL) -> true; +end_bb(?CALL_T) -> true; +end_bb(_) -> false. diff --git a/test/asm_code/test.fate b/test/asm_code/test.fate index 1afaa70..1cd6b20 100644 --- a/test/asm_code/test.fate +++ b/test/asm_code/test.fate @@ -23,6 +23,18 @@ FUNCTION call(integer) -> integer INC RETURN + +FUNCTION tailcall(integer) -> integer + INC + CALL_T inc + +FUNCTION remote_call(integer) : integer + PUSH arg0 + CALL_R remote.add_five + INC + RETURN + + ;; Test the code from the shell ;; _build/default/rel/aessembler/bin/aessembler console