From bae7da509003bdfd9e241fe1c6688a72bbbadd61 Mon Sep 17 00:00:00 2001 From: Dan Korostelev Date: Fri, 21 Nov 2014 21:08:47 +0300 Subject: [PATCH] [js] support @:selfCall for extern methods (see #3441) --- ast.ml | 1 + common.ml | 1 + genjs.ml | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/ast.ml b/ast.ml index 3f4013f8ad2..cfab7141ae4 100644 --- a/ast.ml +++ b/ast.ml @@ -133,6 +133,7 @@ module Meta = struct | Rtti | Runtime | RuntimeValue + | SelfCall | Setter | SkipCtor | SkipReflection diff --git a/common.ml b/common.ml index a9e1f77ceb0..3f5945e7251 100644 --- a/common.ml +++ b/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]) diff --git a/genjs.ml b/genjs.ml index 0b461cdc8b9..0ec088e836e 100644 --- a/genjs.ml +++ b/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 "(";