Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:20
erlang
2771-compile-Clean-up-collection-of-forms-from-...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 2771-compile-Clean-up-collection-of-forms-from-a-.S-file.patch of Package erlang
From e13d1d7c37e5e0e17fe3679708f919ae04a7198d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org> Date: Fri, 24 Jan 2020 06:32:25 +0100 Subject: [PATCH 1/6] compile: Clean up collection of forms from a .S file --- lib/compiler/src/compile.erl | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/lib/compiler/src/compile.erl b/lib/compiler/src/compile.erl index 894b255f93..97ae80df81 100644 --- a/lib/compiler/src/compile.erl +++ b/lib/compiler/src/compile.erl @@ -925,8 +925,6 @@ remove_file(Code, St) -> exports, labels, functions=[], - cfun, - code, attributes=[]}). preprocess_asm_forms(Forms) -> @@ -936,36 +934,30 @@ preprocess_asm_forms(Forms) -> {R1#asm_module.module, R1#asm_module.exports, R1#asm_module.attributes, - R1#asm_module.functions, + reverse(R1#asm_module.functions), R1#asm_module.labels}}. -collect_asm([], R) -> - case R#asm_module.cfun of - undefined -> - R; - {A,B,C} -> - R#asm_module{functions=R#asm_module.functions++ - [{function,A,B,C,R#asm_module.code}]} - end; collect_asm([{module,M} | Rest], R) -> collect_asm(Rest, R#asm_module{module=M}); collect_asm([{exports,M} | Rest], R) -> collect_asm(Rest, R#asm_module{exports=M}); collect_asm([{labels,M} | Rest], R) -> collect_asm(Rest, R#asm_module{labels=M}); -collect_asm([{function,A,B,C} | Rest], R) -> - R1 = case R#asm_module.cfun of - undefined -> - R; - {A0,B0,C0} -> - R#asm_module{functions=R#asm_module.functions++ - [{function,A0,B0,C0,R#asm_module.code}]} - end, - collect_asm(Rest, R1#asm_module{cfun={A,B,C}, code=[]}); +collect_asm([{function,A,B,C} | Rest0], R0) -> + {Code,Rest} = collect_asm_function(Rest0, []), + Func = {function,A,B,C,Code}, + R = R0#asm_module{functions=[Func | R0#asm_module.functions]}, + collect_asm(Rest, R); collect_asm([{attributes, Attr} | Rest], R) -> collect_asm(Rest, R#asm_module{attributes=Attr}); -collect_asm([X | Rest], R) -> - collect_asm(Rest, R#asm_module{code=R#asm_module.code++[X]}). +collect_asm([], R) -> R. + +collect_asm_function([{function,_,_,_}|_]=Is, Acc) -> + {reverse(Acc),Is}; +collect_asm_function([I|Is], Acc) -> + collect_asm_function(Is, [I|Acc]); +collect_asm_function([], Acc) -> + {reverse(Acc),[]}. beam_consult_asm(_Code, St) -> case file:consult(St#compile.ifile) of -- 2.16.4
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor