From: mzp Date: Thu, 10 Sep 2009 13:22:32 +0000 (+0900) Subject: add lowInst test X-Git-Url: http://git.sourceforge.jp/view?a=commitdiff_plain;h=4e26e4c1bc7a9ad21d1dc5638e1063bc1ef39881;p=happyabc%2Fhappyabc.git add lowInst test --- diff --git a/swflib/.gitignore b/swflib/.gitignore index e5574f7..9f7b560 100644 --- a/swflib/.gitignore +++ b/swflib/.gitignore @@ -1 +1,5 @@ -gen_inst \ No newline at end of file +gen_inst +gen_typemap +lowInst.ml +highInst.ml +*.h \ No newline at end of file diff --git a/swflib/OMakefile b/swflib/OMakefile index b75e1a6..191147b 100644 --- a/swflib/OMakefile +++ b/swflib/OMakefile @@ -8,11 +8,12 @@ OCAMLPACKS[] = FILES[] = bytes label - instruction + lowInst abcType asm abc + UseCamlp4(pa_openin pa_oo) PROGRAM=../swflib @@ -26,26 +27,32 @@ OCamlProgram(gen_inst,gen_inst) OCamlProgram(gen_typemap,gen_typemap) # test +OUnitTest(label , label) OUnitTest(bytes , bytes label) -OUnitTest(abc , bytes abc label) -OUnitTest(revList , revList) -OUnitTest(cpool , cpool revList) -OUnitTest(asm , bytes asm cpool revList) +OUnitTest(lowInst , lowInst bytes) + +#OUnitTest(revList , revList) +#OUnitTest(cpool , cpool revList) +#OUnitTest(asm , bytes asm cpool revList) # phony .PHONY: clean .DEFAULT: $(MyOCamlPackage $(PROGRAM), $(FILES)) + write.h: gen_inst$(EXE) instruction.txt ./gen_inst$(EXE) -writer < instruction.txt > $@ type.h: gen_inst$(EXE) instruction.txt ./gen_inst$(EXE) -type < instruction.txt > $@ -write_type.h: gen_typemap$(EXE) - ./gen_typemap$(EXE) -writer > $@ +low_type.h: gen_typemap$(EXE) + ./gen_typemap$(EXE) -low > $@ + +high_type.h: gen_typemap$(EXE) + ./gen_typemap$(EXE) -high > $@ -.SCANNER: instruction.ml : instruction.mlp +.SCANNER: %.ml : %.mlp grep "#include \"" $< | sed 's/.*"\(.*\)".*/'$@': \1/' clean: - ocaml-clean opcode.h match_body.h instruction.ml gen_inst$(EXE) gen_typemap$(EXE) + ocaml-clean *.h lowInst.ml gen_inst$(EXE) gen_typemap$(EXE) diff --git a/swflib/abc.ml b/swflib/abc.ml index cea45ae..8b099d6 100644 --- a/swflib/abc.ml +++ b/swflib/abc.ml @@ -3,7 +3,7 @@ open Base include AbcType type 'a s = 'a t -module A = Asm.Make(Instruction) +module A = Asm.Make(LowInst) let write ch insts = insts diff --git a/swflib/gen_typemap b/swflib/gen_typemap deleted file mode 120000 index 36fe935..0000000 --- a/swflib/gen_typemap +++ /dev/null @@ -1 +0,0 @@ -gen_typemap.opt \ No newline at end of file diff --git a/swflib/gen_typemap.ml b/swflib/gen_typemap.ml index a1a5127..f9cb08d 100644 --- a/swflib/gen_typemap.ml +++ b/swflib/gen_typemap.ml @@ -12,7 +12,7 @@ let u30 name = let _ = match Sys.argv.(1) with - "-writer" -> + "-low" -> u30 "method_"; u30 "class_"; u30 "c_int"; @@ -28,5 +28,7 @@ let _ = ~byte:"function Left label -> label_ref label | Right address -> s24 address" + | "-high" -> + () | _ -> exit 1 diff --git a/swflib/inst.mlp b/swflib/highInst.mlp similarity index 62% rename from swflib/inst.mlp rename to swflib/highInst.mlp index f7f7a59..15a36c2 100644 --- a/swflib/inst.mlp +++ b/swflib/highInst.mlp @@ -1,5 +1,8 @@ open Base +#include "high_type.h" + type t = [ #include "type.h" ] + diff --git a/swflib/inst.ml b/swflib/inst.ml deleted file mode 100644 index 6f0cd7f..0000000 --- a/swflib/inst.ml +++ /dev/null @@ -1,101 +0,0 @@ -(* CAUTION: this is a generated file. If you edit it, all changes will be lost! *) -# 1 "inst.mlp" -# 1 "" -# 1 "" -# 1 "inst.mlp" -open Base - -type t = [ - -# 1 "type.h" 1 -| `NewFunction of method_ -| `NewClass of class_ -| `Coerce -| `Coerce_a -| `Coerce_s -| `Convert_i -| `Convert_s -| `Convert_d -| `Convert_b -| `Convert_u -| `Add_i -| `Subtract_i -| `Multiply_i -| `Add -| `Subtract -| `Multiply -| `Divide -| `Modulo -| `Equals -| `StrictEquals -| `LessThan -| `LessEquals -| `GreaterThan -| `GreaterEquals -| `Label of label -| `IfNlt of label -| `IfNle of label -| `IfNgt of label -| `IfNge of label -| `Jump of label -| `IfTrue of label -| `IfFalse of label -| `IfEq of label -| `IfNe of label -| `IfLt of label -| `IfLe of label -| `IfGt of label -| `IfGe of label -| `IfStrictEq of label -| `IfStrictNe of label -| `PushNull -| `PushUndefined -| `PushByte of u8 -| `PushShort of u30 -| `PushTrue -| `PushFalse -| `PushNaN -| `PushString of string -| `PushInt of int -| `PushUInt of uint -| `PushDouble of float -| `PushNamespace of namespace -| `PushScope -| `PushWith -| `GetGlobalScope -| `GetScopeObject of u8 -| `GetLocal_0 -| `GetLocal_1 -| `GetLocal_2 -| `GetLocal_3 -| `GetLocal of u30 -| `SetLocal_0 -| `SetLocal_1 -| `SetLocal_2 -| `SetLocal_3 -| `SetLocal of u30 -| `GetSlot of u30 -| `SetSlot of u30 -| `GetGlobalSlot of u30 -| `SetGlobalSlot of u30 -| `GetLex of multiname -| `GetProperty of multiname -| `SetProperty of multiname -| `InitProperty of multiname -| `ReturnVoid -| `ReturnValue -| `FindPropStrict of multiname -| `CallProperty of multiname*u30 -| `CallPropLex of multiname*u30 -| `Call of u30 -| `Pop -| `Swap -| `PopScope -| `NewObject of u30 -| `NewArray of u30 -| `NewActivation -| `Dup -| `ConstructSuper of u30 -| `ConstructProp of multiname*u30 -# 5 "inst.mlp" 2 -] diff --git a/swflib/instruction.ml b/swflib/instruction.ml deleted file mode 100644 index 79c50bb..0000000 --- a/swflib/instruction.ml +++ /dev/null @@ -1,224 +0,0 @@ -(* CAUTION: this is a generated file. If you edit it, all changes will be lost! *) -# 1 "instruction.mlp" -# 1 "" -# 1 "" -# 1 "instruction.mlp" -open Base -open Bytes - - -# 1 "write_type.h" 1 -type method_ = int -let write_method_= u30 -type class_ = int -let write_class_= u30 -type c_int = int -let write_c_int= u30 -type c_uint = int -let write_c_uint= u30 -type c_string = int -let write_c_string= u30 -type c_float = int -let write_c_float= u30 -type namespace = int -let write_namespace= u30 -type multiname = int -let write_multiname= u30 -type u30 = int -let write_u30= u30 -type u8 = int -let write_u8= u8 -type label = (Label.t,int) either -let write_label= function - Left label -> label_ref label - | Right address -> s24 address -# 5 "instruction.mlp" 2 -type t = [ - -# 1 "type.h" 1 -| `NewFunction of method_ -| `NewClass of class_ -| `Coerce -| `Coerce_a -| `Coerce_s -| `Convert_i -| `Convert_s -| `Convert_d -| `Convert_b -| `Convert_u -| `Add_i -| `Subtract_i -| `Multiply_i -| `Add -| `Subtract -| `Multiply -| `Divide -| `Modulo -| `Equals -| `StrictEquals -| `LessThan -| `LessEquals -| `GreaterThan -| `GreaterEquals -| `Label of label -| `IfNlt of label -| `IfNle of label -| `IfNgt of label -| `IfNge of label -| `Jump of label -| `IfTrue of label -| `IfFalse of label -| `IfEq of label -| `IfNe of label -| `IfLt of label -| `IfLe of label -| `IfGt of label -| `IfGe of label -| `IfStrictEq of label -| `IfStrictNe of label -| `PushNull -| `PushUndefined -| `PushByte of u8 -| `PushShort of u30 -| `PushTrue -| `PushFalse -| `PushNaN -| `PushString of c_string -| `PushInt of c_int -| `PushUInt of c_uint -| `PushDouble of c_float -| `PushNamespace of namespace -| `PushScope -| `PushWith -| `GetGlobalScope -| `GetScopeObject of u8 -| `GetLocal_0 -| `GetLocal_1 -| `GetLocal_2 -| `GetLocal_3 -| `GetLocal of u30 -| `SetLocal_0 -| `SetLocal_1 -| `SetLocal_2 -| `SetLocal_3 -| `SetLocal of u30 -| `GetSlot of u30 -| `SetSlot of u30 -| `GetGlobalSlot of u30 -| `SetGlobalSlot of u30 -| `GetLex of multiname -| `GetProperty of multiname -| `SetProperty of multiname -| `InitProperty of multiname -| `ReturnVoid -| `ReturnValue -| `FindPropStrict of multiname -| `CallProperty of multiname*u30 -| `CallPropLex of multiname*u30 -| `Call of u30 -| `Pop -| `Swap -| `PopScope -| `NewObject of u30 -| `NewArray of u30 -| `NewActivation -| `Dup -| `ConstructSuper of u30 -| `ConstructProp of multiname*u30 -# 7 "instruction.mlp" 2 -] - -let to_bytes = - function - -# 1 "write.h" 1 -| `NewFunction (arg0) -> [u8 0x40; write_method_ arg0] -| `NewClass (arg0) -> [u8 0x58; write_class_ arg0] -| `Coerce -> [u8 0x80; ] -| `Coerce_a -> [u8 0x82; ] -| `Coerce_s -> [u8 0x85; ] -| `Convert_i -> [u8 0x73; ] -| `Convert_s -> [u8 0x74; ] -| `Convert_d -> [u8 0x75; ] -| `Convert_b -> [u8 0x76; ] -| `Convert_u -> [u8 0x77; ] -| `Add_i -> [u8 0xc5; ] -| `Subtract_i -> [u8 0xc6; ] -| `Multiply_i -> [u8 0xc7; ] -| `Add -> [u8 0xa0; ] -| `Subtract -> [u8 0xa1; ] -| `Multiply -> [u8 0xa2; ] -| `Divide -> [u8 0xa3; ] -| `Modulo -> [u8 0xa4; ] -| `Equals -> [u8 0xab; ] -| `StrictEquals -> [u8 0xac; ] -| `LessThan -> [u8 0xad; ] -| `LessEquals -> [u8 0xae; ] -| `GreaterThan -> [u8 0xaf; ] -| `GreaterEquals -> [u8 0xb0; ] -| `Label (arg0) -> [u8 0x9; write_label arg0] -| `IfNlt (arg0) -> [u8 0xc; write_label arg0] -| `IfNle (arg0) -> [u8 0xd; write_label arg0] -| `IfNgt (arg0) -> [u8 0xe; write_label arg0] -| `IfNge (arg0) -> [u8 0xf; write_label arg0] -| `Jump (arg0) -> [u8 0x10; write_label arg0] -| `IfTrue (arg0) -> [u8 0x11; write_label arg0] -| `IfFalse (arg0) -> [u8 0x12; write_label arg0] -| `IfEq (arg0) -> [u8 0x13; write_label arg0] -| `IfNe (arg0) -> [u8 0x14; write_label arg0] -| `IfLt (arg0) -> [u8 0x15; write_label arg0] -| `IfLe (arg0) -> [u8 0x16; write_label arg0] -| `IfGt (arg0) -> [u8 0x17; write_label arg0] -| `IfGe (arg0) -> [u8 0x18; write_label arg0] -| `IfStrictEq (arg0) -> [u8 0x19; write_label arg0] -| `IfStrictNe (arg0) -> [u8 0x1a; write_label arg0] -| `PushNull -> [u8 0x20; ] -| `PushUndefined -> [u8 0x21; ] -| `PushByte (arg0) -> [u8 0x24; write_u8 arg0] -| `PushShort (arg0) -> [u8 0x25; write_u30 arg0] -| `PushTrue -> [u8 0x26; ] -| `PushFalse -> [u8 0x27; ] -| `PushNaN -> [u8 0x28; ] -| `PushString (arg0) -> [u8 0x2c; write_c_string arg0] -| `PushInt (arg0) -> [u8 0x2d; write_c_int arg0] -| `PushUInt (arg0) -> [u8 0x2e; write_c_uint arg0] -| `PushDouble (arg0) -> [u8 0x2f; write_c_float arg0] -| `PushNamespace (arg0) -> [u8 0x31; write_namespace arg0] -| `PushScope -> [u8 0x30; ] -| `PushWith -> [u8 0x1c; ] -| `GetGlobalScope -> [u8 0x64; ] -| `GetScopeObject (arg0) -> [u8 0x65; write_u8 arg0] -| `GetLocal_0 -> [u8 0xd0; ] -| `GetLocal_1 -> [u8 0xd1; ] -| `GetLocal_2 -> [u8 0xd2; ] -| `GetLocal_3 -> [u8 0xd3; ] -| `GetLocal (arg0) -> [u8 0x62; write_u30 arg0] -| `SetLocal_0 -> [u8 0xd4; ] -| `SetLocal_1 -> [u8 0xd5; ] -| `SetLocal_2 -> [u8 0xd6; ] -| `SetLocal_3 -> [u8 0xd7; ] -| `SetLocal (arg0) -> [u8 0x63; write_u30 arg0] -| `GetSlot (arg0) -> [u8 0x6c; write_u30 arg0] -| `SetSlot (arg0) -> [u8 0x6d; write_u30 arg0] -| `GetGlobalSlot (arg0) -> [u8 0x6e; write_u30 arg0] -| `SetGlobalSlot (arg0) -> [u8 0x6f; write_u30 arg0] -| `GetLex (arg0) -> [u8 0x60; write_multiname arg0] -| `GetProperty (arg0) -> [u8 0x66; write_multiname arg0] -| `SetProperty (arg0) -> [u8 0x61; write_multiname arg0] -| `InitProperty (arg0) -> [u8 0x68; write_multiname arg0] -| `ReturnVoid -> [u8 0x47; ] -| `ReturnValue -> [u8 0x48; ] -| `FindPropStrict (arg0) -> [u8 0x5d; write_multiname arg0] -| `CallProperty (arg0,arg1) -> [u8 0x46; write_multiname arg0;write_u30 arg1] -| `CallPropLex (arg0,arg1) -> [u8 0x4c; write_multiname arg0;write_u30 arg1] -| `Call (arg0) -> [u8 0x41; write_u30 arg0] -| `Pop -> [u8 0x29; ] -| `Swap -> [u8 0x2b; ] -| `PopScope -> [u8 0x1d; ] -| `NewObject (arg0) -> [u8 0x55; write_u30 arg0] -| `NewArray (arg0) -> [u8 0x56; write_u30 arg0] -| `NewActivation -> [u8 0x57; ] -| `Dup -> [u8 0x2a; ] -| `ConstructSuper (arg0) -> [u8 0x49; write_u30 arg0] -| `ConstructProp (arg0,arg1) -> [u8 0x4a; write_multiname arg0;write_u30 arg1] -# 12 "instruction.mlp" 2 diff --git a/swflib/instruction.txt b/swflib/instruction.txt index ade7a7b..2bcfa85 100644 --- a/swflib/instruction.txt +++ b/swflib/instruction.txt @@ -106,6 +106,7 @@ NewObject of u30(0x55) -> stack=1-arg0 NewArray of u30(0x56) NewActivation(0x57) -> stack=1 Dup(0x2a) -> stack= 2 +Nop(0x02) # Class ConstructSuper of u30(0x49) -> stack= ~-(arg0+1) diff --git a/swflib/labelTest.ml b/swflib/labelTest.ml new file mode 100644 index 0000000..f157d40 --- /dev/null +++ b/swflib/labelTest.ml @@ -0,0 +1,21 @@ +open Base +open OUnit +open Label + +let _ = + ("label.ml" >::: [ + "unique" >:: + (fun () -> + let a = + Label.make () in + let b = + Label.make() in + assert_equal false (a=b)); + "peek" >:: + (fun () -> + let a = + Label.peek 0 in + let b = + Label.make() in + assert_equal true (a=b)); + ]) +> run_test_tt_main diff --git a/swflib/instruction.mlp b/swflib/lowInst.mlp similarity index 59% rename from swflib/instruction.mlp rename to swflib/lowInst.mlp index 014c67c..a817bfa 100644 --- a/swflib/instruction.mlp +++ b/swflib/lowInst.mlp @@ -1,11 +1,12 @@ open Base open Bytes -#include "write_type.h" +#include "low_type.h" type t = [ #include "type.h" ] -let to_bytes = +let to_bytes : t -> Bytes.t list = function #include "write.h" + diff --git a/swflib/lowInstTest.ml b/swflib/lowInstTest.ml new file mode 100644 index 0000000..fc3239f --- /dev/null +++ b/swflib/lowInstTest.ml @@ -0,0 +1,18 @@ +open Base +open OUnit +open LowInst +open Bytes + +let ok x y = + assert_equal x (to_bytes y) + +let _ = + ("lowInst.ml" >::: [ + "nop" >:: + (fun () -> + ok [u8 0x02] `Nop); + "PushInt" >:: + (fun () -> + ok [u8 0x2d; u30 42] (`PushInt 42)) + + ]) +> run_test_tt_main diff --git a/swflib/match_body.h b/swflib/match_body.h deleted file mode 100644 index c496068..0000000 --- a/swflib/match_body.h +++ /dev/null @@ -1,89 +0,0 @@ -| `NewFunction (arg0) -> { {default with op=0x40; args=(fun _ctx -> [p_method_ _ctx arg0]); const=filter_map id [c_method_ arg0]} with stack=1; method_=Some arg0} -| `NewClass (arg0) -> {default with op=0x58; args=(fun _ctx -> [p_class_ _ctx arg0]); const=filter_map id [c_class_ arg0]} -| `Coerce -> {default with op=0x80; args=(fun _ctx -> []); const=filter_map id []} -| `Coerce_a -> {default with op=0x82; args=(fun _ctx -> []); const=filter_map id []} -| `Coerce_s -> {default with op=0x85; args=(fun _ctx -> []); const=filter_map id []} -| `Convert_i -> {default with op=0x73; args=(fun _ctx -> []); const=filter_map id []} -| `Convert_s -> {default with op=0x74; args=(fun _ctx -> []); const=filter_map id []} -| `Convert_d -> {default with op=0x75; args=(fun _ctx -> []); const=filter_map id []} -| `Convert_b -> {default with op=0x76; args=(fun _ctx -> []); const=filter_map id []} -| `Convert_u -> {default with op=0x77; args=(fun _ctx -> []); const=filter_map id []} -| `Add_i -> { {default with op=0xc5; args=(fun _ctx -> []); const=filter_map id []} with stack= ~-1} -| `Subtract_i -> { {default with op=0xc6; args=(fun _ctx -> []); const=filter_map id []} with stack= ~-1} -| `Multiply_i -> { {default with op=0xc7; args=(fun _ctx -> []); const=filter_map id []} with stack= ~-1} -| `Add -> { {default with op=0xa0; args=(fun _ctx -> []); const=filter_map id []} with stack= ~-1} -| `Subtract -> { {default with op=0xa1; args=(fun _ctx -> []); const=filter_map id []} with stack= ~-1} -| `Multiply -> { {default with op=0xa2; args=(fun _ctx -> []); const=filter_map id []} with stack= ~-1} -| `Divide -> { {default with op=0xa3; args=(fun _ctx -> []); const=filter_map id []} with stack= ~-1} -| `Modulo -> { {default with op=0xa4; args=(fun _ctx -> []); const=filter_map id []} with stack= ~-1} -| `Equals -> { {default with op=0xab; args=(fun _ctx -> []); const=filter_map id []} with stack= ~-1} -| `StrictEquals -> { {default with op=0xac; args=(fun _ctx -> []); const=filter_map id []} with stack= ~-1} -| `LessThan -> { {default with op=0xad; args=(fun _ctx -> []); const=filter_map id []} with stack= ~-1} -| `LessEquals -> { {default with op=0xae; args=(fun _ctx -> []); const=filter_map id []} with stack= ~-1} -| `GreaterThan -> { {default with op=0xaf; args=(fun _ctx -> []); const=filter_map id []} with stack= ~-1} -| `GreaterEquals -> { {default with op=0xb0; args=(fun _ctx -> []); const=filter_map id []} with stack= ~-1} -| `Label (arg0) -> { {default with op=0x9; args=(fun _ctx -> [p_label _ctx arg0]); const=filter_map id [c_label arg0]} with prefix=const [label arg0];args=const []} -| `IfNlt (arg0) -> { {default with op=0xc; args=(fun _ctx -> [p_label _ctx arg0]); const=filter_map id [c_label arg0]} with stack= ~-1} -| `IfNle (arg0) -> { {default with op=0xd; args=(fun _ctx -> [p_label _ctx arg0]); const=filter_map id [c_label arg0]} with stack= ~-1} -| `IfNgt (arg0) -> { {default with op=0xe; args=(fun _ctx -> [p_label _ctx arg0]); const=filter_map id [c_label arg0]} with stack= ~-1} -| `IfNge (arg0) -> { {default with op=0xf; args=(fun _ctx -> [p_label _ctx arg0]); const=filter_map id [c_label arg0]} with stack= ~-1} -| `Jump (arg0) -> {default with op=0x10; args=(fun _ctx -> [p_label _ctx arg0]); const=filter_map id [c_label arg0]} -| `IfTrue (arg0) -> { {default with op=0x11; args=(fun _ctx -> [p_label _ctx arg0]); const=filter_map id [c_label arg0]} with stack= ~-1} -| `IfFalse (arg0) -> { {default with op=0x12; args=(fun _ctx -> [p_label _ctx arg0]); const=filter_map id [c_label arg0]} with stack= ~-1} -| `IfEq (arg0) -> { {default with op=0x13; args=(fun _ctx -> [p_label _ctx arg0]); const=filter_map id [c_label arg0]} with stack= ~-1} -| `IfNe (arg0) -> { {default with op=0x14; args=(fun _ctx -> [p_label _ctx arg0]); const=filter_map id [c_label arg0]} with stack= ~-1} -| `IfLt (arg0) -> { {default with op=0x15; args=(fun _ctx -> [p_label _ctx arg0]); const=filter_map id [c_label arg0]} with stack= ~-1} -| `IfLe (arg0) -> { {default with op=0x16; args=(fun _ctx -> [p_label _ctx arg0]); const=filter_map id [c_label arg0]} with stack= ~-1} -| `IfGt (arg0) -> { {default with op=0x17; args=(fun _ctx -> [p_label _ctx arg0]); const=filter_map id [c_label arg0]} with stack= ~-1} -| `IfGe (arg0) -> { {default with op=0x18; args=(fun _ctx -> [p_label _ctx arg0]); const=filter_map id [c_label arg0]} with stack= ~-1} -| `IfStrictEq (arg0) -> { {default with op=0x19; args=(fun _ctx -> [p_label _ctx arg0]); const=filter_map id [c_label arg0]} with stack= ~-1} -| `IfStrictNe (arg0) -> { {default with op=0x1a; args=(fun _ctx -> [p_label _ctx arg0]); const=filter_map id [c_label arg0]} with stack= ~-1} -| `PushNull -> { {default with op=0x20; args=(fun _ctx -> []); const=filter_map id []} with stack=1} -| `PushUndefined -> { {default with op=0x21; args=(fun _ctx -> []); const=filter_map id []} with stack=1} -| `PushByte (arg0) -> { {default with op=0x24; args=(fun _ctx -> [p_u8 _ctx arg0]); const=filter_map id [c_u8 arg0]} with stack=1} -| `PushShort (arg0) -> { {default with op=0x25; args=(fun _ctx -> [p_u30 _ctx arg0]); const=filter_map id [c_u30 arg0]} with stack=1} -| `PushTrue -> { {default with op=0x26; args=(fun _ctx -> []); const=filter_map id []} with stack=1} -| `PushFalse -> { {default with op=0x27; args=(fun _ctx -> []); const=filter_map id []} with stack=1} -| `PushNaN -> { {default with op=0x28; args=(fun _ctx -> []); const=filter_map id []} with stack=1} -| `PushString (arg0) -> { {default with op=0x2c; args=(fun _ctx -> [p_string _ctx arg0]); const=filter_map id [c_string arg0]} with stack=1} -| `PushInt (arg0) -> { {default with op=0x2d; args=(fun _ctx -> [p_int _ctx arg0]); const=filter_map id [c_int arg0]} with stack=1} -| `PushUInt (arg0) -> { {default with op=0x2e; args=(fun _ctx -> [p_uint _ctx arg0]); const=filter_map id [c_uint arg0]} with stack=1} -| `PushDouble (arg0) -> { {default with op=0x2f; args=(fun _ctx -> [p_float _ctx arg0]); const=filter_map id [c_float arg0]} with stack=1} -| `PushNamespace (arg0) -> { {default with op=0x31; args=(fun _ctx -> [p_namespace _ctx arg0]); const=filter_map id [c_namespace arg0]} with stack=1} -| `PushScope -> { {default with op=0x30; args=(fun _ctx -> []); const=filter_map id []} with stack= ~-1; scope=1} -| `PushWith -> { {default with op=0x1c; args=(fun _ctx -> []); const=filter_map id []} with stack= ~-1; scope=1} -| `GetGlobalScope -> { {default with op=0x64; args=(fun _ctx -> []); const=filter_map id []} with stack=1} -| `GetScopeObject (arg0) -> { {default with op=0x65; args=(fun _ctx -> [p_u8 _ctx arg0]); const=filter_map id [c_u8 arg0]} with stack=1} -| `GetLocal_0 -> { {default with op=0xd0; args=(fun _ctx -> []); const=filter_map id []} with stack=1;count=1} -| `GetLocal_1 -> { {default with op=0xd1; args=(fun _ctx -> []); const=filter_map id []} with stack=1;count=2} -| `GetLocal_2 -> { {default with op=0xd2; args=(fun _ctx -> []); const=filter_map id []} with stack=1;count=3} -| `GetLocal_3 -> { {default with op=0xd3; args=(fun _ctx -> []); const=filter_map id []} with stack=1;count=4} -| `GetLocal (arg0) -> { {default with op=0x62; args=(fun _ctx -> [p_u30 _ctx arg0]); const=filter_map id [c_u30 arg0]} with stack=1;count=(arg0+1)} -| `SetLocal_0 -> { {default with op=0xd4; args=(fun _ctx -> []); const=filter_map id []} with stack=1} -| `SetLocal_1 -> { {default with op=0xd5; args=(fun _ctx -> []); const=filter_map id []} with stack=1} -| `SetLocal_2 -> { {default with op=0xd6; args=(fun _ctx -> []); const=filter_map id []} with stack=1} -| `SetLocal_3 -> { {default with op=0xd7; args=(fun _ctx -> []); const=filter_map id []} with stack=1} -| `SetLocal (arg0) -> { {default with op=0x63; args=(fun _ctx -> [p_u30 _ctx arg0]); const=filter_map id [c_u30 arg0]} with stack=1} -| `GetSlot (arg0) -> {default with op=0x6c; args=(fun _ctx -> [p_u30 _ctx arg0]); const=filter_map id [c_u30 arg0]} -| `SetSlot (arg0) -> { {default with op=0x6d; args=(fun _ctx -> [p_u30 _ctx arg0]); const=filter_map id [c_u30 arg0]} with stack= ~-2} -| `GetGlobalSlot (arg0) -> { {default with op=0x6e; args=(fun _ctx -> [p_u30 _ctx arg0]); const=filter_map id [c_u30 arg0]} with stack=1} -| `SetGlobalSlot (arg0) -> { {default with op=0x6f; args=(fun _ctx -> [p_u30 _ctx arg0]); const=filter_map id [c_u30 arg0]} with stack= ~-1} -| `GetLex (arg0) -> { {default with op=0x60; args=(fun _ctx -> [p_multiname _ctx arg0]); const=filter_map id [c_multiname arg0]} with stack=1} -| `GetProperty (arg0) -> {default with op=0x66; args=(fun _ctx -> [p_multiname _ctx arg0]); const=filter_map id [c_multiname arg0]} -| `SetProperty (arg0) -> { {default with op=0x61; args=(fun _ctx -> [p_multiname _ctx arg0]); const=filter_map id [c_multiname arg0]} with stack= ~-2} -| `InitProperty (arg0) -> { {default with op=0x68; args=(fun _ctx -> [p_multiname _ctx arg0]); const=filter_map id [c_multiname arg0]} with stack= ~-2} -| `ReturnVoid -> {default with op=0x47; args=(fun _ctx -> []); const=filter_map id []} -| `ReturnValue -> { {default with op=0x48; args=(fun _ctx -> []); const=filter_map id []} with stack= ~-1} -| `FindPropStrict (arg0) -> { {default with op=0x5d; args=(fun _ctx -> [p_multiname _ctx arg0]); const=filter_map id [c_multiname arg0]} with stack=1} -| `CallProperty (arg0,arg1) -> { {default with op=0x46; args=(fun _ctx -> [p_multiname _ctx arg0;p_u30 _ctx arg1]); const=filter_map id [c_multiname arg0;c_u30 arg1]} with stack= 1-arg1} -| `CallPropLex (arg0,arg1) -> { {default with op=0x4c; args=(fun _ctx -> [p_multiname _ctx arg0;p_u30 _ctx arg1]); const=filter_map id [c_multiname arg0;c_u30 arg1]} with stack= 1-arg1} -| `Call (arg0) -> { {default with op=0x41; args=(fun _ctx -> [p_u30 _ctx arg0]); const=filter_map id [c_u30 arg0]} with stack= 1-(2+arg0)} -| `Pop -> { {default with op=0x29; args=(fun _ctx -> []); const=filter_map id []} with stack= ~-1} -| `Swap -> {default with op=0x2b; args=(fun _ctx -> []); const=filter_map id []} -| `PopScope -> { {default with op=0x1d; args=(fun _ctx -> []); const=filter_map id []} with scope= ~-1} -| `NewObject (arg0) -> { {default with op=0x55; args=(fun _ctx -> [p_u30 _ctx arg0]); const=filter_map id [c_u30 arg0]} with stack=1-arg0} -| `NewArray (arg0) -> {default with op=0x56; args=(fun _ctx -> [p_u30 _ctx arg0]); const=filter_map id [c_u30 arg0]} -| `NewActivation -> { {default with op=0x57; args=(fun _ctx -> []); const=filter_map id []} with stack=1} -| `Dup -> { {default with op=0x2a; args=(fun _ctx -> []); const=filter_map id []} with stack= 2} -| `ConstructSuper (arg0) -> { {default with op=0x49; args=(fun _ctx -> [p_u30 _ctx arg0]); const=filter_map id [c_u30 arg0]} with stack= ~-(arg0+1)} -| `ConstructProp (arg0,arg1) -> { {default with op=0x4a; args=(fun _ctx -> [p_multiname _ctx arg0;p_u30 _ctx arg1]); const=filter_map id [c_multiname arg0;c_u30 arg1]} with stack= ~-arg1} diff --git a/swflib/opcode.h b/swflib/opcode.h deleted file mode 100644 index 2ea5609..0000000 --- a/swflib/opcode.h +++ /dev/null @@ -1,89 +0,0 @@ -| `NewFunction of method_ -| `NewClass of class_ -| `Coerce -| `Coerce_a -| `Coerce_s -| `Convert_i -| `Convert_s -| `Convert_d -| `Convert_b -| `Convert_u -| `Add_i -| `Subtract_i -| `Multiply_i -| `Add -| `Subtract -| `Multiply -| `Divide -| `Modulo -| `Equals -| `StrictEquals -| `LessThan -| `LessEquals -| `GreaterThan -| `GreaterEquals -| `Label of label -| `IfNlt of label -| `IfNle of label -| `IfNgt of label -| `IfNge of label -| `Jump of label -| `IfTrue of label -| `IfFalse of label -| `IfEq of label -| `IfNe of label -| `IfLt of label -| `IfLe of label -| `IfGt of label -| `IfGe of label -| `IfStrictEq of label -| `IfStrictNe of label -| `PushNull -| `PushUndefined -| `PushByte of u8 -| `PushShort of u30 -| `PushTrue -| `PushFalse -| `PushNaN -| `PushString of string -| `PushInt of int -| `PushUInt of uint -| `PushDouble of float -| `PushNamespace of namespace -| `PushScope -| `PushWith -| `GetGlobalScope -| `GetScopeObject of u8 -| `GetLocal_0 -| `GetLocal_1 -| `GetLocal_2 -| `GetLocal_3 -| `GetLocal of u30 -| `SetLocal_0 -| `SetLocal_1 -| `SetLocal_2 -| `SetLocal_3 -| `SetLocal of u30 -| `GetSlot of u30 -| `SetSlot of u30 -| `GetGlobalSlot of u30 -| `SetGlobalSlot of u30 -| `GetLex of multiname -| `GetProperty of multiname -| `SetProperty of multiname -| `InitProperty of multiname -| `ReturnVoid -| `ReturnValue -| `FindPropStrict of multiname -| `CallProperty of multiname*u30 -| `CallPropLex of multiname*u30 -| `Call of u30 -| `Pop -| `Swap -| `PopScope -| `NewObject of u30 -| `NewArray of u30 -| `NewActivation -| `Dup -| `ConstructSuper of u30 -| `ConstructProp of multiname*u30 diff --git a/swflib/type.h b/swflib/type.h deleted file mode 100644 index db9469f..0000000 --- a/swflib/type.h +++ /dev/null @@ -1,89 +0,0 @@ -| `NewFunction of method_ -| `NewClass of class_ -| `Coerce -| `Coerce_a -| `Coerce_s -| `Convert_i -| `Convert_s -| `Convert_d -| `Convert_b -| `Convert_u -| `Add_i -| `Subtract_i -| `Multiply_i -| `Add -| `Subtract -| `Multiply -| `Divide -| `Modulo -| `Equals -| `StrictEquals -| `LessThan -| `LessEquals -| `GreaterThan -| `GreaterEquals -| `Label of label -| `IfNlt of label -| `IfNle of label -| `IfNgt of label -| `IfNge of label -| `Jump of label -| `IfTrue of label -| `IfFalse of label -| `IfEq of label -| `IfNe of label -| `IfLt of label -| `IfLe of label -| `IfGt of label -| `IfGe of label -| `IfStrictEq of label -| `IfStrictNe of label -| `PushNull -| `PushUndefined -| `PushByte of u8 -| `PushShort of u30 -| `PushTrue -| `PushFalse -| `PushNaN -| `PushString of c_string -| `PushInt of c_int -| `PushUInt of c_uint -| `PushDouble of c_float -| `PushNamespace of namespace -| `PushScope -| `PushWith -| `GetGlobalScope -| `GetScopeObject of u8 -| `GetLocal_0 -| `GetLocal_1 -| `GetLocal_2 -| `GetLocal_3 -| `GetLocal of u30 -| `SetLocal_0 -| `SetLocal_1 -| `SetLocal_2 -| `SetLocal_3 -| `SetLocal of u30 -| `GetSlot of u30 -| `SetSlot of u30 -| `GetGlobalSlot of u30 -| `SetGlobalSlot of u30 -| `GetLex of multiname -| `GetProperty of multiname -| `SetProperty of multiname -| `InitProperty of multiname -| `ReturnVoid -| `ReturnValue -| `FindPropStrict of multiname -| `CallProperty of multiname*u30 -| `CallPropLex of multiname*u30 -| `Call of u30 -| `Pop -| `Swap -| `PopScope -| `NewObject of u30 -| `NewArray of u30 -| `NewActivation -| `Dup -| `ConstructSuper of u30 -| `ConstructProp of multiname*u30 diff --git a/swflib/typemap.h b/swflib/typemap.h deleted file mode 100644 index c91aeaf..0000000 --- a/swflib/typemap.h +++ /dev/null @@ -1,28 +0,0 @@ -type label = Label.t -let p_label _ctx _x = label_ref _x -let c_label _ = None -type u8 = int -let p_u8 _ctx _x = u8 _x -let c_u8 _ = None -type u30 = int -let p_u30 _ctx _x = u30 _x -let c_u30 _ = None -let p_method_ _ctx _x = u30 @@ RevList.index _x _ctx#methods -let c_method_ _ = None -let p_class_ _ctx _x = u30 @@ RevList.index _x _ctx#classes -let c_class_ _ = None -type uint = int -let p_uint _ctx _x = u30 @@ Cpool.index (`UInt _x) _ctx#cpool -let c_uint _x = Some(`UInt _x) -type namespace = Cpool.namespace -let p_namespace _ctx _x = u30 @@ Cpool.index (`Namespace _x) _ctx#cpool -let c_namespace _x = Some(`Namespace _x) -type multiname = Cpool.multiname -let p_multiname _ctx _x = u30 @@ Cpool.index (`Multiname _x) _ctx#cpool -let c_multiname _x = Some(`Multiname _x) -let p_string _ctx _x = u30 @@ Cpool.index (`String _x) _ctx#cpool -let c_string _x = Some(`String _x) -let p_int _ctx _x = u30 @@ Cpool.index (`Int _x) _ctx#cpool -let c_int _x = Some(`Int _x) -let p_float _ctx _x = u30 @@ Cpool.index (`Double _x) _ctx#cpool -let c_float _x = Some(`Double _x) diff --git a/swflib/write.h b/swflib/write.h deleted file mode 100644 index cd81ffb..0000000 --- a/swflib/write.h +++ /dev/null @@ -1,89 +0,0 @@ -| `NewFunction (arg0) -> [u8 0x40; write_method_ arg0] -| `NewClass (arg0) -> [u8 0x58; write_class_ arg0] -| `Coerce -> [u8 0x80; ] -| `Coerce_a -> [u8 0x82; ] -| `Coerce_s -> [u8 0x85; ] -| `Convert_i -> [u8 0x73; ] -| `Convert_s -> [u8 0x74; ] -| `Convert_d -> [u8 0x75; ] -| `Convert_b -> [u8 0x76; ] -| `Convert_u -> [u8 0x77; ] -| `Add_i -> [u8 0xc5; ] -| `Subtract_i -> [u8 0xc6; ] -| `Multiply_i -> [u8 0xc7; ] -| `Add -> [u8 0xa0; ] -| `Subtract -> [u8 0xa1; ] -| `Multiply -> [u8 0xa2; ] -| `Divide -> [u8 0xa3; ] -| `Modulo -> [u8 0xa4; ] -| `Equals -> [u8 0xab; ] -| `StrictEquals -> [u8 0xac; ] -| `LessThan -> [u8 0xad; ] -| `LessEquals -> [u8 0xae; ] -| `GreaterThan -> [u8 0xaf; ] -| `GreaterEquals -> [u8 0xb0; ] -| `Label (arg0) -> [u8 0x9; write_label arg0] -| `IfNlt (arg0) -> [u8 0xc; write_label arg0] -| `IfNle (arg0) -> [u8 0xd; write_label arg0] -| `IfNgt (arg0) -> [u8 0xe; write_label arg0] -| `IfNge (arg0) -> [u8 0xf; write_label arg0] -| `Jump (arg0) -> [u8 0x10; write_label arg0] -| `IfTrue (arg0) -> [u8 0x11; write_label arg0] -| `IfFalse (arg0) -> [u8 0x12; write_label arg0] -| `IfEq (arg0) -> [u8 0x13; write_label arg0] -| `IfNe (arg0) -> [u8 0x14; write_label arg0] -| `IfLt (arg0) -> [u8 0x15; write_label arg0] -| `IfLe (arg0) -> [u8 0x16; write_label arg0] -| `IfGt (arg0) -> [u8 0x17; write_label arg0] -| `IfGe (arg0) -> [u8 0x18; write_label arg0] -| `IfStrictEq (arg0) -> [u8 0x19; write_label arg0] -| `IfStrictNe (arg0) -> [u8 0x1a; write_label arg0] -| `PushNull -> [u8 0x20; ] -| `PushUndefined -> [u8 0x21; ] -| `PushByte (arg0) -> [u8 0x24; write_u8 arg0] -| `PushShort (arg0) -> [u8 0x25; write_u30 arg0] -| `PushTrue -> [u8 0x26; ] -| `PushFalse -> [u8 0x27; ] -| `PushNaN -> [u8 0x28; ] -| `PushString (arg0) -> [u8 0x2c; write_c_string arg0] -| `PushInt (arg0) -> [u8 0x2d; write_c_int arg0] -| `PushUInt (arg0) -> [u8 0x2e; write_c_uint arg0] -| `PushDouble (arg0) -> [u8 0x2f; write_c_float arg0] -| `PushNamespace (arg0) -> [u8 0x31; write_namespace arg0] -| `PushScope -> [u8 0x30; ] -| `PushWith -> [u8 0x1c; ] -| `GetGlobalScope -> [u8 0x64; ] -| `GetScopeObject (arg0) -> [u8 0x65; write_u8 arg0] -| `GetLocal_0 -> [u8 0xd0; ] -| `GetLocal_1 -> [u8 0xd1; ] -| `GetLocal_2 -> [u8 0xd2; ] -| `GetLocal_3 -> [u8 0xd3; ] -| `GetLocal (arg0) -> [u8 0x62; write_u30 arg0] -| `SetLocal_0 -> [u8 0xd4; ] -| `SetLocal_1 -> [u8 0xd5; ] -| `SetLocal_2 -> [u8 0xd6; ] -| `SetLocal_3 -> [u8 0xd7; ] -| `SetLocal (arg0) -> [u8 0x63; write_u30 arg0] -| `GetSlot (arg0) -> [u8 0x6c; write_u30 arg0] -| `SetSlot (arg0) -> [u8 0x6d; write_u30 arg0] -| `GetGlobalSlot (arg0) -> [u8 0x6e; write_u30 arg0] -| `SetGlobalSlot (arg0) -> [u8 0x6f; write_u30 arg0] -| `GetLex (arg0) -> [u8 0x60; write_multiname arg0] -| `GetProperty (arg0) -> [u8 0x66; write_multiname arg0] -| `SetProperty (arg0) -> [u8 0x61; write_multiname arg0] -| `InitProperty (arg0) -> [u8 0x68; write_multiname arg0] -| `ReturnVoid -> [u8 0x47; ] -| `ReturnValue -> [u8 0x48; ] -| `FindPropStrict (arg0) -> [u8 0x5d; write_multiname arg0] -| `CallProperty (arg0,arg1) -> [u8 0x46; write_multiname arg0;write_u30 arg1] -| `CallPropLex (arg0,arg1) -> [u8 0x4c; write_multiname arg0;write_u30 arg1] -| `Call (arg0) -> [u8 0x41; write_u30 arg0] -| `Pop -> [u8 0x29; ] -| `Swap -> [u8 0x2b; ] -| `PopScope -> [u8 0x1d; ] -| `NewObject (arg0) -> [u8 0x55; write_u30 arg0] -| `NewArray (arg0) -> [u8 0x56; write_u30 arg0] -| `NewActivation -> [u8 0x57; ] -| `Dup -> [u8 0x2a; ] -| `ConstructSuper (arg0) -> [u8 0x49; write_u30 arg0] -| `ConstructProp (arg0,arg1) -> [u8 0x4a; write_multiname arg0;write_u30 arg1] diff --git a/swflib/write_type.h b/swflib/write_type.h deleted file mode 100644 index ab91c34..0000000 --- a/swflib/write_type.h +++ /dev/null @@ -1,24 +0,0 @@ -type method_ = int -let write_method_= u30 -type class_ = int -let write_class_= u30 -type c_int = int -let write_c_int= u30 -type c_uint = int -let write_c_uint= u30 -type c_string = int -let write_c_string= u30 -type c_float = int -let write_c_float= u30 -type namespace = int -let write_namespace= u30 -type multiname = int -let write_multiname= u30 -type u30 = int -let write_u30= u30 -type u8 = int -let write_u8= u8 -type label = (Label.t,int) either -let write_label= function - Left label -> label_ref label - | Right address -> s24 address diff --git a/swflib/writer.h b/swflib/writer.h deleted file mode 100644 index ab91c34..0000000 --- a/swflib/writer.h +++ /dev/null @@ -1,24 +0,0 @@ -type method_ = int -let write_method_= u30 -type class_ = int -let write_class_= u30 -type c_int = int -let write_c_int= u30 -type c_uint = int -let write_c_uint= u30 -type c_string = int -let write_c_string= u30 -type c_float = int -let write_c_float= u30 -type namespace = int -let write_namespace= u30 -type multiname = int -let write_multiname= u30 -type u30 = int -let write_u30= u30 -type u8 = int -let write_u8= u8 -type label = (Label.t,int) either -let write_label= function - Left label -> label_ref label - | Right address -> s24 address