aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src/beam_disasm.erl
diff options
context:
space:
mode:
authorBjörn-Egil Dahlberg <[email protected]>2014-02-13 15:47:40 +0100
committerBjörn-Egil Dahlberg <[email protected]>2014-02-19 15:32:17 +0100
commitbf21750a8af22b1ad10eab41ea48a7ae6efec7f5 (patch)
treed8edbd15fac8889f4d9197c34ab1f7d395653a5a /lib/compiler/src/beam_disasm.erl
parent3e206565c2032a24b03ca13c313d1879d74dfec6 (diff)
downloadotp-bf21750a8af22b1ad10eab41ea48a7ae6efec7f5.tar.gz
otp-bf21750a8af22b1ad10eab41ea48a7ae6efec7f5.tar.bz2
otp-bf21750a8af22b1ad10eab41ea48a7ae6efec7f5.zip
compiler: Check literal order in beam_validator
Diffstat (limited to 'lib/compiler/src/beam_disasm.erl')
-rw-r--r--lib/compiler/src/beam_disasm.erl41
1 files changed, 23 insertions, 18 deletions
diff --git a/lib/compiler/src/beam_disasm.erl b/lib/compiler/src/beam_disasm.erl
index 3f5e9df5fd..363989f4c9 100644
--- a/lib/compiler/src/beam_disasm.erl
+++ b/lib/compiler/src/beam_disasm.erl
@@ -366,9 +366,13 @@ disasm_instr(B, Bs, Atoms, Literals) ->
select_tuple_arity ->
disasm_select_inst(select_tuple_arity, Bs, Atoms, Literals);
put_map_assoc ->
- disasm_map_inst(put_map_assoc, Bs, Atoms, Literals);
+ disasm_map_inst(put_map_assoc, Arity, Bs, Atoms, Literals);
put_map_exact ->
- disasm_map_inst(put_map_exact, Bs, Atoms, Literals);
+ disasm_map_inst(put_map_exact, Arity, Bs, Atoms, Literals);
+ get_map_elements ->
+ disasm_map_inst(get_map_elements, Arity, Bs, Atoms, Literals);
+ has_map_fields ->
+ disasm_map_inst(has_map_fields, Arity, Bs, Atoms, Literals);
_ ->
try decode_n_args(Arity, Bs, Atoms, Literals) of
{Args, RestBs} ->
@@ -399,16 +403,15 @@ disasm_select_inst(Inst, Bs, Atoms, Literals) ->
{List, RestBs} = decode_n_args(Len, Bs4, Atoms, Literals),
{{Inst, [X,F,{Z,U,List}]}, RestBs}.
-disasm_map_inst(Inst, Bs0, Atoms, Literals) ->
- {F, Bs1} = decode_arg(Bs0, Atoms, Literals),
- {S, Bs2} = decode_arg(Bs1, Atoms, Literals),
- {X, Bs3} = decode_arg(Bs2, Atoms, Literals),
- {N, Bs4} = decode_arg(Bs3, Atoms, Literals),
- {Z, Bs5} = decode_arg(Bs4, Atoms, Literals),
- {U, Bs6} = decode_arg(Bs5, Atoms, Literals),
- {u, Len} = U,
- {List, RestBs} = decode_n_args(Len, Bs6, Atoms, Literals),
- {{Inst, [F,S,X,N,{Z,U,List}]}, RestBs}.
+disasm_map_inst(Inst, Arity, Bs0, Atoms, Literals) ->
+ {Args0,Bs1} = decode_n_args(Arity, Bs0, Atoms, Literals),
+ %% no droplast ..
+ [Z|Args1] = lists:reverse(Args0),
+ Args = lists:reverse(Args1),
+ {U, Bs2} = decode_arg(Bs1, Atoms, Literals),
+ {u, Len} = U,
+ {List, RestBs} = decode_n_args(Len, Bs2, Atoms, Literals),
+ {{Inst, Args ++ [{Z,U,List}]}, RestBs}.
%%-----------------------------------------------------------------------
%% decode_arg([Byte]) -> {Arg, [Byte]}
@@ -1150,13 +1153,15 @@ resolve_inst({is_map,Args0},_,_,_) ->
[FLbl|Args] = resolve_args(Args0),
{test, is_map, FLbl, Args};
-resolve_inst({has_map_field,Args0},_,_,_) ->
- [FLbl,Src,{u,_Len}|Args] = resolve_args(Args0),
- {test,has_map_field,FLbl,Src,{list,Args}};
+resolve_inst({has_map_fields,Args0},_,_,_) ->
+ [FLbl,Src,{{z,1},{u,_Len},List0}] = Args0,
+ List = resolve_args(List0),
+ {test,has_map_fields,FLbl,Src,{list,List}};
-resolve_inst({get_map_element,Args0},_,_,_) ->
- [FLbl,Src,{u,_Len}|Args] = resolve_args(Args0),
- {get_map_element,FLbl,Src,{list,Args}};
+resolve_inst({get_map_elements,Args0},_,_,_) ->
+ [FLbl,Src,{{z,1},{u,_Len},List0}] = Args0,
+ List = resolve_args(List0),
+ {get_map_elements,FLbl,Src,{list,List}};
%%
%% Catches instructions that are not yet handled.