Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang
erlang
2516-compiler-Introduce-opaque-expressions-in-k...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 2516-compiler-Introduce-opaque-expressions-in-kernel-lang.patch of Package erlang
From a1810776be6f1d27b2ca03b1d274e1ae917fd485 Mon Sep 17 00:00:00 2001 From: Frej Drejhammar <frej.drejhammar@gmail.com> Date: Wed, 30 Nov 2022 13:28:35 +0100 Subject: [PATCH 06/13] compiler: Introduce opaque expressions in kernel language Introduce an opaque expression which is intended to pass a term unchanged through the passes which are applied to the kernel representation. --- lib/compiler/src/v3_kernel.erl | 9 +++++++-- lib/compiler/src/v3_kernel.hrl | 2 ++ lib/compiler/src/v3_kernel_pp.erl | 2 ++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/compiler/src/v3_kernel.erl b/lib/compiler/src/v3_kernel.erl index 1f23b07546..ae373a27ba 100644 --- a/lib/compiler/src/v3_kernel.erl +++ b/lib/compiler/src/v3_kernel.erl @@ -360,7 +360,9 @@ expr(#c_try{anno=A,arg=Ca,vars=Cvs,body=Cb,evars=Evs,handler=Ch}, Sub0, St0) -> evars=Kevs,handler=pre_seq(Ph, Kh)},[],St5}; expr(#c_catch{anno=A,body=Cb}, Sub, St0) -> {Kb,Pb,St1} = body(Cb, Sub, St0), - {#k_catch{anno=A,body=pre_seq(Pb, Kb)},[],St1}. + {#k_catch{anno=A,body=pre_seq(Pb, Kb)},[],St1}; +expr(#c_opaque{anno=A,val=V}, _, St) -> + {#k_opaque{anno=A,val=V},[],St}. %% Implement letrec in the traditional way as a local %% function for each definition in the letrec. @@ -2050,6 +2052,8 @@ uexpr(#k_letrec_goto{anno=A,vars=Vs,first=F0,then=T0}=MatchAlt, Br, St0) -> {T1,Tu,St2} = ubody(T0, Br, St1), Used = subtract(union(Fu, Tu), Ns), {MatchAlt#k_letrec_goto{anno=A,first=F1,then=T1,ret=Rs},Used,St2}; +uexpr(#k_opaque{}=O, _, St) -> + {O,[],St}; uexpr(Lit, {break,Rs0}, St0) -> %% Transform literals to puts here. %%ok = io:fwrite("uexpr ~w:~p~n", [?LINE,Lit]), @@ -2192,7 +2196,8 @@ lit_vars(#k_bin_seg{size=Size,seg=S,next=N}) -> union(lit_vars(Size), union(lit_vars(S), lit_vars(N))); lit_vars(#k_tuple{es=Es}) -> lit_list_vars(Es); -lit_vars(#k_literal{}) -> []. +lit_vars(#k_literal{}) -> []; +lit_vars(#k_opaque{}) -> []. lit_list_vars(Ps) -> foldl(fun (P, Vs) -> union(lit_vars(P), Vs) end, [], Ps). diff --git a/lib/compiler/src/v3_kernel.hrl b/lib/compiler/src/v3_kernel.hrl index 8d3e5dd7e7..58e275fa7a 100644 --- a/lib/compiler/src/v3_kernel.hrl +++ b/lib/compiler/src/v3_kernel.hrl @@ -70,5 +70,7 @@ -record(k_break, {anno=[],args=[]}). -record(k_return, {anno=[],args=[]}). +-record(k_opaque, {anno=[],val}). + %%k_get_anno(Thing) -> element(2, Thing). %%k_set_anno(Thing, Anno) -> setelement(2, Thing, Anno). diff --git a/lib/compiler/src/v3_kernel_pp.erl b/lib/compiler/src/v3_kernel_pp.erl index d1b075ce0f..d66bce8693 100644 --- a/lib/compiler/src/v3_kernel_pp.erl +++ b/lib/compiler/src/v3_kernel_pp.erl @@ -356,6 +356,8 @@ format_1(#ifun{vars=Vs,body=B}, Ctxt) -> nl_indent(Ctxt1) | format(B, Ctxt1) ]; +format_1(#k_opaque{val=V}, _Ctxt) -> + ["** Opaque: ", io_lib:write(V), " **\n"]; format_1(Type, _Ctxt) -> ["** Unsupported type: ", io_lib:write(Type) -- 2.35.3
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