Cleanup whitespace, bad typespec, and remaining enacl reference
This commit is contained in:
parent
3137bc4d4a
commit
cef2383726
@ -38,18 +38,18 @@
|
||||
version() ->
|
||||
?COMPILER_VERSION.
|
||||
|
||||
-spec file(string()) -> map().
|
||||
-spec file(string()) -> {ok, map()} | {error, binary()}.
|
||||
file(Filename) ->
|
||||
file(Filename, []).
|
||||
|
||||
-spec file(string(), options()) -> map().
|
||||
-spec file(string(), options()) -> {ok, map()} | {error, binary()}.
|
||||
file(File, Options) ->
|
||||
case read_contract(File) of
|
||||
{ok, Bin} -> from_string(Bin, Options);
|
||||
{error, Error} -> {error, {File, Error}}
|
||||
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(binary_to_list(ContractBin), Options);
|
||||
from_string(ContractString, Options) ->
|
||||
@ -68,19 +68,19 @@ from_string(ContractString, Options) ->
|
||||
ByteCodeList = to_bytecode(Assembler, Options),
|
||||
ByteCode = << << B:8 >> || B <- ByteCodeList >>,
|
||||
ok = pp_bytecode(ByteCode, Options),
|
||||
{ok,#{byte_code => ByteCode,
|
||||
{ok, #{byte_code => ByteCode,
|
||||
compiler_version => version(),
|
||||
contract_source => ContractString,
|
||||
type_info => TypeInfo
|
||||
}}
|
||||
catch
|
||||
%% The compiler errors.
|
||||
error:{parse_errors,Errors} ->
|
||||
{error,join_errors("Parse errors", Errors, fun(E) -> E end)};
|
||||
error:{type_errors,Errors} ->
|
||||
{error,join_errors("Type errors", Errors, fun(E) -> E end)};
|
||||
error:{code_errors,Errors} ->
|
||||
{error,join_errors("Code errors", Errors,
|
||||
error:{parse_errors, Errors} ->
|
||||
{error, join_errors("Parse errors", Errors, fun(E) -> E end)};
|
||||
error:{type_errors, Errors} ->
|
||||
{error, join_errors("Type errors", Errors, fun(E) -> E end)};
|
||||
error:{code_errors, Errors} ->
|
||||
{error, join_errors("Code errors", Errors,
|
||||
fun (E) -> io_lib:format("~p", [E]) end)}
|
||||
%% General programming errors in the compiler just signal error.
|
||||
end.
|
||||
@ -119,14 +119,14 @@ check_call(ContractString, Options) ->
|
||||
{ok, FunName, {ArgVMTypes, RetVMType}, ArgTerms}
|
||||
catch
|
||||
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,join_errors("Type errors", Errors, fun (E) -> E end)};
|
||||
error:{badmatch,{error,missing_call_function}} ->
|
||||
{error,join_errors("Type errors", ["missing __call function"],
|
||||
{error, join_errors("Type errors", Errors, fun (E) -> E end)};
|
||||
error:{badmatch, {error, missing_call_function}} ->
|
||||
{error, join_errors("Type errors", ["missing __call function"],
|
||||
fun (E) -> E end)};
|
||||
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)}
|
||||
end.
|
||||
|
||||
@ -279,9 +279,9 @@ parse_string(Text) ->
|
||||
parse_error(Pos, ErrorString)
|
||||
end.
|
||||
|
||||
parse_error({Line,Pos}, ErrorString) ->
|
||||
Error = io_lib:format("line ~p, column ~p: ~s", [Line,Pos,ErrorString]),
|
||||
error({parse_errors,[Error]}).
|
||||
parse_error({Line, Pos}, ErrorString) ->
|
||||
Error = io_lib:format("line ~p, column ~p: ~s", [Line, Pos, ErrorString]),
|
||||
error({parse_errors, [Error]}).
|
||||
|
||||
read_contract(Name) ->
|
||||
file:read_file(Name).
|
||||
|
Loading…
x
Reference in New Issue
Block a user