From 5f5444ca9ec1717235e00303c18b0cabc3ff0034 Mon Sep 17 00:00:00 2001 From: Erik Stenman Date: Sat, 29 Jun 2019 16:28:51 +0200 Subject: [PATCH] Provide info for tracing. --- src/aeb_fate_code.erl | 25 ++++++++++++++++++++++++- src/aeb_fate_generate_ops.erl | 10 ++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/aeb_fate_code.erl b/src/aeb_fate_code.erl index 73c1ea1..74c06f5 100644 --- a/src/aeb_fate_code.erl +++ b/src/aeb_fate_code.erl @@ -39,8 +39,31 @@ -define(HASH_BYTES, 32). +-type fate_arg_spec() :: {'immediate', aeb_fate_data:fate_type()} + | {'arg', integer()} + | {'var', integer()} + | {'stack', 0}. + +-type fate_instruction() :: atom() + | {atom(), fate_arg_spec()} + | {atom(), fate_arg_spec(), fate_arg_spec()} + | {atom(), fate_arg_spec(), fate_arg_spec(), fate_arg_spec()} + | {atom(), fate_arg_spec(), fate_arg_spec(), fate_arg_spec(), + fate_arg_spec()} + | {atom(), fate_arg_spec(), fate_arg_spec(), fate_arg_spec(), + fate_arg_spec(), fate_arg_spec()} + | {atom(), fate_arg_spec(), fate_arg_spec(), fate_arg_spec(), + fate_arg_spec(), fate_arg_spec(), fate_arg_spec()} + | {atom(), fate_arg_spec(), fate_arg_spec(), fate_arg_spec(), + fate_arg_spec(), fate_arg_spec(), fate_arg_spec(), + fate_arg_spec()} + | {atom(), fate_arg_spec(), fate_arg_spec(), fate_arg_spec(), + fate_arg_spec(), fate_arg_spec(), fate_arg_spec(), + fate_arg_spec(), fate_arg_spec()}. + + -type fcode() :: #fcode{}. --export_type([fcode/0]). +-export_type([fate_arg_spec/0, fate_instruction/0, fcode/0]). %%%=================================================================== %%% API diff --git a/src/aeb_fate_generate_ops.erl b/src/aeb_fate_generate_ops.erl index 83b5184..dc519ea 100644 --- a/src/aeb_fate_generate_ops.erl +++ b/src/aeb_fate_generate_ops.erl @@ -205,6 +205,7 @@ generate_opcodes_ops(Modulename, HrlFile, SrcDir, Ops) -> Args = lists:flatten([gen_args(Op) || Op <- Ops]), EndBB = lists:flatten([gen_bb(Op) || Op <- Ops]), InAuth = lists:flatten([gen_in_auth(Op) || Op <- Ops]), + ResType = lists:flatten([gen_res_type(Op) || Op <- Ops]), io:format(File, "~s", [prelude("Provides opcode primitives.\n")]), io:format(File, "~s", [ops_exports(Modulename, HrlFile, @@ -213,6 +214,7 @@ generate_opcodes_ops(Modulename, HrlFile, SrcDir, Ops) -> " , in_auth/1\n" " , mnemonic/1\n" " , m_to_op/1\n" + " , result_type/1\n" ])]), io:format(File, "%% FATE mnemonics\n~s", [Mnemonic]), @@ -230,6 +232,9 @@ generate_opcodes_ops(Modulename, HrlFile, SrcDir, Ops) -> io:format(File, "%% Is FATE Op allowed in GA Authentication context?\n~s", [InAuth]), io:format(File, "in_auth(_) -> false.\n\n", []), + io:format(File, "%% What is the result type.\n~s", [ResType]), + io:format(File, "result_type(_) -> none.\n\n", []), + file:close(File). generate_code_ops(Modulename, SrcDir, Ops) -> @@ -369,6 +374,11 @@ gen_in_auth(#{macro := Macro, in_auth := InAuth}) -> lists:flatten(io_lib:format("in_auth(~21s) -> ~w ;\n", [Macro, InAuth])). +gen_res_type(#{macro := Macro, res_type := ResType}) -> + lists:flatten(io_lib:format("result_type(~21s) -> ~w ;\n", + [Macro, ResType])). + + prelude(Doc) -> "%%%-------------------------------------------------------------------\n" "%%% @copyright (C) 2019, Aeternity Anstalt\n"