Bläddra i källkod

[js] support @:selfCall for extern methods (see #3441)

Dan Korostelev 10 år sedan
förälder
incheckning
bae7da5090
3 ändrade filer med 7 tillägg och 0 borttagningar
  1. 1 0
      ast.ml
  2. 1 0
      common.ml
  3. 5 0
      genjs.ml

+ 1 - 0
ast.ml

@@ -133,6 +133,7 @@ module Meta = struct
 		| Rtti
 		| Runtime
 		| RuntimeValue
+		| SelfCall
 		| Setter
 		| SkipCtor
 		| SkipReflection

+ 1 - 0
common.ml

@@ -444,6 +444,7 @@ module MetaInfo = struct
 		| Rtti -> ":rtti",("Adds runtime type informations",[UsedOn TClass])
 		| Runtime -> ":runtime",("?",[])
 		| RuntimeValue -> ":runtimeValue",("Marks an abstract as being a runtime value",[UsedOn TAbstract])
+		| SelfCall -> ":selfCall",("Translates method calls into calling object directly",[UsedOn TClassField; Platform Js])
 		| Setter -> ":setter",("Generates a native getter function on the given field",[HasParam "Class field name";UsedOn TClassField;Platform Flash])
 		| SkipCtor -> ":skipCtor",("Used internally to generate a constructor as if it were a native type (no __hx_ctor)",[Platforms [Java;Cs]; Internal])
 		| SkipReflection -> ":skipReflection",("Used internally to annotate a field that shouldn't have its reflection data generated",[Platforms [Java;Cs]; UsedOn TClassField; Internal])

+ 5 - 0
genjs.ml

@@ -461,6 +461,11 @@ let rec gen_call ctx e el in_value =
 			gen_value ctx e;
 			spr ctx ")";
 		end
+	| TField (eo, (FInstance(_,_,cf) | FStatic(_,cf) | FAnon(cf))), _ when Meta.has Meta.SelfCall cf.cf_meta ->
+		gen_value ctx eo;
+		spr ctx "(";
+		concat ctx "," (gen_value ctx) el;
+		spr ctx ")"
 	| _ ->
 		gen_value ctx e;
 		spr ctx "(";