OSDN Git Service

remove pool
authorMIZUNO Hiroki <mzpppp@gmail.com>
Sat, 2 Aug 2008 15:01:28 +0000 (00:01 +0900)
committerMIZUNO Hiroki <mzpppp@gmail.com>
Sat, 2 Aug 2008 15:01:28 +0000 (00:01 +0900)
src/asm.ml
src/base.ml
src/cpool.ml
util/instruction.txt

index 2469739..62bce30 100644 (file)
@@ -2,6 +2,10 @@ open Base
 open Cpool
 open Bytes
 
+module Set = Core.Std.Set
+type 'a set = 'a Set.t
+
+
 type trait_body = Slot of int
 type trait = string * trait_body
 
@@ -17,7 +21,7 @@ type instruction =
   exceptions: int list;
 }
 
-type mmap = meth Pool.map
+type mmap = meth list
 type config = {
   op:     int;
   args:   Cpool.t * mmap -> Bytes.t list;
@@ -61,14 +65,14 @@ let rec collect ({instructions=insts;traits=traits} as meth) =
              collect child in
              m',Cpool.append c c'
        | None ->
-           Pool.empty,c in
+           Set.empty,c in
   let meths,consts =
     List.fold_left 
-      (fun (m0,c0) (m,c) -> Pool.append m m0,Cpool.append c c0) 
-      (Pool.empty,Cpool.empty) @@ List.map meth_and_const insts in
+      (fun (m0,c0) (m,c) -> Set.union m m0,Cpool.append c c0) 
+      (Set.empty,Cpool.empty) @@ List.map meth_and_const insts in
   let traits' =
     collect_traits traits in
-    Pool.add meth meths,consts
+    Set.add meth meths,consts
 
 (* convert instruction *)
 let add (max,current) n = 
@@ -123,10 +127,8 @@ let asm_method map index m =
 let assemble meth =
   let meths,cpool = 
     collect meth in
-  let mmap =
-    Pool.to_map meths in
   let meths' =
-    Pool.to_list meths in
+    Set.to_list meths in
   let info,body =
-    ExtList.List.split @@ ExtList.List.mapi (fun i x-> asm_method (cpool,mmap) i x) meths' in
+    ExtList.List.split @@ ExtList.List.mapi (fun i x-> asm_method (cpool,meths') i x) meths' in
     Cpool.to_abc cpool,info,body
index d0543bc..27b96c6 100644 (file)
@@ -72,4 +72,4 @@ let index x xs =
          i
        else
          loop (i+1) ys in
-    loop 1 xs
+    loop 0 xs
index a4d176a..1e9f1cc 100644 (file)
@@ -1,5 +1,4 @@
 open Base
-module Set = Core.Std.Set
 
 type namespace = 
     Namespace of string 
@@ -10,6 +9,7 @@ type multiname =
     QName of namespace * string 
   | Multiname of string * namespace_set
 
+module Set = Core.Std.Set
 type 'a set = 'a Set.t
 
 type t = {
@@ -87,6 +87,9 @@ let multiname name=
           multiname     = Set.singleton name }
 
 (* conversion *)    
+let index x xs =
+  1+Base.index x xs
+
 let of_namespace ~string ns =
   let i =
     index (ns_name ns) string in
index e42a079..485eab6 100644 (file)
@@ -84,6 +84,6 @@ PopScope:op=0x1d; scope= ~-1
 NewObject of int:op=0x55; args=const [Bytes.u30 arg0]; stack=1-arg0
 NewArray of int:op=0x56; args=const [Bytes.u30 arg0]
 NewActivation:op=0x57; stack=1
-NewFunction of meth: op=0x40; stack=1; meth=Some arg0; args=fun (_,mmap)->[Bytes.u30 (Pool.get arg0 mmap)]
+NewFunction of meth: op=0x40; stack=1; meth=Some arg0; args=fun (_,mmap)->[Bytes.u30 (index arg0 mmap)]
 
 Dup: op=0x2a; stack= 2