Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id EF401200C65 for ; Wed, 22 Mar 2017 00:10:45 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id ED127160B90; Tue, 21 Mar 2017 23:10:45 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 12B5F160B9A for ; Wed, 22 Mar 2017 00:10:44 +0100 (CET) Received: (qmail 7711 invoked by uid 500); 21 Mar 2017 23:10:39 -0000 Mailing-List: contact commits-help@flex.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@flex.apache.org Delivered-To: mailing list commits@flex.apache.org Received: (qmail 7518 invoked by uid 99); 21 Mar 2017 23:10:39 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Mar 2017 23:10:39 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id BD3AEDFF56; Tue, 21 Mar 2017 23:10:38 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: joshtynjala@apache.org To: commits@flex.apache.org Date: Tue, 21 Mar 2017 23:10:40 -0000 Message-Id: <73afaf5fd1024c2ab1884b64b48eaf3a@git.apache.org> In-Reply-To: <132b70eb1b464b6891c60ec846f00390@git.apache.org> References: <132b70eb1b464b6891c60ec846f00390@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [03/50] git commit: [flex-falcon] [refs/heads/master] - FLEX-35231 fix self/this in Language.closure archived-at: Tue, 21 Mar 2017 23:10:46 -0000 FLEX-35231 fix self/this in Language.closure Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/d66093a7 Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/d66093a7 Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/d66093a7 Branch: refs/heads/master Commit: d66093a732ad90b02b6199504db6829c4e28a16c Parents: d67fe9c Author: Alex Harui Authored: Thu Dec 29 22:12:15 2016 -0800 Committer: Alex Harui Committed: Thu Dec 29 22:12:15 2016 -0800 ---------------------------------------------------------------------- .../internal/codegen/js/jx/IdentifierEmitter.java | 12 +++++++++++- .../codegen/js/flexjs/TestFlexJSExpressions.java | 10 ++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/d66093a7/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/IdentifierEmitter.java ---------------------------------------------------------------------- diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/IdentifierEmitter.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/IdentifierEmitter.java index 5a464ad..75d8173 100644 --- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/IdentifierEmitter.java +++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/IdentifierEmitter.java @@ -207,6 +207,7 @@ public class IdentifierEmitter extends JSSubEmitter implements getEmitter().emitClosureStart(); } + boolean wroteSelf = false; if (EmitterUtils.writeThis(getProject(), getModel(), node)) { IFunctionObjectNode functionObjectNode = (IFunctionObjectNode) node @@ -222,9 +223,15 @@ public class IdentifierEmitter extends JSSubEmitter implements startMapping(node); if (functionObjectNode != null) + { write(JSGoogEmitterTokens.SELF); + wroteSelf = true; + } else if (functionNode != null && functionDef.getFunctionClassification() == FunctionClassification.LOCAL) + { write(JSGoogEmitterTokens.SELF); + wroteSelf = true; + } else write(ASEmitterTokens.THIS); @@ -247,7 +254,10 @@ public class IdentifierEmitter extends JSSubEmitter implements write(node.getName()); writeToken(ASEmitterTokens.COMMA); - write(ASEmitterTokens.THIS); + if (wroteSelf) + write(JSGoogEmitterTokens.SELF); + else + write(ASEmitterTokens.THIS); getEmitter().emitClosureEnd(node, nodeDef); emitName = false; } http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/d66093a7/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java ---------------------------------------------------------------------- diff --git a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java index b50636f..29c6ff6 100644 --- a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java +++ b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java @@ -884,6 +884,16 @@ public class TestFlexJSExpressions extends TestGoogExpressions } @Test + public void testMethodAsParamInLocalFunction() + { + IFunctionNode node = (IFunctionNode) getNode( + "public class B {public function b() { function c(f:Function):void {c(d); }; } public function d() {}}", + IFunctionNode.class, WRAP_LEVEL_PACKAGE); + asBlockWalker.visitFunction(node); + assertOut("/**\n * @export\n */\nB.prototype.b = function() {\n var self = this;\n function c(f) {\n c(org.apache.flex.utils.Language.closure(self.d, self, 'd'));\n };\n \n}"); + } + + @Test public void testNativeGetter() { IFunctionNode node = (IFunctionNode) getNode(