From 454d7da75779892f8fe1fde81b05bfffaab53a3a Mon Sep 17 00:00:00 2001 From: mzp Date: Sun, 13 Sep 2009 20:25:08 +0900 Subject: [PATCH] bugfix: label --- swflib/gen_inst.ml | 20 ++++++++++++++++---- swflib/instruction.txt | 4 ++-- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/swflib/gen_inst.ml b/swflib/gen_inst.ml index 677c76b..5949b45 100644 --- a/swflib/gen_inst.ml +++ b/swflib/gen_inst.ml @@ -105,6 +105,12 @@ let make_pat name args = let call_args prefix args = concat_mapi ";" (sprintf "%s_%s _%d" prefix) args +let assoc x xs = + try + Some (List.assoc x xs) + with Not_found -> + None + let cmds = [ begin "-type",fun {name; args}-> if args = [] then @@ -113,13 +119,19 @@ let cmds = [ sprintf "| `%s of %s" name @@ String.concat "*" args end; - begin "-asm",fun {name; opcode; args} -> + begin "-asm",fun {name; opcode; args;extra} -> let pat = make_pat name args in let record = - sprintf "[u8 0x%x; %s]" - opcode - (call_args "write" args) in + match assoc "prefix" extra with + Some "true" -> + sprintf "[%s; u8 0x%x]" + (call_args "write" args) + opcode + | Some _ | None -> + sprintf "[u8 0x%x; %s]" + opcode + (call_args "write" args) in sprintf "| %s -> %s" pat record end; diff --git a/swflib/instruction.txt b/swflib/instruction.txt index 48ef92c..cd9344f 100644 --- a/swflib/instruction.txt +++ b/swflib/instruction.txt @@ -31,7 +31,7 @@ GreaterThan(0xaf) -> stack= ~-1 GreaterEquals(0xb0) -> stack= ~-1 # Jump/Conditonal Jump -Label of label_def(0x09) +Label of label_def(0x09) -> prefix=true IfNlt of label(0x0c) -> stack= ~-1 IfNle of label(0x0d) -> stack= ~-1 IfNgt of label(0x0e) -> stack= ~-1 @@ -56,7 +56,7 @@ PushShort of u30(0x25) -> stack=1 PushTrue(0x26) -> stack=1 PushFalse(0x27) -> stack=1 PushNaN(0x28) -> stack=1 -PushString of c_string(0x2C) -> stack=1 +PushString of c_string(0x2C) -> stack=10 PushInt of c_int(0x2D) -> stack=1 PushUInt of c_uint(0x2E) -> stack=1 PushDouble of c_float(0x2F) -> stack=1 -- 2.11.0