Merge pull request #75 from aeternity/PT-168256282-disallow_calls_to_init

Implement aeb_fate_code:strip_init_function/1
This commit is contained in:
Hans Svensson 2019-09-03 13:12:59 +02:00 committed by GitHub
commit 5e16b85ae2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -19,6 +19,7 @@
, serialize/3 , serialize/3
, serialize_code/1 , serialize_code/1
, serialize_signature/1 , serialize_signature/1
, strip_init_function/1
, symbol_identifier/1 , symbol_identifier/1
, symbols/1 , symbols/1
]). ]).
@ -92,6 +93,13 @@ insert_annotation(comment =_Type, Line, Comment, FCode) ->
Value = aeb_fate_data:make_string(Comment), Value = aeb_fate_data:make_string(Comment),
update_annotations(FCode, #{ Key => Value }). update_annotations(FCode, #{ Key => Value }).
strip_init_function(#fcode{ functions = Funs,
symbols = Syms } = FCode) ->
Id = symbol_identifier(<<"init">>),
Funs1 = maps:remove(Id, Funs),
Syms1 = maps:remove(Id, Syms),
FCode#fcode{ functions = Funs1, symbols = Syms1 }.
%%%=================================================================== %%%===================================================================
%%% Serialization %%% Serialization
%%%=================================================================== %%%===================================================================