From 1dafdaad964908fe3ae64933fb588e52bba61af3 Mon Sep 17 00:00:00 2001 From: mzp Date: Fri, 4 Sep 2009 17:48:37 +0900 Subject: [PATCH] merge src/ and test/ at scm/ --- scm/OMakefile | 31 ++++- scm/codegen/OMakefile | 56 ++++++++ scm/{src => }/codegen/abc.ml | 0 scm/{src => }/codegen/abc.mli | 0 scm/{test => }/codegen/abcTest.ml | 0 scm/{src => }/codegen/asm.ml | 0 scm/{src => }/codegen/asm.mli | 0 scm/{test => }/codegen/asmTest.ml | 0 scm/{test => }/codegen/astUtil.ml | 0 scm/{src => }/codegen/binding.ml | 0 scm/codegen/binding.mli | 46 ++++++ scm/{src => }/codegen/binding.mlip | 0 scm/{test => }/codegen/bindingTest.ml | 0 scm/{src => }/codegen/bytes.ml | 0 scm/{src => }/codegen/bytes.mli | 0 scm/{test => }/codegen/bytesTest.ml | 0 scm/{src => }/codegen/closureTrans.ml | 0 scm/{src => }/codegen/closureTrans.mli | 0 scm/{test => }/codegen/closureTransTest.ml | 0 scm/{src => }/codegen/codegen.ml | 0 scm/{src => }/codegen/codegen.mli | 0 scm/{test => }/codegen/codegenClassTest.ml | 0 scm/{test => }/codegen/codegenExprTest.ml | 0 scm/{test => }/codegen/codegenStmtTest.ml | 0 scm/{src => }/codegen/cpool.ml | 0 scm/{src => }/codegen/cpool.mli | 0 scm/{test => }/codegen/cpoolTest.ml | 0 scm/codegen/gen_inst | 1 + scm/{src => }/codegen/gen_inst.ml | 0 scm/{src => }/codegen/iSpec.ml | 0 scm/codegen/instruction.ml | 217 +++++++++++++++++++++++++++++ scm/{src => }/codegen/instruction.mlp | 0 scm/{src => }/codegen/instruction.txt | 0 scm/{src => }/codegen/label.ml | 0 scm/{src => }/codegen/label.mli | 0 scm/{src => }/codegen/main.ml | 0 scm/codegen/match_body.h | 89 ++++++++++++ scm/{src => }/codegen/module.ml | 0 scm/codegen/module.mli | 36 +++++ scm/{src => }/codegen/module.mlip | 0 scm/{test => }/codegen/moduleTest.ml | 0 scm/codegen/opcode.h | 89 ++++++++++++ scm/{src => }/codegen/override.ml | 0 scm/codegen/override.mli | 34 +++++ scm/{src => }/codegen/override.mlip | 0 scm/{test => }/codegen/overrideTest.ml | 0 scm/{src => }/codegen/revList.ml | 0 scm/{src => }/codegen/revList.mli | 0 scm/{test => }/codegen/revListTest.ml | 0 scm/filter/OMakefile | 26 ++++ scm/{test => }/filter/astUtil.ml | 0 scm/{src => }/filter/binding.ml | 0 scm/{src => }/filter/binding.mli | 0 scm/{test => }/filter/bindingTest.ml | 0 scm/{src => }/filter/main.ml | 0 scm/{src => }/filter/rename.ml | 0 scm/{src => }/filter/rename.mli | 0 scm/{test => }/filter/renameTest.ml | 0 scm/{src => }/interCode.ml | 0 scm/{src => }/interCode.mli | 0 scm/{test => }/interCodeTest.ml | 0 scm/{src => }/main.ml | 0 scm/parser/OMakefile | 29 ++++ scm/{test => }/parser/astUtil.ml | 0 scm/{src => }/parser/lexer.ml | 0 scm/{src => }/parser/lexer.mli | 0 scm/{test => }/parser/lexerTest.ml | 0 scm/{src => }/parser/lisp.ml | 0 scm/{src => }/parser/lisp.mli | 0 scm/{test => }/parser/lispTest.ml | 0 scm/{src => }/parser/main.ml | 0 scm/{src => }/parser/parsec.ml | 0 scm/{src => }/parser/parsec.mli | 0 scm/{src => }/parser/sexp.ml | 0 scm/{src => }/parser/sexp.mli | 0 scm/{test => }/parser/sexpTest.ml | 0 scm/{src => }/parser/token.ml | 0 scm/{src => }/parser/token.mli | 0 scm/type/OMakefile | 18 +++ scm/{src => }/type/ast.ml | 0 scm/type/ast.mli | 97 +++++++++++++ scm/{src => }/type/ast.mlip | 0 scm/{src => }/type/error.ml | 0 scm/{src => }/type/node.ml | 0 scm/{src => }/type/node.mli | 0 scm/{test => }/type/nodeTest.ml | 0 scm/{src => }/type/pSet.ml | 0 scm/{src => }/type/pSet.mli | 0 scm/{test => }/type/psetTest.ml | 0 scm/{test => }/type/test_node.txt | 0 scm/{src => }/type/type.h | 0 91 files changed, 764 insertions(+), 5 deletions(-) create mode 100644 scm/codegen/OMakefile rename scm/{src => }/codegen/abc.ml (100%) rename scm/{src => }/codegen/abc.mli (100%) rename scm/{test => }/codegen/abcTest.ml (100%) rename scm/{src => }/codegen/asm.ml (100%) rename scm/{src => }/codegen/asm.mli (100%) rename scm/{test => }/codegen/asmTest.ml (100%) rename scm/{test => }/codegen/astUtil.ml (100%) rename scm/{src => }/codegen/binding.ml (100%) create mode 100644 scm/codegen/binding.mli rename scm/{src => }/codegen/binding.mlip (100%) rename scm/{test => }/codegen/bindingTest.ml (100%) rename scm/{src => }/codegen/bytes.ml (100%) rename scm/{src => }/codegen/bytes.mli (100%) rename scm/{test => }/codegen/bytesTest.ml (100%) rename scm/{src => }/codegen/closureTrans.ml (100%) rename scm/{src => }/codegen/closureTrans.mli (100%) rename scm/{test => }/codegen/closureTransTest.ml (100%) rename scm/{src => }/codegen/codegen.ml (100%) rename scm/{src => }/codegen/codegen.mli (100%) rename scm/{test => }/codegen/codegenClassTest.ml (100%) rename scm/{test => }/codegen/codegenExprTest.ml (100%) rename scm/{test => }/codegen/codegenStmtTest.ml (100%) rename scm/{src => }/codegen/cpool.ml (100%) rename scm/{src => }/codegen/cpool.mli (100%) rename scm/{test => }/codegen/cpoolTest.ml (100%) create mode 120000 scm/codegen/gen_inst rename scm/{src => }/codegen/gen_inst.ml (100%) rename scm/{src => }/codegen/iSpec.ml (100%) create mode 100644 scm/codegen/instruction.ml rename scm/{src => }/codegen/instruction.mlp (100%) rename scm/{src => }/codegen/instruction.txt (100%) rename scm/{src => }/codegen/label.ml (100%) rename scm/{src => }/codegen/label.mli (100%) rename scm/{src => }/codegen/main.ml (100%) create mode 100644 scm/codegen/match_body.h rename scm/{src => }/codegen/module.ml (100%) create mode 100644 scm/codegen/module.mli rename scm/{src => }/codegen/module.mlip (100%) rename scm/{test => }/codegen/moduleTest.ml (100%) create mode 100644 scm/codegen/opcode.h rename scm/{src => }/codegen/override.ml (100%) create mode 100644 scm/codegen/override.mli rename scm/{src => }/codegen/override.mlip (100%) rename scm/{test => }/codegen/overrideTest.ml (100%) rename scm/{src => }/codegen/revList.ml (100%) rename scm/{src => }/codegen/revList.mli (100%) rename scm/{test => }/codegen/revListTest.ml (100%) create mode 100644 scm/filter/OMakefile rename scm/{test => }/filter/astUtil.ml (100%) rename scm/{src => }/filter/binding.ml (100%) rename scm/{src => }/filter/binding.mli (100%) rename scm/{test => }/filter/bindingTest.ml (100%) rename scm/{src => }/filter/main.ml (100%) rename scm/{src => }/filter/rename.ml (100%) rename scm/{src => }/filter/rename.mli (100%) rename scm/{test => }/filter/renameTest.ml (100%) rename scm/{src => }/interCode.ml (100%) rename scm/{src => }/interCode.mli (100%) rename scm/{test => }/interCodeTest.ml (100%) rename scm/{src => }/main.ml (100%) create mode 100644 scm/parser/OMakefile rename scm/{test => }/parser/astUtil.ml (100%) rename scm/{src => }/parser/lexer.ml (100%) rename scm/{src => }/parser/lexer.mli (100%) rename scm/{test => }/parser/lexerTest.ml (100%) rename scm/{src => }/parser/lisp.ml (100%) rename scm/{src => }/parser/lisp.mli (100%) rename scm/{test => }/parser/lispTest.ml (100%) rename scm/{src => }/parser/main.ml (100%) rename scm/{src => }/parser/parsec.ml (100%) rename scm/{src => }/parser/parsec.mli (100%) rename scm/{src => }/parser/sexp.ml (100%) rename scm/{src => }/parser/sexp.mli (100%) rename scm/{test => }/parser/sexpTest.ml (100%) rename scm/{src => }/parser/token.ml (100%) rename scm/{src => }/parser/token.mli (100%) create mode 100644 scm/type/OMakefile rename scm/{src => }/type/ast.ml (100%) create mode 100644 scm/type/ast.mli rename scm/{src => }/type/ast.mlip (100%) rename scm/{src => }/type/error.ml (100%) rename scm/{src => }/type/node.ml (100%) rename scm/{src => }/type/node.mli (100%) rename scm/{test => }/type/nodeTest.ml (100%) rename scm/{src => }/type/pSet.ml (100%) rename scm/{src => }/type/pSet.mli (100%) rename scm/{test => }/type/psetTest.ml (100%) rename scm/{test => }/type/test_node.txt (100%) rename scm/{src => }/type/type.h (100%) diff --git a/scm/OMakefile b/scm/OMakefile index 97d811c..c6bd8c8 100644 --- a/scm/OMakefile +++ b/scm/OMakefile @@ -1,13 +1,34 @@ +# ------------------------------ # build -OCAMLINCLUDES += $(ROOT)/base/src -OCAML_LIBS += $(ROOT)/base/src/base +# ------------------------------ +OCAMLPACKS[] = + extlib + str + oUnit +UseCamlp4(pa_oo pa_openin) -.SUBDIRS: test src +OCAMLINCLUDES += $(ROOT)/base +OCAML_LIBS += $(ROOT)/base/base +.SUBDIRS: type -habc-scm$(EXE): src/habc-scm$(EXE) - ln-or-cp src/habc-scm$(EXE) . +OCAMLINCLUDES += $(absname type/) +OCAML_LIBS += $(absname type/type) +.SUBDIRS: parser filter codegen +FILES[] = + interCode + parser + codegen + filter + $(ROOT)/config + +PROGRAM = habc-scm + +OCamlProgram($(PROGRAM), main $(FILES)) + +# ------------------------------ # phony +# ------------------------------ .DEFAULT: habc-scm$(EXE) .PHONY: clean integrate integrate-detail clean: diff --git a/scm/codegen/OMakefile b/scm/codegen/OMakefile new file mode 100644 index 0000000..94ba826 --- /dev/null +++ b/scm/codegen/OMakefile @@ -0,0 +1,56 @@ +.PHONY: clean +FILES[] = + module + binding + closureTrans + bytes + label + abc + cpool + revList + instruction + iSpec + asm + codegen + override + main + +CPPFLAGS+=-I../type + +PROGRAM=../codegen + +OCAMLOPT = ocamlopt -for-pack $(capitalize $(basename $(PROGRAM))) +OCAMLOPTLINK= ocamlopt + +OCamlProgram(gen_inst,gen_inst) +OCamlLibrary(codegen, $(FILES)) +MyOCamlPackage($(PROGRAM), $(FILES)) + +OUNIT_LIBS+=astUtil + +OUnitTest(bytes , bytes label) +OUnitTest(abc , abc label bytes) +OUnitTest(revList , revList) +OUnitTest(cpool , cpool revList) +OUnitTest(closureTrans , closureTrans module) +OUnitTest(asm , asm cpool revList bytes) +OUnitTest(codegenExpr , codegen label iSpec) +OUnitTest(codegenStmt , codegen label iSpec) +OUnitTest(codegenClass , codegen label iSpec) +OUnitTest(override , override binding module) +OUnitTest(module , module) +OUnitTest(binding , binding module) + +.DEFAULT: + +match_body.h: gen_inst$(EXE) instruction.txt + ./gen_inst$(EXE) -m < instruction.txt > $@ + +opcode.h: gen_inst$(EXE) instruction.txt + ./gen_inst$(EXE) -t < instruction.txt > $@ + +.SCANNER: instruction.ml : instruction.mlp + grep "#include \"" $< | sed 's/.*"\(.*\)".*/'$@': \1/' + +clean: + ocaml-clean opcode.h match_body.h instruction.ml gen_inst$(EXE) diff --git a/scm/src/codegen/abc.ml b/scm/codegen/abc.ml similarity index 100% rename from scm/src/codegen/abc.ml rename to scm/codegen/abc.ml diff --git a/scm/src/codegen/abc.mli b/scm/codegen/abc.mli similarity index 100% rename from scm/src/codegen/abc.mli rename to scm/codegen/abc.mli diff --git a/scm/test/codegen/abcTest.ml b/scm/codegen/abcTest.ml similarity index 100% rename from scm/test/codegen/abcTest.ml rename to scm/codegen/abcTest.ml diff --git a/scm/src/codegen/asm.ml b/scm/codegen/asm.ml similarity index 100% rename from scm/src/codegen/asm.ml rename to scm/codegen/asm.ml diff --git a/scm/src/codegen/asm.mli b/scm/codegen/asm.mli similarity index 100% rename from scm/src/codegen/asm.mli rename to scm/codegen/asm.mli diff --git a/scm/test/codegen/asmTest.ml b/scm/codegen/asmTest.ml similarity index 100% rename from scm/test/codegen/asmTest.ml rename to scm/codegen/asmTest.ml diff --git a/scm/test/codegen/astUtil.ml b/scm/codegen/astUtil.ml similarity index 100% rename from scm/test/codegen/astUtil.ml rename to scm/codegen/astUtil.ml diff --git a/scm/src/codegen/binding.ml b/scm/codegen/binding.ml similarity index 100% rename from scm/src/codegen/binding.ml rename to scm/codegen/binding.ml diff --git a/scm/codegen/binding.mli b/scm/codegen/binding.mli new file mode 100644 index 0000000..270703c --- /dev/null +++ b/scm/codegen/binding.mli @@ -0,0 +1,46 @@ +(* CAUTION: this is a generated file. If you edit it, all changes will be lost! *) +# 1 "binding.mlip" +# 1 "" +# 1 "" +# 1 "binding.mlip" +type scope = Scope of int | Global + +type name = string list * string + +type bind = + Register of int + | Slot of scope * int + | Member of scope * name + +type slot = name * int + +type 'expr expr = + [ 'expr Module.expr + | `BindVar of bind Node.t] + +type ('expr,'stmt) stmt = + ('expr,'stmt) Module.stmt + + + +# 1 "../type/type.h" 1 + + + + + +# 21 "binding.mlip" 2 +val fold : ('a -> ([> 'b expr]) -> 'a) -> ('a -> [> 'd expr] -> 'e) -> ('a -> 'b -> 'd) -> 'a -> 'b expr -> 'e +val lift : ('a -> 'b) -> [< ('a,'c) stmt ] -> [> ('b,'c) stmt ] +val fold_stmt : ('a -> [> ('b,'c) stmt] -> 'a) -> ('a -> [> ('b,'c) stmt] -> 'e) -> 'a -> ('b,'c) stmt -> 'e + +type expr' = + expr' expr + +type stmt' = + (expr',stmt') stmt + +type program = + stmt' list + +val of_module : Module.program -> slot list * program diff --git a/scm/src/codegen/binding.mlip b/scm/codegen/binding.mlip similarity index 100% rename from scm/src/codegen/binding.mlip rename to scm/codegen/binding.mlip diff --git a/scm/test/codegen/bindingTest.ml b/scm/codegen/bindingTest.ml similarity index 100% rename from scm/test/codegen/bindingTest.ml rename to scm/codegen/bindingTest.ml diff --git a/scm/src/codegen/bytes.ml b/scm/codegen/bytes.ml similarity index 100% rename from scm/src/codegen/bytes.ml rename to scm/codegen/bytes.ml diff --git a/scm/src/codegen/bytes.mli b/scm/codegen/bytes.mli similarity index 100% rename from scm/src/codegen/bytes.mli rename to scm/codegen/bytes.mli diff --git a/scm/test/codegen/bytesTest.ml b/scm/codegen/bytesTest.ml similarity index 100% rename from scm/test/codegen/bytesTest.ml rename to scm/codegen/bytesTest.ml diff --git a/scm/src/codegen/closureTrans.ml b/scm/codegen/closureTrans.ml similarity index 100% rename from scm/src/codegen/closureTrans.ml rename to scm/codegen/closureTrans.ml diff --git a/scm/src/codegen/closureTrans.mli b/scm/codegen/closureTrans.mli similarity index 100% rename from scm/src/codegen/closureTrans.mli rename to scm/codegen/closureTrans.mli diff --git a/scm/test/codegen/closureTransTest.ml b/scm/codegen/closureTransTest.ml similarity index 100% rename from scm/test/codegen/closureTransTest.ml rename to scm/codegen/closureTransTest.ml diff --git a/scm/src/codegen/codegen.ml b/scm/codegen/codegen.ml similarity index 100% rename from scm/src/codegen/codegen.ml rename to scm/codegen/codegen.ml diff --git a/scm/src/codegen/codegen.mli b/scm/codegen/codegen.mli similarity index 100% rename from scm/src/codegen/codegen.mli rename to scm/codegen/codegen.mli diff --git a/scm/test/codegen/codegenClassTest.ml b/scm/codegen/codegenClassTest.ml similarity index 100% rename from scm/test/codegen/codegenClassTest.ml rename to scm/codegen/codegenClassTest.ml diff --git a/scm/test/codegen/codegenExprTest.ml b/scm/codegen/codegenExprTest.ml similarity index 100% rename from scm/test/codegen/codegenExprTest.ml rename to scm/codegen/codegenExprTest.ml diff --git a/scm/test/codegen/codegenStmtTest.ml b/scm/codegen/codegenStmtTest.ml similarity index 100% rename from scm/test/codegen/codegenStmtTest.ml rename to scm/codegen/codegenStmtTest.ml diff --git a/scm/src/codegen/cpool.ml b/scm/codegen/cpool.ml similarity index 100% rename from scm/src/codegen/cpool.ml rename to scm/codegen/cpool.ml diff --git a/scm/src/codegen/cpool.mli b/scm/codegen/cpool.mli similarity index 100% rename from scm/src/codegen/cpool.mli rename to scm/codegen/cpool.mli diff --git a/scm/test/codegen/cpoolTest.ml b/scm/codegen/cpoolTest.ml similarity index 100% rename from scm/test/codegen/cpoolTest.ml rename to scm/codegen/cpoolTest.ml diff --git a/scm/codegen/gen_inst b/scm/codegen/gen_inst new file mode 120000 index 0000000..a8d9c25 --- /dev/null +++ b/scm/codegen/gen_inst @@ -0,0 +1 @@ +gen_inst.opt \ No newline at end of file diff --git a/scm/src/codegen/gen_inst.ml b/scm/codegen/gen_inst.ml similarity index 100% rename from scm/src/codegen/gen_inst.ml rename to scm/codegen/gen_inst.ml diff --git a/scm/src/codegen/iSpec.ml b/scm/codegen/iSpec.ml similarity index 100% rename from scm/src/codegen/iSpec.ml rename to scm/codegen/iSpec.ml diff --git a/scm/codegen/instruction.ml b/scm/codegen/instruction.ml new file mode 100644 index 0000000..ff2c38c --- /dev/null +++ b/scm/codegen/instruction.ml @@ -0,0 +1,217 @@ +(* 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 +open ISpec + +type t = [ + +# 1 "opcode.h" 1 +| `ConstructProp of Cpool.multiname*int +| `ConstructSuper of int +| `Dup +| `NewActivation +| `NewArray of int +| `NewObject of int +| `PopScope +| `Swap +| `Pop +| `Call of int +| `CallPropLex of Cpool.multiname*int +| `CallProperty of Cpool.multiname*int +| `FindPropStrict of Cpool.multiname +| `ReturnValue +| `ReturnVoid +| `InitProperty of Cpool.multiname +| `SetProperty of Cpool.multiname +| `GetProperty of Cpool.multiname +| `GetLex of Cpool.multiname +| `SetGlobalSlot of int +| `GetGlobalSlot of int +| `SetSlot of int +| `GetSlot of int +| `SetLocal of int +| `SetLocal_3 +| `SetLocal_2 +| `SetLocal_1 +| `SetLocal_0 +| `GetLocal of int +| `GetLocal_3 +| `GetLocal_2 +| `GetLocal_1 +| `GetLocal_0 +| `GetScopeObject of int +| `GetGlobalScope +| `PushWith +| `PushScope +| `PushNamespace of Cpool.namespace +| `PushDouble of float +| `PushUInt of int +| `PushInt of int +| `PushString of string +| `PushNaN +| `PushFalse +| `PushTrue +| `PushShort of int +| `PushByte of int +| `PushUndefined +| `PushNull +| `IfStrictNe of Label.t +| `IfStrictEq of Label.t +| `IfGe of Label.t +| `IfGt of Label.t +| `IfLe of Label.t +| `IfLt of Label.t +| `IfNe of Label.t +| `IfEq of Label.t +| `IfFalse of Label.t +| `IfTrue of Label.t +| `Jump of Label.t +| `IfNge of Label.t +| `IfNgt of Label.t +| `IfNle of Label.t +| `IfNlt of Label.t +| `Label of Label.t +| `GreaterEquals +| `GreaterThan +| `LessEquals +| `LessThan +| `StrictEquals +| `Equals +| `Modulo +| `Divide +| `Multiply +| `Subtract +| `Add +| `Multiply_i +| `Subtract_i +| `Add_i +| `Convert_u +| `Convert_b +| `Convert_d +| `Convert_s +| `Convert_i +| `Coerce_s +| `Coerce_a +| `Coerce +| `NewClass of class_ +| `NewFunction of method_ +# 7 "instruction.mlp" 2 +] +and class_ = t ISpec.class_ +and method_ = t ISpec.method_ + +let default : t ISpec.t = { + op=0; + args=const []; + prefix=const []; + const=[]; + method_ = None; + class_ = None; + stack=0; + scope=0; + count=0; +} + +let cindex entry ctx = + u30 (Cpool.index entry ctx#cpool) + +let entry name = + (name :> Cpool.entry) + +let spec = + +# 1 "match_body.h" 1 +function| `ConstructProp (arg0,arg1) -> {default with op=0x4a; stack= ~-arg1; args=(fun ctx -> [u30 @@ Cpool.index arg0 ctx#cpool;u30 arg1]);} +| `ConstructSuper (arg0) -> {default with op=0x49; args=const [u30 arg0]; stack= ~-(arg0+1)} +| `Dup -> {default with op=0x2a; stack= 2} +| `NewActivation -> {default with op=0x57; stack=1} +| `NewArray (arg0) -> {default with op=0x56; args=const [u30 arg0]} +| `NewObject (arg0) -> {default with op=0x55; args=const [u30 arg0]; stack=1-arg0} +| `PopScope -> {default with op=0x1d; scope= ~-1} +| `Swap -> {default with op=0x2b} +| `Pop -> {default with op=0x29; stack= ~-1} +| `Call (arg0) -> {default with op=0x41; stack= 1-(2+arg0); args=const [u30 arg0];} +| `CallPropLex (arg0,arg1) -> {default with op=0x4c; stack= 1-arg1; const=[entry arg0]; args=fun ctx ->[cindex arg0 ctx; u30 arg1]} +| `CallProperty (arg0,arg1) -> {default with op=0x46; stack= 1-arg1; const=[entry arg0]; args=fun ctx ->[cindex arg0 ctx; u30 arg1]} +| `FindPropStrict (arg0) -> {default with op=0x5D; stack=1; const=[entry arg0]; args=fun ctx -> [cindex arg0 ctx]} +| `ReturnValue -> {default with op=0x48; stack= ~-1} +| `ReturnVoid -> {default with op=0x47} +| `InitProperty (arg0) -> {default with op=0x68; stack= ~-2; const=[entry arg0]; args=fun ctx ->[cindex arg0 ctx]} +| `SetProperty (arg0) -> {default with op=0x61; stack= ~-2; const=[entry arg0]; args=fun ctx ->[cindex arg0 ctx]} +| `GetProperty (arg0) -> {default with op=0x66; const=[entry arg0]; args=fun ctx ->[cindex arg0 ctx]} +| `GetLex (arg0) -> {default with op=0x60; stack=1; const=[entry arg0]; args=fun ctx ->[cindex arg0 ctx]} +| `SetGlobalSlot (arg0) -> {default with op=0x6f; stack= ~-1; args=const [u30 arg0]} +| `GetGlobalSlot (arg0) -> {default with op=0x6e; stack=1; args=const [u30 arg0]} +| `SetSlot (arg0) -> {default with op=0x6d; args=const [u30 arg0]; stack= ~-2} +| `GetSlot (arg0) -> {default with op=0x6c; args=const [u30 arg0]} +| `SetLocal (arg0) -> {default with op=0x63; stack=1; args=const [u30 arg0]} +| `SetLocal_3 -> {default with op=0xD7; stack=1} +| `SetLocal_2 -> {default with op=0xD6; stack=1} +| `SetLocal_1 -> {default with op=0xD5; stack=1} +| `SetLocal_0 -> {default with op=0xD4; stack=1} +| `GetLocal (arg0) -> {default with op=0x62; stack=1; args=const [u30 arg0];count=(arg0+1)} +| `GetLocal_3 -> {default with op=0xD3; stack=1;count=4} +| `GetLocal_2 -> {default with op=0xD2; stack=1;count=3} +| `GetLocal_1 -> {default with op=0xD1; stack=1;count=2} +| `GetLocal_0 -> {default with op=0xD0; stack=1;count=1} +| `GetScopeObject (arg0) -> {default with op=0x65; stack=1; args=const[u8 arg0]} +| `GetGlobalScope -> {default with op=0x64; stack=1} +| `PushWith -> {default with op=0x1c; stack= ~-1; scope=1} +| `PushScope -> {default with op=0x30; stack= ~-1; scope=1} +| `PushNamespace (arg0) -> {default with op=0x31; stack=1; const=[entry arg0]; args=fun ctx -> [cindex arg0 ctx]} +| `PushDouble (arg0) -> {default with op=0x2F; stack=1; const=[`Double arg0]; args=fun ctx -> [cindex (`Double arg0) ctx]} +| `PushUInt (arg0) -> {default with op=0x2E; stack=1; const=[`UInt arg0]; args=fun ctx -> [cindex (`UInt arg0) ctx]} +| `PushInt (arg0) -> {default with op=0x2D; stack=1; const=[`Int arg0]; args=fun ctx -> [cindex (`Int arg0) ctx]} +| `PushString (arg0) -> {default with op=0x2C; stack=1; const=[`String arg0]; args=fun ctx -> [cindex (`String arg0) ctx]} +| `PushNaN -> {default with op=0x28; stack=1} +| `PushFalse -> {default with op=0x27; stack=1} +| `PushTrue -> {default with op=0x26; stack=1} +| `PushShort (arg0) -> {default with op=0x25; stack=1; args=const [u30 arg0]} +| `PushByte (arg0) -> {default with op=0x24; stack=1; args=const [u8 arg0]} +| `PushUndefined -> {default with op=0x21; stack=1} +| `PushNull -> {default with op=0x20; stack=1} +| `IfStrictNe (arg0) -> {default with op=0x1a; stack= ~-1; args=const [label_ref arg0]} +| `IfStrictEq (arg0) -> {default with op=0x19; stack= ~-1; args=const [label_ref arg0]} +| `IfGe (arg0) -> {default with op=0x18; stack= ~-1; args=const [label_ref arg0]} +| `IfGt (arg0) -> {default with op=0x17; stack= ~-1; args=const [label_ref arg0]} +| `IfLe (arg0) -> {default with op=0x16; stack= ~-1; args=const [label_ref arg0]} +| `IfLt (arg0) -> {default with op=0x15; stack= ~-1; args=const [label_ref arg0]} +| `IfNe (arg0) -> {default with op=0x14; stack= ~-1; args=const [label_ref arg0]} +| `IfEq (arg0) -> {default with op=0x13; stack= ~-1; args=const [label_ref arg0]} +| `IfFalse (arg0) -> {default with op=0x12; stack= ~-1; args=const [label_ref arg0]} +| `IfTrue (arg0) -> {default with op=0x11; stack= ~-1; args=const [label_ref arg0]} +| `Jump (arg0) -> {default with op=0x10; args=const [label_ref arg0]} +| `IfNge (arg0) -> {default with op=0x0f; stack= ~-1; args=const [label_ref arg0]} +| `IfNgt (arg0) -> {default with op=0x0e; stack= ~-1; args=const [label_ref arg0]} +| `IfNle (arg0) -> {default with op=0x0d; stack= ~-1; args=const [label_ref arg0]} +| `IfNlt (arg0) -> {default with op=0x0c; stack= ~-1; args=const [label_ref arg0]} +| `Label (arg0) -> {default with op=0x09; prefix=const [label arg0]} +| `GreaterEquals -> {default with op=0xb0; stack= ~-1} +| `GreaterThan -> {default with op=0xaf; stack= ~-1} +| `LessEquals -> {default with op=0xae; stack= ~-1} +| `LessThan -> {default with op=0xad; stack= ~-1} +| `StrictEquals -> {default with op=0xac; stack= ~-1} +| `Equals -> {default with op=0xab; stack= ~-1} +| `Modulo -> {default with op=0xa4; stack= ~-1} +| `Divide -> {default with op=0xa3; stack= ~-1} +| `Multiply -> {default with op=0xa2; stack= ~-1} +| `Subtract -> {default with op=0xa1; stack= ~-1} +| `Add -> {default with op=0xa0; stack= ~-1} +| `Multiply_i -> {default with op=0xc7; stack= ~-1} +| `Subtract_i -> {default with op=0xc6; stack= ~-1} +| `Add_i -> {default with op=0xc5; stack= ~-1} +| `Convert_u -> {default with op=0x77} +| `Convert_b -> {default with op=0x76} +| `Convert_d -> {default with op=0x75} +| `Convert_s -> {default with op=0x74} +| `Convert_i -> {default with op=0x73} +| `Coerce_s -> {default with op=0x85} +| `Coerce_a -> {default with op=0x82} +| `Coerce -> {default with op=0x80} +| `NewClass (arg0) -> {default with op=0x58; class_=Some arg0; args=fun ctx -> [u30 @@ RevList.index arg0 ctx#classes];} +| `NewFunction (arg0) -> {default with op=0x40; stack=1; method_=Some arg0; args=fun ctx->[u30 @@ RevList.index arg0 ctx#methods];} +# 31 "instruction.mlp" 2 diff --git a/scm/src/codegen/instruction.mlp b/scm/codegen/instruction.mlp similarity index 100% rename from scm/src/codegen/instruction.mlp rename to scm/codegen/instruction.mlp diff --git a/scm/src/codegen/instruction.txt b/scm/codegen/instruction.txt similarity index 100% rename from scm/src/codegen/instruction.txt rename to scm/codegen/instruction.txt diff --git a/scm/src/codegen/label.ml b/scm/codegen/label.ml similarity index 100% rename from scm/src/codegen/label.ml rename to scm/codegen/label.ml diff --git a/scm/src/codegen/label.mli b/scm/codegen/label.mli similarity index 100% rename from scm/src/codegen/label.mli rename to scm/codegen/label.mli diff --git a/scm/src/codegen/main.ml b/scm/codegen/main.ml similarity index 100% rename from scm/src/codegen/main.ml rename to scm/codegen/main.ml diff --git a/scm/codegen/match_body.h b/scm/codegen/match_body.h new file mode 100644 index 0000000..1b880e8 --- /dev/null +++ b/scm/codegen/match_body.h @@ -0,0 +1,89 @@ +function| `ConstructProp (arg0,arg1) -> {default with op=0x4a; stack= ~-arg1; args=(fun ctx -> [u30 @@ Cpool.index arg0 ctx#cpool;u30 arg1]);} +| `ConstructSuper (arg0) -> {default with op=0x49; args=const [u30 arg0]; stack= ~-(arg0+1)} +| `Dup -> {default with op=0x2a; stack= 2} +| `NewActivation -> {default with op=0x57; stack=1} +| `NewArray (arg0) -> {default with op=0x56; args=const [u30 arg0]} +| `NewObject (arg0) -> {default with op=0x55; args=const [u30 arg0]; stack=1-arg0} +| `PopScope -> {default with op=0x1d; scope= ~-1} +| `Swap -> {default with op=0x2b} +| `Pop -> {default with op=0x29; stack= ~-1} +| `Call (arg0) -> {default with op=0x41; stack= 1-(2+arg0); args=const [u30 arg0];} +| `CallPropLex (arg0,arg1) -> {default with op=0x4c; stack= 1-arg1; const=[entry arg0]; args=fun ctx ->[cindex arg0 ctx; u30 arg1]} +| `CallProperty (arg0,arg1) -> {default with op=0x46; stack= 1-arg1; const=[entry arg0]; args=fun ctx ->[cindex arg0 ctx; u30 arg1]} +| `FindPropStrict (arg0) -> {default with op=0x5D; stack=1; const=[entry arg0]; args=fun ctx -> [cindex arg0 ctx]} +| `ReturnValue -> {default with op=0x48; stack= ~-1} +| `ReturnVoid -> {default with op=0x47} +| `InitProperty (arg0) -> {default with op=0x68; stack= ~-2; const=[entry arg0]; args=fun ctx ->[cindex arg0 ctx]} +| `SetProperty (arg0) -> {default with op=0x61; stack= ~-2; const=[entry arg0]; args=fun ctx ->[cindex arg0 ctx]} +| `GetProperty (arg0) -> {default with op=0x66; const=[entry arg0]; args=fun ctx ->[cindex arg0 ctx]} +| `GetLex (arg0) -> {default with op=0x60; stack=1; const=[entry arg0]; args=fun ctx ->[cindex arg0 ctx]} +| `SetGlobalSlot (arg0) -> {default with op=0x6f; stack= ~-1; args=const [u30 arg0]} +| `GetGlobalSlot (arg0) -> {default with op=0x6e; stack=1; args=const [u30 arg0]} +| `SetSlot (arg0) -> {default with op=0x6d; args=const [u30 arg0]; stack= ~-2} +| `GetSlot (arg0) -> {default with op=0x6c; args=const [u30 arg0]} +| `SetLocal (arg0) -> {default with op=0x63; stack=1; args=const [u30 arg0]} +| `SetLocal_3 -> {default with op=0xD7; stack=1} +| `SetLocal_2 -> {default with op=0xD6; stack=1} +| `SetLocal_1 -> {default with op=0xD5; stack=1} +| `SetLocal_0 -> {default with op=0xD4; stack=1} +| `GetLocal (arg0) -> {default with op=0x62; stack=1; args=const [u30 arg0];count=(arg0+1)} +| `GetLocal_3 -> {default with op=0xD3; stack=1;count=4} +| `GetLocal_2 -> {default with op=0xD2; stack=1;count=3} +| `GetLocal_1 -> {default with op=0xD1; stack=1;count=2} +| `GetLocal_0 -> {default with op=0xD0; stack=1;count=1} +| `GetScopeObject (arg0) -> {default with op=0x65; stack=1; args=const[u8 arg0]} +| `GetGlobalScope -> {default with op=0x64; stack=1} +| `PushWith -> {default with op=0x1c; stack= ~-1; scope=1} +| `PushScope -> {default with op=0x30; stack= ~-1; scope=1} +| `PushNamespace (arg0) -> {default with op=0x31; stack=1; const=[entry arg0]; args=fun ctx -> [cindex arg0 ctx]} +| `PushDouble (arg0) -> {default with op=0x2F; stack=1; const=[`Double arg0]; args=fun ctx -> [cindex (`Double arg0) ctx]} +| `PushUInt (arg0) -> {default with op=0x2E; stack=1; const=[`UInt arg0]; args=fun ctx -> [cindex (`UInt arg0) ctx]} +| `PushInt (arg0) -> {default with op=0x2D; stack=1; const=[`Int arg0]; args=fun ctx -> [cindex (`Int arg0) ctx]} +| `PushString (arg0) -> {default with op=0x2C; stack=1; const=[`String arg0]; args=fun ctx -> [cindex (`String arg0) ctx]} +| `PushNaN -> {default with op=0x28; stack=1} +| `PushFalse -> {default with op=0x27; stack=1} +| `PushTrue -> {default with op=0x26; stack=1} +| `PushShort (arg0) -> {default with op=0x25; stack=1; args=const [u30 arg0]} +| `PushByte (arg0) -> {default with op=0x24; stack=1; args=const [u8 arg0]} +| `PushUndefined -> {default with op=0x21; stack=1} +| `PushNull -> {default with op=0x20; stack=1} +| `IfStrictNe (arg0) -> {default with op=0x1a; stack= ~-1; args=const [label_ref arg0]} +| `IfStrictEq (arg0) -> {default with op=0x19; stack= ~-1; args=const [label_ref arg0]} +| `IfGe (arg0) -> {default with op=0x18; stack= ~-1; args=const [label_ref arg0]} +| `IfGt (arg0) -> {default with op=0x17; stack= ~-1; args=const [label_ref arg0]} +| `IfLe (arg0) -> {default with op=0x16; stack= ~-1; args=const [label_ref arg0]} +| `IfLt (arg0) -> {default with op=0x15; stack= ~-1; args=const [label_ref arg0]} +| `IfNe (arg0) -> {default with op=0x14; stack= ~-1; args=const [label_ref arg0]} +| `IfEq (arg0) -> {default with op=0x13; stack= ~-1; args=const [label_ref arg0]} +| `IfFalse (arg0) -> {default with op=0x12; stack= ~-1; args=const [label_ref arg0]} +| `IfTrue (arg0) -> {default with op=0x11; stack= ~-1; args=const [label_ref arg0]} +| `Jump (arg0) -> {default with op=0x10; args=const [label_ref arg0]} +| `IfNge (arg0) -> {default with op=0x0f; stack= ~-1; args=const [label_ref arg0]} +| `IfNgt (arg0) -> {default with op=0x0e; stack= ~-1; args=const [label_ref arg0]} +| `IfNle (arg0) -> {default with op=0x0d; stack= ~-1; args=const [label_ref arg0]} +| `IfNlt (arg0) -> {default with op=0x0c; stack= ~-1; args=const [label_ref arg0]} +| `Label (arg0) -> {default with op=0x09; prefix=const [label arg0]} +| `GreaterEquals -> {default with op=0xb0; stack= ~-1} +| `GreaterThan -> {default with op=0xaf; stack= ~-1} +| `LessEquals -> {default with op=0xae; stack= ~-1} +| `LessThan -> {default with op=0xad; stack= ~-1} +| `StrictEquals -> {default with op=0xac; stack= ~-1} +| `Equals -> {default with op=0xab; stack= ~-1} +| `Modulo -> {default with op=0xa4; stack= ~-1} +| `Divide -> {default with op=0xa3; stack= ~-1} +| `Multiply -> {default with op=0xa2; stack= ~-1} +| `Subtract -> {default with op=0xa1; stack= ~-1} +| `Add -> {default with op=0xa0; stack= ~-1} +| `Multiply_i -> {default with op=0xc7; stack= ~-1} +| `Subtract_i -> {default with op=0xc6; stack= ~-1} +| `Add_i -> {default with op=0xc5; stack= ~-1} +| `Convert_u -> {default with op=0x77} +| `Convert_b -> {default with op=0x76} +| `Convert_d -> {default with op=0x75} +| `Convert_s -> {default with op=0x74} +| `Convert_i -> {default with op=0x73} +| `Coerce_s -> {default with op=0x85} +| `Coerce_a -> {default with op=0x82} +| `Coerce -> {default with op=0x80} +| `NewClass (arg0) -> {default with op=0x58; class_=Some arg0; args=fun ctx -> [u30 @@ RevList.index arg0 ctx#classes];} +| `NewFunction (arg0) -> {default with op=0x40; stack=1; method_=Some arg0; args=fun ctx->[u30 @@ RevList.index arg0 ctx#methods];} diff --git a/scm/src/codegen/module.ml b/scm/codegen/module.ml similarity index 100% rename from scm/src/codegen/module.ml rename to scm/codegen/module.ml diff --git a/scm/codegen/module.mli b/scm/codegen/module.mli new file mode 100644 index 0000000..dee5037 --- /dev/null +++ b/scm/codegen/module.mli @@ -0,0 +1,36 @@ +(* CAUTION: this is a generated file. If you edit it, all changes will be lost! *) +# 1 "module.mlip" +# 1 "" +# 1 "" +# 1 "module.mlip" +type 'expr expr = 'expr Ast.expr + +type stmt_name = + [ `Public of Ast.qname + | `Internal of Ast.qname] + +type ('expr,'stmt) stmt = + [ `Define of stmt_name * 'expr + | `Expr of 'expr + | `Class of (stmt_name,'expr Ast.method_) Ast.class_ ] + + +# 1 "../type/type.h" 1 + + + + + +# 13 "module.mlip" 2 +val fold : ('a -> ([> 'b expr]) -> 'a) -> ('a -> [> 'd expr] -> 'e) -> ('a -> 'b -> 'd) -> 'a -> 'b expr -> 'e +val lift : ('a -> 'b) -> [< ('a,'c) stmt ] -> [> ('b,'c) stmt ] +val fold_stmt : ('a -> [> ('b,'c) stmt] -> 'a) -> ('a -> [> ('b,'c) stmt] -> 'e) -> 'a -> ('b,'c) stmt -> 'e + +type expr' = + expr' expr +type stmt' = + (expr',stmt') stmt +type program = + stmt' list + +val of_ast : Ast.program -> program diff --git a/scm/src/codegen/module.mlip b/scm/codegen/module.mlip similarity index 100% rename from scm/src/codegen/module.mlip rename to scm/codegen/module.mlip diff --git a/scm/test/codegen/moduleTest.ml b/scm/codegen/moduleTest.ml similarity index 100% rename from scm/test/codegen/moduleTest.ml rename to scm/codegen/moduleTest.ml diff --git a/scm/codegen/opcode.h b/scm/codegen/opcode.h new file mode 100644 index 0000000..d8ff8c9 --- /dev/null +++ b/scm/codegen/opcode.h @@ -0,0 +1,89 @@ +| `ConstructProp of Cpool.multiname*int +| `ConstructSuper of int +| `Dup +| `NewActivation +| `NewArray of int +| `NewObject of int +| `PopScope +| `Swap +| `Pop +| `Call of int +| `CallPropLex of Cpool.multiname*int +| `CallProperty of Cpool.multiname*int +| `FindPropStrict of Cpool.multiname +| `ReturnValue +| `ReturnVoid +| `InitProperty of Cpool.multiname +| `SetProperty of Cpool.multiname +| `GetProperty of Cpool.multiname +| `GetLex of Cpool.multiname +| `SetGlobalSlot of int +| `GetGlobalSlot of int +| `SetSlot of int +| `GetSlot of int +| `SetLocal of int +| `SetLocal_3 +| `SetLocal_2 +| `SetLocal_1 +| `SetLocal_0 +| `GetLocal of int +| `GetLocal_3 +| `GetLocal_2 +| `GetLocal_1 +| `GetLocal_0 +| `GetScopeObject of int +| `GetGlobalScope +| `PushWith +| `PushScope +| `PushNamespace of Cpool.namespace +| `PushDouble of float +| `PushUInt of int +| `PushInt of int +| `PushString of string +| `PushNaN +| `PushFalse +| `PushTrue +| `PushShort of int +| `PushByte of int +| `PushUndefined +| `PushNull +| `IfStrictNe of Label.t +| `IfStrictEq of Label.t +| `IfGe of Label.t +| `IfGt of Label.t +| `IfLe of Label.t +| `IfLt of Label.t +| `IfNe of Label.t +| `IfEq of Label.t +| `IfFalse of Label.t +| `IfTrue of Label.t +| `Jump of Label.t +| `IfNge of Label.t +| `IfNgt of Label.t +| `IfNle of Label.t +| `IfNlt of Label.t +| `Label of Label.t +| `GreaterEquals +| `GreaterThan +| `LessEquals +| `LessThan +| `StrictEquals +| `Equals +| `Modulo +| `Divide +| `Multiply +| `Subtract +| `Add +| `Multiply_i +| `Subtract_i +| `Add_i +| `Convert_u +| `Convert_b +| `Convert_d +| `Convert_s +| `Convert_i +| `Coerce_s +| `Coerce_a +| `Coerce +| `NewClass of class_ +| `NewFunction of method_ diff --git a/scm/src/codegen/override.ml b/scm/codegen/override.ml similarity index 100% rename from scm/src/codegen/override.ml rename to scm/codegen/override.ml diff --git a/scm/codegen/override.mli b/scm/codegen/override.mli new file mode 100644 index 0000000..5bbc4c2 --- /dev/null +++ b/scm/codegen/override.mli @@ -0,0 +1,34 @@ +(* CAUTION: this is a generated file. If you edit it, all changes will be lost! *) +# 1 "override.mlip" +# 1 "" +# 1 "" +# 1 "override.mlip" +type 'expr expr = 'expr Binding.expr + +type 'expr method_ = ('expr Ast.method_) * [`Override] list +type ('expr,'stmt) stmt = + [ `Define of Module.stmt_name * 'expr + | `Expr of 'expr + | `Class of (Module.stmt_name,'expr method_) Ast.class_ ] + + + +# 1 "../type/type.h" 1 + + + + + +# 11 "override.mlip" 2 +val fold : ('a -> ([> 'b expr]) -> 'a) -> ('a -> [> 'd expr] -> 'e) -> ('a -> 'b -> 'd) -> 'a -> 'b expr -> 'e +val lift : ('a -> 'b) -> [< ('a,'c) stmt ] -> [> ('b,'c) stmt ] +val fold_stmt : ('a -> [> ('b,'c) stmt] -> 'a) -> ('a -> [> ('b,'c) stmt] -> 'e) -> 'a -> ('b,'c) stmt -> 'e + +type expr' = + expr' expr +type stmt' = + (expr',stmt') stmt +type program = + stmt' list + +val of_binding : Binding.program -> program diff --git a/scm/src/codegen/override.mlip b/scm/codegen/override.mlip similarity index 100% rename from scm/src/codegen/override.mlip rename to scm/codegen/override.mlip diff --git a/scm/test/codegen/overrideTest.ml b/scm/codegen/overrideTest.ml similarity index 100% rename from scm/test/codegen/overrideTest.ml rename to scm/codegen/overrideTest.ml diff --git a/scm/src/codegen/revList.ml b/scm/codegen/revList.ml similarity index 100% rename from scm/src/codegen/revList.ml rename to scm/codegen/revList.ml diff --git a/scm/src/codegen/revList.mli b/scm/codegen/revList.mli similarity index 100% rename from scm/src/codegen/revList.mli rename to scm/codegen/revList.mli diff --git a/scm/test/codegen/revListTest.ml b/scm/codegen/revListTest.ml similarity index 100% rename from scm/test/codegen/revListTest.ml rename to scm/codegen/revListTest.ml diff --git a/scm/filter/OMakefile b/scm/filter/OMakefile new file mode 100644 index 0000000..6c80b03 --- /dev/null +++ b/scm/filter/OMakefile @@ -0,0 +1,26 @@ + +# build +FILES[] = + binding + rename + main + +PROGRAM = ../filter +OCAMLOPT = ocamlopt -for-pack $(capitalize $(basename $(PROGRAM))) +OCAMLOPTLINK = ocamlopt + +MyOCamlPackage($(PROGRAM), $(FILES)) +OCamlLibrary(filter, $(FILES)) + +OUNIT_LIBS+=astUtil +OUnitTest(binding, binding) +OUnitTest(rename, rename) + +# phony +.DEFAULT: +.PHONY: clean +clean: + ocaml-clean + + + diff --git a/scm/test/filter/astUtil.ml b/scm/filter/astUtil.ml similarity index 100% rename from scm/test/filter/astUtil.ml rename to scm/filter/astUtil.ml diff --git a/scm/src/filter/binding.ml b/scm/filter/binding.ml similarity index 100% rename from scm/src/filter/binding.ml rename to scm/filter/binding.ml diff --git a/scm/src/filter/binding.mli b/scm/filter/binding.mli similarity index 100% rename from scm/src/filter/binding.mli rename to scm/filter/binding.mli diff --git a/scm/test/filter/bindingTest.ml b/scm/filter/bindingTest.ml similarity index 100% rename from scm/test/filter/bindingTest.ml rename to scm/filter/bindingTest.ml diff --git a/scm/src/filter/main.ml b/scm/filter/main.ml similarity index 100% rename from scm/src/filter/main.ml rename to scm/filter/main.ml diff --git a/scm/src/filter/rename.ml b/scm/filter/rename.ml similarity index 100% rename from scm/src/filter/rename.ml rename to scm/filter/rename.ml diff --git a/scm/src/filter/rename.mli b/scm/filter/rename.mli similarity index 100% rename from scm/src/filter/rename.mli rename to scm/filter/rename.mli diff --git a/scm/test/filter/renameTest.ml b/scm/filter/renameTest.ml similarity index 100% rename from scm/test/filter/renameTest.ml rename to scm/filter/renameTest.ml diff --git a/scm/src/interCode.ml b/scm/interCode.ml similarity index 100% rename from scm/src/interCode.ml rename to scm/interCode.ml diff --git a/scm/src/interCode.mli b/scm/interCode.mli similarity index 100% rename from scm/src/interCode.mli rename to scm/interCode.mli diff --git a/scm/test/interCodeTest.ml b/scm/interCodeTest.ml similarity index 100% rename from scm/test/interCodeTest.ml rename to scm/interCodeTest.ml diff --git a/scm/src/main.ml b/scm/main.ml similarity index 100% rename from scm/src/main.ml rename to scm/main.ml diff --git a/scm/parser/OMakefile b/scm/parser/OMakefile new file mode 100644 index 0000000..9d1dcf8 --- /dev/null +++ b/scm/parser/OMakefile @@ -0,0 +1,29 @@ +# build +FILES[] = + token + parsec + lexer + sexp + lisp + main + +CPPFLAGS+=-I../type + +PROGRAM = ../parser +OCAMLOPT = ocamlopt -for-pack $(capitalize $(basename $(PROGRAM))) +OCAMLOPTLINK = ocamlopt +MyOCamlPackage($(PROGRAM), $(FILES)) + + +OUNIT_LIBS += astUtil +OUnitTest(lexer ,lexer parsec) +OUnitTest(sexp ,sexp parsec) +OUnitTest(lisp ,lisp sexp parsec lexer) + + + +# phony +.PHONY: clean +.DEFAULT: +clean: + ocaml-clean closTrans.mli diff --git a/scm/test/parser/astUtil.ml b/scm/parser/astUtil.ml similarity index 100% rename from scm/test/parser/astUtil.ml rename to scm/parser/astUtil.ml diff --git a/scm/src/parser/lexer.ml b/scm/parser/lexer.ml similarity index 100% rename from scm/src/parser/lexer.ml rename to scm/parser/lexer.ml diff --git a/scm/src/parser/lexer.mli b/scm/parser/lexer.mli similarity index 100% rename from scm/src/parser/lexer.mli rename to scm/parser/lexer.mli diff --git a/scm/test/parser/lexerTest.ml b/scm/parser/lexerTest.ml similarity index 100% rename from scm/test/parser/lexerTest.ml rename to scm/parser/lexerTest.ml diff --git a/scm/src/parser/lisp.ml b/scm/parser/lisp.ml similarity index 100% rename from scm/src/parser/lisp.ml rename to scm/parser/lisp.ml diff --git a/scm/src/parser/lisp.mli b/scm/parser/lisp.mli similarity index 100% rename from scm/src/parser/lisp.mli rename to scm/parser/lisp.mli diff --git a/scm/test/parser/lispTest.ml b/scm/parser/lispTest.ml similarity index 100% rename from scm/test/parser/lispTest.ml rename to scm/parser/lispTest.ml diff --git a/scm/src/parser/main.ml b/scm/parser/main.ml similarity index 100% rename from scm/src/parser/main.ml rename to scm/parser/main.ml diff --git a/scm/src/parser/parsec.ml b/scm/parser/parsec.ml similarity index 100% rename from scm/src/parser/parsec.ml rename to scm/parser/parsec.ml diff --git a/scm/src/parser/parsec.mli b/scm/parser/parsec.mli similarity index 100% rename from scm/src/parser/parsec.mli rename to scm/parser/parsec.mli diff --git a/scm/src/parser/sexp.ml b/scm/parser/sexp.ml similarity index 100% rename from scm/src/parser/sexp.ml rename to scm/parser/sexp.ml diff --git a/scm/src/parser/sexp.mli b/scm/parser/sexp.mli similarity index 100% rename from scm/src/parser/sexp.mli rename to scm/parser/sexp.mli diff --git a/scm/test/parser/sexpTest.ml b/scm/parser/sexpTest.ml similarity index 100% rename from scm/test/parser/sexpTest.ml rename to scm/parser/sexpTest.ml diff --git a/scm/src/parser/token.ml b/scm/parser/token.ml similarity index 100% rename from scm/src/parser/token.ml rename to scm/parser/token.ml diff --git a/scm/src/parser/token.mli b/scm/parser/token.mli similarity index 100% rename from scm/src/parser/token.mli rename to scm/parser/token.mli diff --git a/scm/type/OMakefile b/scm/type/OMakefile new file mode 100644 index 0000000..82d817a --- /dev/null +++ b/scm/type/OMakefile @@ -0,0 +1,18 @@ +# build +FILES[] = + node + ast + pSet + +PROGRAM = type + +OCamlLibrary($(PROGRAM), $(FILES)) + +OUnitTest(pset, pSet) +OUnitTest(node, node) + +# phony +.PHONY: clean +.DEFAULT: +clean: + ocaml-clean ast.mli diff --git a/scm/src/type/ast.ml b/scm/type/ast.ml similarity index 100% rename from scm/src/type/ast.ml rename to scm/type/ast.ml diff --git a/scm/type/ast.mli b/scm/type/ast.mli new file mode 100644 index 0000000..9f62c97 --- /dev/null +++ b/scm/type/ast.mli @@ -0,0 +1,97 @@ +(* CAUTION: this is a generated file. If you edit it, all changes will be lost! *) +# 1 "ast.mlip" +# 1 "" +# 1 "" +# 1 "ast.mlip" +open Base + +type qname = (string list * string) Node.t +type sname = string Node.t + +type 'expr expr = + [ `Int of int Node.t + | `String of string Node.t + | `Bool of bool Node.t + | `Float of float Node.t + | `Var of qname + | `Array of 'expr list + | `Lambda of sname list * 'expr + | `Call of 'expr list + | `If of 'expr * 'expr * 'expr + | `Let of (sname*'expr) list * 'expr + | `LetRec of (sname*'expr) list * 'expr + | `Block of 'expr list + | `New of qname * 'expr list + | `Invoke of 'expr * sname * 'expr list + | `SlotRef of 'expr * sname + | `SlotSet of 'expr * sname * 'expr ] + +type 'stmt module_ = { + module_name : sname; + exports : [`All | `Only of sname list]; + stmts : 'stmt list +} +type ('expr,'stmt) module_stmt = + [ `Module of 'stmt module_ + | `Open of string list Node.t ] + +type 'expr method_ = { + method_name : [`Public of sname | `Static of sname]; + args : sname list; + body : 'expr; +} + +type ('name,'method_) class_ = { + class_name : 'name; + super: qname; + attrs: sname list; + methods: 'method_ list +} + +type ('expr,'stmt) expr_stmt = + [ `Define of sname * 'expr + | `Expr of 'expr ] + +type ('expr,'stmt) class_stmt = + [ `Class of (sname, 'expr method_) class_ ] + +type ('expr,'stmt) stmt = + [ ('expr,'stmt) class_stmt + | ('expr,'stmt) expr_stmt + | ('expr,'stmt) module_stmt ] + +type expr' = + expr' expr +type stmt' = + (expr',stmt') stmt +type program = + stmt' list + + +# 1 "type.h" 1 + + + + + +# 66 "ast.mlip" 2 +val fold : ('a -> ([> 'b expr]) -> 'a) -> ('a -> [> 'd expr] -> 'e) -> ('a -> 'b -> 'd) -> 'a -> 'b expr -> 'e + +val fold_expr_stmt : ('a -> [> ('b,'c) expr_stmt] -> 'a) -> ('a -> [> ('b,'c) expr_stmt] -> 'e) -> 'a -> ('b,'c) expr_stmt -> 'e +val fold_module_stmt : ('a -> [> ('b,'c) module_stmt ] -> 'a) -> ('a -> [> ('b,'d) module_stmt ] -> 'e) -> ('a -> 'c -> 'd) -> 'a -> ('b, 'c) module_stmt -> 'e +val fold_class_stmt : ('a -> [> ('b,'c) class_stmt] -> 'a) -> ('a -> [> ('b,'c) class_stmt] -> 'e) -> 'a -> ('b,'c) class_stmt -> 'e +val fold_stmt : ('a -> [> ('b,'c) stmt ] -> 'a) -> ('a -> [> ('b,'d) stmt ] -> 'e) -> ('a -> 'c -> 'd) -> 'a -> ('b, 'c) stmt -> 'e + +val lift_expr : ('a -> 'b) -> [< ('a,'c) expr_stmt ] -> [> ('b,'c) expr_stmt ] +val lift_module : ('a -> 'b) -> ('c -> 'd) -> [< ('a,'c) module_stmt ] -> [> ('b,'d) module_stmt ] +val lift_class : ('a -> 'b) -> [< ('a,'c) class_stmt ] -> [> ('b,'c) class_stmt ] +val lift : ('a -> 'b) -> ('c -> 'd) -> [< ('a,'c) stmt ] -> [> ('b,'d) stmt ] + +(* combinator *) +val fix_fold : ('a -> 'b -> ('c -> 'd -> 'e) -> 'c -> 'd -> 'e) -> 'a -> 'b -> 'c -> 'd -> 'e +val fix_lift : ('a -> ('b -> 'c) -> 'b -> 'c) -> 'a -> 'b -> 'c +val map : (('a -> 'b -> 'b) -> ('c -> 'd -> 'e) -> ('f -> 'f -> 'g) -> 'f -> 'f -> 'g) -> ('d -> 'e) -> 'f -> 'g + +val public_symbols : stmt' -> qname list +val public_methods : stmt' -> sname list +val public_modules : stmt' -> string list Node.t list diff --git a/scm/src/type/ast.mlip b/scm/type/ast.mlip similarity index 100% rename from scm/src/type/ast.mlip rename to scm/type/ast.mlip diff --git a/scm/src/type/error.ml b/scm/type/error.ml similarity index 100% rename from scm/src/type/error.ml rename to scm/type/error.ml diff --git a/scm/src/type/node.ml b/scm/type/node.ml similarity index 100% rename from scm/src/type/node.ml rename to scm/type/node.ml diff --git a/scm/src/type/node.mli b/scm/type/node.mli similarity index 100% rename from scm/src/type/node.mli rename to scm/type/node.mli diff --git a/scm/test/type/nodeTest.ml b/scm/type/nodeTest.ml similarity index 100% rename from scm/test/type/nodeTest.ml rename to scm/type/nodeTest.ml diff --git a/scm/src/type/pSet.ml b/scm/type/pSet.ml similarity index 100% rename from scm/src/type/pSet.ml rename to scm/type/pSet.ml diff --git a/scm/src/type/pSet.mli b/scm/type/pSet.mli similarity index 100% rename from scm/src/type/pSet.mli rename to scm/type/pSet.mli diff --git a/scm/test/type/psetTest.ml b/scm/type/psetTest.ml similarity index 100% rename from scm/test/type/psetTest.ml rename to scm/type/psetTest.ml diff --git a/scm/test/type/test_node.txt b/scm/type/test_node.txt similarity index 100% rename from scm/test/type/test_node.txt rename to scm/type/test_node.txt diff --git a/scm/src/type/type.h b/scm/type/type.h similarity index 100% rename from scm/src/type/type.h rename to scm/type/type.h -- 2.11.0