Cleanup whitespace, bad typespec, and remaining enacl reference
This commit is contained in:
parent
53299b9b17
commit
f1f2b09294
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
|
|
||||||
-type option() :: pp_sophia_code | pp_ast | pp_types | pp_typed_ast |
|
-type option() :: pp_sophia_code | pp_ast | pp_types | pp_typed_ast |
|
||||||
pp_icode| pp_assembler | pp_bytecode.
|
pp_icode| pp_assembler | pp_bytecode.
|
||||||
-type options() :: [option()].
|
-type options() :: [option()].
|
||||||
|
|
||||||
-export_type([ option/0
|
-export_type([ option/0
|
||||||
@ -38,50 +38,50 @@
|
|||||||
version() ->
|
version() ->
|
||||||
?COMPILER_VERSION.
|
?COMPILER_VERSION.
|
||||||
|
|
||||||
-spec file(string()) -> map().
|
-spec file(string()) -> {ok, map()} | {error, binary()}.
|
||||||
file(Filename) ->
|
file(Filename) ->
|
||||||
file(Filename, []).
|
file(Filename, []).
|
||||||
|
|
||||||
-spec file(string(), options()) -> map().
|
-spec file(string(), options()) -> {ok, map()} | {error, binary()}.
|
||||||
file(File, Options) ->
|
file(File, Options) ->
|
||||||
case read_contract(File, Options) of
|
case read_contract(File, Options) of
|
||||||
{ok,Bin} -> from_string(Bin, Options);
|
{ok, Bin} -> from_string(Bin, Options);
|
||||||
{error,Error} -> {error,{File,Error}}
|
{error, Error} -> {error, {File, Error}}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
-spec from_string(binary() | string(), options()) -> map().
|
-spec from_string(binary() | string(), options()) -> {ok, map()} | {error, binary()}.
|
||||||
from_string(ContractBin, Options) when is_binary(ContractBin) ->
|
from_string(ContractBin, Options) when is_binary(ContractBin) ->
|
||||||
from_string(binary_to_list(ContractBin), Options);
|
from_string(binary_to_list(ContractBin), Options);
|
||||||
from_string(ContractString, Options) ->
|
from_string(ContractString, Options) ->
|
||||||
try
|
try
|
||||||
Ast = parse(ContractString, Options),
|
Ast = parse(ContractString, Options),
|
||||||
ok = pp_sophia_code(Ast, Options),
|
ok = pp_sophia_code(Ast, Options),
|
||||||
ok = pp_ast(Ast, Options),
|
ok = pp_ast(Ast, Options),
|
||||||
TypedAst = aeso_ast_infer_types:infer(Ast, Options),
|
TypedAst = aeso_ast_infer_types:infer(Ast, Options),
|
||||||
%% pp_types is handled inside aeso_ast_infer_types.
|
%% pp_types is handled inside aeso_ast_infer_types.
|
||||||
ok = pp_typed_ast(TypedAst, Options),
|
ok = pp_typed_ast(TypedAst, Options),
|
||||||
ICode = to_icode(TypedAst, Options),
|
ICode = to_icode(TypedAst, Options),
|
||||||
TypeInfo = extract_type_info(ICode),
|
TypeInfo = extract_type_info(ICode),
|
||||||
ok = pp_icode(ICode, Options),
|
ok = pp_icode(ICode, Options),
|
||||||
Assembler = assemble(ICode, Options),
|
Assembler = assemble(ICode, Options),
|
||||||
ok = pp_assembler(Assembler, Options),
|
ok = pp_assembler(Assembler, Options),
|
||||||
ByteCodeList = to_bytecode(Assembler, Options),
|
ByteCodeList = to_bytecode(Assembler, Options),
|
||||||
ByteCode = << << B:8 >> || B <- ByteCodeList >>,
|
ByteCode = << << B:8 >> || B <- ByteCodeList >>,
|
||||||
ok = pp_bytecode(ByteCode, Options),
|
ok = pp_bytecode(ByteCode, Options),
|
||||||
{ok,#{byte_code => ByteCode,
|
{ok, #{byte_code => ByteCode,
|
||||||
compiler_version => version(),
|
compiler_version => version(),
|
||||||
contract_source => ContractString,
|
contract_source => ContractString,
|
||||||
type_info => TypeInfo
|
type_info => TypeInfo
|
||||||
}}
|
}}
|
||||||
catch
|
catch
|
||||||
%% The compiler errors.
|
%% The compiler errors.
|
||||||
error:{parse_errors,Errors} ->
|
error:{parse_errors, Errors} ->
|
||||||
{error,join_errors("Parse errors", Errors, fun(E) -> E end)};
|
{error, join_errors("Parse errors", Errors, fun(E) -> E end)};
|
||||||
error:{type_errors,Errors} ->
|
error:{type_errors, Errors} ->
|
||||||
{error,join_errors("Type errors", Errors, fun(E) -> E end)};
|
{error, join_errors("Type errors", Errors, fun(E) -> E end)};
|
||||||
error:{code_errors,Errors} ->
|
error:{code_errors, Errors} ->
|
||||||
{error,join_errors("Code errors", Errors,
|
{error, join_errors("Code errors", Errors,
|
||||||
fun (E) -> io_lib:format("~p", [E]) end)}
|
fun (E) -> io_lib:format("~p", [E]) end)}
|
||||||
%% General programming errors in the compiler just signal error.
|
%% General programming errors in the compiler just signal error.
|
||||||
end.
|
end.
|
||||||
|
|
||||||
@ -99,35 +99,35 @@ join_errors(Prefix, Errors, Pfun) ->
|
|||||||
when Type :: term().
|
when Type :: term().
|
||||||
check_call(ContractString, Options) ->
|
check_call(ContractString, Options) ->
|
||||||
try
|
try
|
||||||
Ast = parse(ContractString, Options),
|
Ast = parse(ContractString, Options),
|
||||||
ok = pp_sophia_code(Ast, Options),
|
ok = pp_sophia_code(Ast, Options),
|
||||||
ok = pp_ast(Ast, Options),
|
ok = pp_ast(Ast, Options),
|
||||||
TypedAst = aeso_ast_infer_types:infer(Ast, [permissive_address_literals]),
|
TypedAst = aeso_ast_infer_types:infer(Ast, [permissive_address_literals]),
|
||||||
{ok, {FunName, {fun_t, _, _, ArgTypes, RetType}}} = get_call_type(TypedAst),
|
{ok, {FunName, {fun_t, _, _, ArgTypes, RetType}}} = get_call_type(TypedAst),
|
||||||
ok = pp_typed_ast(TypedAst, Options),
|
ok = pp_typed_ast(TypedAst, Options),
|
||||||
Icode = to_icode(TypedAst, Options),
|
Icode = to_icode(TypedAst, Options),
|
||||||
ArgVMTypes = [ aeso_ast_to_icode:ast_typerep(T, Icode) || T <- ArgTypes ],
|
ArgVMTypes = [ aeso_ast_to_icode:ast_typerep(T, Icode) || T <- ArgTypes ],
|
||||||
RetVMType = case RetType of
|
RetVMType = case RetType of
|
||||||
{id, _, "_"} -> any;
|
{id, _, "_"} -> any;
|
||||||
_ -> aeso_ast_to_icode:ast_typerep(RetType, Icode)
|
_ -> aeso_ast_to_icode:ast_typerep(RetType, Icode)
|
||||||
end,
|
end,
|
||||||
ok = pp_icode(Icode, Options),
|
ok = pp_icode(Icode, Options),
|
||||||
#{ functions := Funs } = Icode,
|
#{ functions := Funs } = Icode,
|
||||||
ArgIcode = get_arg_icode(Funs),
|
ArgIcode = get_arg_icode(Funs),
|
||||||
ArgTerms = [ icode_to_term(T, Arg) ||
|
ArgTerms = [ icode_to_term(T, Arg) ||
|
||||||
{T, Arg} <- lists:zip(ArgVMTypes, ArgIcode) ],
|
{T, Arg} <- lists:zip(ArgVMTypes, ArgIcode) ],
|
||||||
{ok, FunName, {ArgVMTypes, RetVMType}, ArgTerms}
|
{ok, FunName, {ArgVMTypes, RetVMType}, ArgTerms}
|
||||||
catch
|
catch
|
||||||
error:{parse_errors, Errors} ->
|
error:{parse_errors, Errors} ->
|
||||||
{error,join_errors("Parse errors", Errors, fun (E) -> E end)};
|
{error, join_errors("Parse errors", Errors, fun (E) -> E end)};
|
||||||
error:{type_errors, Errors} ->
|
error:{type_errors, Errors} ->
|
||||||
{error,join_errors("Type errors", Errors, fun (E) -> E end)};
|
{error, join_errors("Type errors", Errors, fun (E) -> E end)};
|
||||||
error:{badmatch,{error,missing_call_function}} ->
|
error:{badmatch, {error, missing_call_function}} ->
|
||||||
{error,join_errors("Type errors", ["missing __call function"],
|
{error, join_errors("Type errors", ["missing __call function"],
|
||||||
fun (E) -> E end)};
|
fun (E) -> E end)};
|
||||||
throw:Error -> %Don't ask
|
throw:Error -> %Don't ask
|
||||||
{error,join_errors("Code errors", [Error],
|
{error, join_errors("Code errors", [Error],
|
||||||
fun (E) -> io_lib:format("~p", [E]) end)}
|
fun (E) -> io_lib:format("~p", [E]) end)}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
-spec create_calldata(map(), string(), string()) ->
|
-spec create_calldata(map(), string(), string()) ->
|
||||||
@ -279,9 +279,9 @@ parse_string(Text) ->
|
|||||||
parse_error(Pos, ErrorString)
|
parse_error(Pos, ErrorString)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
parse_error({Line,Pos}, ErrorString) ->
|
parse_error({Line, Pos}, ErrorString) ->
|
||||||
Error = io_lib:format("line ~p, column ~p: ~s", [Line,Pos,ErrorString]),
|
Error = io_lib:format("line ~p, column ~p: ~s", [Line, Pos, ErrorString]),
|
||||||
error({parse_errors,[Error]}).
|
error({parse_errors, [Error]}).
|
||||||
|
|
||||||
read_contract(Name, Opts) ->
|
read_contract(Name, Opts) ->
|
||||||
FileName = filename(Name, ".aes", Opts),
|
FileName = filename(Name, ".aes", Opts),
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
{applications,
|
{applications,
|
||||||
[kernel,
|
[kernel,
|
||||||
stdlib,
|
stdlib,
|
||||||
enacl,
|
|
||||||
syntax_tools,
|
syntax_tools,
|
||||||
aebytecode
|
aebytecode
|
||||||
]},
|
]},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user