瀏覽代碼

added ExprRequire<T> (supported for "using" only)

Nicolas Cannasse 14 年之前
父節點
當前提交
d75fbdf77d
共有 2 個文件被更改,包括 8 次插入1 次删除
  1. 2 0
      std/haxe/macro/Expr.hx
  2. 6 1
      typeload.ml

+ 2 - 0
std/haxe/macro/Expr.hx

@@ -83,6 +83,8 @@ typedef Expr = {
 	var pos : Position;
 }
 
+typedef ExprRequire<T> = Expr;
+
 enum ExprDef {
 	EConst( c : Constant );
 	EArray( e1 : Expr, e2 : Expr );

+ 6 - 1
typeload.ml

@@ -927,9 +927,14 @@ let init_class ctx c p herits fields =
 				}
 			else
 				let tdyn = Some (CTPath { tpackage = []; tname = "Dynamic"; tparams = []; tsub = None }) in
+				let to_dyn = function
+					| { tpackage = ["haxe";"macro"]; tname = "Expr"; tsub = Some "ExprRequire"; tparams = [TPType t] } -> Some t
+					| { tpackage = []; tname = "ExprRequire"; tsub = None; tparams = [TPType t] } -> Some t
+					| _ -> tdyn
+				in
 				{
 					f_type = tdyn;
-					f_args = List.map (fun (a,o,_,_) -> a,o,tdyn,None) fd.f_args;
+					f_args = List.map (fun (a,o,t,_) -> a,o,(match t with Some (CTPath t) -> to_dyn t | _ -> tdyn),None) fd.f_args;
 					f_expr = (EBlock [],p)
 				}
 			in