Procházet zdrojové kódy

[macro] additional fixes for allow_transform : false (#10792)

* [macro] additional fixes for allow_transform : false

* indentation

Co-authored-by: Simon Krajewski <[email protected]>
Nicolas Cannasse před 2 roky
rodič
revize
8c67be5694
2 změnil soubory, kde provedl 14 přidání a 2 odebrání
  1. 11 1
      src/typing/calls.ml
  2. 3 1
      src/typing/forLoop.ml

+ 11 - 1
src/typing/calls.ml

@@ -289,6 +289,16 @@ let rec build_call_access ctx acc el mode with_type p =
 		AKExpr (dispatch#field_call fa [] el)
 	| AKUsingField sea ->
 		let eparam = sea.se_this in
+		let e = dispatch#field_call sea.se_access [eparam] el in
+		let e = match sea.se_access.fa_host with
+		| FHAbstract _ when not ctx.allow_transform ->
+			(* transform XXXImpl.field(this,args) back into this.field(args) *)
+			(match e.eexpr with
+			| TCall ({ eexpr = TField(_,name) } as f, abs :: el) -> { e with eexpr = TCall(mk (TField(abs,name)) t_dynamic f.epos, el) }
+			| _ -> assert false)
+		| _ ->
+			e
+		in
 		AKExpr (dispatch#field_call sea.se_access [eparam] el)
 	| AKResolve(sea,name) ->
 		AKExpr (dispatch#expr_call (dispatch#resolve_call sea name) [] el)
@@ -509,4 +519,4 @@ let field_chain ctx path access mode with_type =
 			let access = type_field_default_cfg ctx e part.name part.pos mode with_type in
 			loop access path
 	in
-	loop access path
+	loop access path

+ 3 - 1
src/typing/forLoop.ml

@@ -260,7 +260,7 @@ module IterationKind = struct
 		{
 			it_kind = it;
 			it_type = pt;
-			it_expr = e1;
+			it_expr = if not ctx.allow_transform then e else e1;
 		}
 
 	let to_texpr ctx v iterator e2 p =
@@ -315,6 +315,8 @@ module IterationKind = struct
 			mk (TBlock el) t_void p
 		in
 		match iterator.it_kind with
+		| _ when not ctx.allow_transform ->
+			mk (TFor(v,e1,e2)) t_void p
 		| IteratorIntUnroll(offset,length,ascending) ->
 			check_loop_var_modification [v] e2;
 			if not ascending then typing_error "Cannot iterate backwards" p;