OSDN Git Service

[UPDATE]Add interCode module
authormzp <mzpppp@gmail.com>
Sat, 17 Jan 2009 11:04:30 +0000 (20:04 +0900)
committermzp <mzpppp@gmail.com>
Sat, 17 Jan 2009 11:04:30 +0000 (20:04 +0900)
14 files changed:
.gitignore
OMakefile
OMakeroot
driver/OMakefile
driver/OMakeroot [deleted file]
scm/OMakefile
scm/src/OMakefile
scm/src/interCode.ml [new file with mode: 0644]
scm/test/.ocamlinit
scm/test/OMakefile
scm/test/test_interCode.ml [new file with mode: 0644]
xml/OMakefile
xml/src/OMakefile
xml/test/OMakefile

index 73b865f..f2218ac 100644 (file)
@@ -2,6 +2,9 @@
 *~
 .DS_Store
 *.swp
+*.spot
+*.spit
+*.annot
 
 # auto generate file
 scm/src/instruction.ml
index 9af1b88..73a52f6 100644 (file)
--- a/OMakefile
+++ b/OMakefile
@@ -1,5 +1,15 @@
 PREFIX:=/usr/local
 
+static. =
+       OCAMLFLAGS = -g -annot
+
+Shell. +=
+    ounit-postproc(argv) =
+      (grep -i "FAIL\|ERROR" && exit 1) || exit 0
+    ocaml-clean(argv) =
+      rm -f *.cm[iox] *.o *.omc *.opt *.run *~ $(argv) *.cmxa *.a
+
+
 .PHONY: clean all
 .SUBDIRS: scm xml driver base
 
@@ -15,7 +25,7 @@ habc : driver/habc
 PROGRAM = habc habc-xml habc-scm
 
 clean:
-       rm -f *~ *.omc *.abc $(PROGRAM)
+       ocaml-clean *.abc $(PROGRAM)
 
 install: $(PROGRAM) share
        mkdir -p $(PREFIX)/bin
index 9af1704..35c219d 100644 (file)
--- a/OMakeroot
+++ b/OMakeroot
@@ -39,11 +39,6 @@ open build/LaTeX
 #
 DefineCommandVars()
 
-Shell. +=
-    ounit-postproc(argv) =
-      (grep -i "FAIL\|ERROR" && exit 1) || exit 0
-
-
 #
 # Include the OMakefile in this directory.
 #
index 0e2d677..1551d6f 100644 (file)
@@ -1,4 +1,4 @@
-.PHONY: all install clean
+.PHONY: clean
 
 ################################################
 # Configuration.  You may want to modify any of these configuration
@@ -12,7 +12,7 @@ USE_OCAMLFIND = true
 OCAMLPACKS[] =
     extlib
 
-#
+
 if $(not $(OCAMLFIND_EXISTS))
     eprintln('This project requires ocamlfind, but is was not found.')
     eprintln('You need to install ocamlfind and run "omake --configure".')
@@ -53,3 +53,6 @@ OCAML_LIBS += ../base/base
 OCAML_OTHER_LIBS += unix
 
 .DEFAULT: $(OCamlProgram $(PROGRAM), $(FILES))
+
+clean:
+       ocaml-clean $(PROGRAM)
diff --git a/driver/OMakeroot b/driver/OMakeroot
deleted file mode 100644 (file)
index 35c219d..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-########################################################################
-# Permission is hereby granted, free of charge, to any person
-# obtaining a copy of this file, to deal in the File without
-# restriction, including without limitation the rights to use,
-# copy, modify, merge, publish, distribute, sublicense, and/or
-# sell copies of the File, and to permit persons to whom the
-# File is furnished to do so, subject to the following condition:
-#
-# THE FILE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE FILE OR
-# THE USE OR OTHER DEALINGS IN THE FILE.
-
-########################################################################
-# The standard OMakeroot file.
-# You will not normally need to modify this file.
-# By default, your changes should be placed in the
-# OMakefile in this directory.
-#
-# If you decide to modify this file, note that it uses exactly
-# the same syntax as the OMakefile.
-#
-
-#
-# Include the standard installed configuration files.
-# Any of these can be deleted if you are not using them,
-# but you probably want to keep the Common file.
-#
-open build/C
-open build/OCaml
-open build/LaTeX
-
-#
-# The command-line variables are defined *after* the
-# standard configuration has been loaded.
-#
-DefineCommandVars()
-
-#
-# Include the OMakefile in this directory.
-#
-.SUBDIRS: .
index b31753b..10252b6 100644 (file)
@@ -1,9 +1,8 @@
-.PHONY: clean integrate 
+.PHONY: clean integrate
 .SUBDIRS: test src util
 
-
 clean:
-       rm -f *~ *.omc
+       ocaml-clean
 
 habc-scm: src/habc-scm
        cp src/habc-scm .
index 53ca995..4f3723c 100644 (file)
@@ -29,7 +29,7 @@ BYTE_ENABLED = true
 #
 # Various options
 #
-OCAMLFLAGS    += -g
+#OCAMLFLAGS    +=
 OCAMLPPFLAGS   += -pp 'camlp4o'
 OCAMLDEPFLAGS  += $(OCAMLPPFLAGS)
 
@@ -60,6 +60,7 @@ FILES[] =
        pSet
        tuple
        varResolve
+       interCode
 
 OCAMLINCLUDES += ../../base/
 OCAML_LIBS += ../../base/base
@@ -92,4 +93,4 @@ opcode.ml: ../util/instruction ../util/instruction.txt
     ../util/instruction -t < ../util/instruction.txt > $@
 
 clean:
-       rm -f  $(PROGRAM) *.cm[iox] *.o *.omc *.opt *.run *~ match_body.ml opcode.ml instruction.ml
+       ocaml-clean $(PROGRAM) match_body.ml opcode.ml instruction.ml
diff --git a/scm/src/interCode.ml b/scm/src/interCode.ml
new file mode 100644 (file)
index 0000000..df330a1
--- /dev/null
@@ -0,0 +1,13 @@
+(** intermediate code *)
+type inter_code = {
+  variables: Ast.qname list;
+  methods: Ast.qname list;
+  program: Ast.program
+}
+
+let of_program program = {
+  variables = [];
+  methods   = [];
+  program   = program
+}
+
index 4cfe808..ba9b850 100644 (file)
@@ -1,5 +1,6 @@
 #directory "../src";;
 #use "../src/.ocamlinit";;
+#require "Dynlink";;
 #require "oUnit";;
 #load "util.cmo";;
 #load "astUtil.cmo";;
index 9952017..1b6a6fe 100644 (file)
@@ -37,7 +37,6 @@ BYTE_ENABLED = true
 # Various options
 #
 
-OCAMLFLAGS    +=
 OCAMLPPFLAGS +=
 OCAMLDEPFLAGS += $(OCAMLPPFLAGS)
 
@@ -69,6 +68,7 @@ FILES[] =
        test_abc
        test_tuple
        test_varResolve
+       test_interCode
 
 OCAMLINCLUDES += ../../base/
 OCAML_LIBS += ../../base/base
@@ -90,4 +90,4 @@ check: $(PROGRAM).run
        ./$(PROGRAM).run | ounit-postproc
 
 clean:
-       rm -f  $(PROGRAM) *.cm[iox] *.o *.omc *.opt *.run *~ runner.h
+       ocaml-clean $(PROGRAM)
diff --git a/scm/test/test_interCode.ml b/scm/test/test_interCode.ml
new file mode 100644 (file)
index 0000000..1781d9f
--- /dev/null
@@ -0,0 +1,19 @@
+open Base
+open Util
+open OUnit
+open AstUtil
+open InterCode
+
+let v_ok variables program =
+  let inter_code =
+    of_program program in
+    ok variables inter_code.variables
+
+
+let _ =
+  ("interCode.ml" >::: [
+     "'public define' should export its name" >::
+       (fun () ->
+         v_ok [global "x"] [define (`Public (global "x")) (int 42)];
+         v_ok [] [define (`Internal (global "x")) (int 42)]);
+   ]) +> run_test_tt
index 0bcb367..f842873 100644 (file)
@@ -4,4 +4,4 @@
 .DEFAULT: src/habc-xml
 
 clean:
-       rm -f habc-xml habc-xml.opt habc-xml.run *.omc .omakedb .omakedb.lock
+       ocaml-clean habc-xml
index 8e2fd4c..0dc0e3b 100644 (file)
@@ -10,8 +10,9 @@
 #
 USE_OCAMLFIND = true
 OCAMLPACKS[] =
-       xml-light
        extlib
+       xml-light
+
 
 if $(not $(OCAMLFIND_EXISTS))
     eprintln('This project requires ocamlfind, but is was not found.')
@@ -19,9 +20,6 @@ if $(not $(OCAMLFIND_EXISTS))
     exit 1
 
 
-OCAMLINCLUDES += ../../base/
-
-
 # Compile native or byte code?
 #
 # The default values are defined as follows:
@@ -77,4 +75,4 @@ OCamlLibrary($(PROGRAM), $(FILES))
 .DEFAULT: $(PROGRAM)
 
 clean:
-       rm -f *.cm[iox] *~ *.o *.omc $(PROGRAM) *.opt *.run *.cma *.cmxa *.a
+       ocaml-clean $(PROGRAM)
index 1975828..88d798f 100644 (file)
@@ -78,4 +78,4 @@ check: $(PROGRAM)
 # PHONY TARGET
 #
 clean:
-       rm -f *.cm[iox] *~ *.o *.omc $(PROGRAM) *.opt *.run
+       ocaml-clean $(PROGRAM)