Ver Fonte

move dt type to type.ml

Simon Krajewski há 12 anos atrás
pai
commit
151eef1a05
2 ficheiros alterados com 42 adições e 44 exclusões
  1. 1 44
      matcher.ml
  2. 41 0
      type.ml

+ 1 - 44
matcher.ml

@@ -25,51 +25,8 @@ open Common
 open Type
 open Typecore
 
-(* Dt *)
-
 type pvar = tvar * pos
 
-type con_def =
-	| CEnum of tenum * tenum_field
-	| CConst of tconstant
-	| CAny
-	| CType of module_type
-	| CArray of int
-	| CFields of int * (string * tclass_field) list
-	| CExpr of texpr
-
-and con = {
-	c_def : con_def;
-	c_type : t;
-	c_pos : pos;
-}
-
-type st_def =
-	| SVar of tvar
-	| SField of st * string
-	| SEnum of st * string * int
-	| SArray of st * int
-	| STuple of st * int * int
-
-and st = {
-	st_def : st_def;
-	st_type : t;
-	st_pos : pos;
-}
-
-type dt =
-	| Out of texpr * texpr option * dt option
-	| Switch of st * (con * dt) list
-	| Bind of (pvar * st) list * dt
-	| Goto of int
-
-type decision_tree = {
-	dt_dt_lookup : dt array;
-	dt_first : int;
-	dt_type : t;
-	dt_var_init : (tvar * texpr option) list;
-}
-
 (* Pattern *)
 
 type pat_def =
@@ -1118,7 +1075,7 @@ let make_dt ctx e cases def with_type p =
 		| _ -> assert false
 	end;
 	{
-		dt_first = Hashtbl.find mctx.dt_cache dt;
+		dt_first = (match dt with Goto i -> i | _ -> Hashtbl.find mctx.dt_cache dt);
 		dt_dt_lookup = DynArray.to_array mctx.dt_lut;
 		dt_type = t;
 		dt_var_init = List.rev !var_inits;

+ 41 - 0
type.ml

@@ -289,6 +289,47 @@ and module_kind =
 	| MMacro
 	| MFake
 
+and con_def =
+	| CEnum of tenum * tenum_field
+	| CConst of tconstant
+	| CAny
+	| CType of module_type
+	| CArray of int
+	| CFields of int * (string * tclass_field) list
+	| CExpr of texpr
+
+and con = {
+	c_def : con_def;
+	c_type : t;
+	c_pos : pos;
+}
+
+and st_def =
+	| SVar of tvar
+	| SField of st * string
+	| SEnum of st * string * int
+	| SArray of st * int
+	| STuple of st * int * int
+
+and st = {
+	st_def : st_def;
+	st_type : t;
+	st_pos : pos;
+}
+
+and dt =
+	| Out of texpr * texpr option * dt option
+	| Switch of st * (con * dt) list
+	| Bind of ((tvar * pos) * st) list * dt
+	| Goto of int
+
+and decision_tree = {
+	dt_dt_lookup : dt array;
+	dt_first : int;
+	dt_type : t;
+	dt_var_init : (tvar * texpr option) list;
+}
+
 let alloc_var =
 	let uid = ref 0 in
 	(fun n t -> incr uid; { v_name = n; v_type = t; v_id = !uid; v_capture = false; v_extra = None })