You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by yi...@apache.org on 2020/04/05 20:51:05 UTC

[royale-compiler] 01/01: Works on given test case. Hope I didn't break anything.

This is an automated email from the ASF dual-hosted git repository.

yishayw pushed a commit to branch issue_143
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git

commit 634cb4f3362c75317538ba0daedafd19742d00df
Author: DESKTOP-RH4S838\Yishay <yi...@hotmail.com>
AuthorDate: Sun Apr 5 23:48:11 2020 +0300

    Works on given test case. Hope I didn't break anything.
    
    Reference #143
---
 .../royale/compiler/internal/codegen/js/JSEmitter.java    | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/JSEmitter.java b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/JSEmitter.java
index d24adca..24c65f3 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/JSEmitter.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/JSEmitter.java
@@ -40,6 +40,7 @@ import org.apache.royale.compiler.definitions.metadata.IMetaTag;
 import org.apache.royale.compiler.definitions.metadata.IMetaTagAttribute;
 import org.apache.royale.compiler.internal.codegen.as.ASEmitter;
 import org.apache.royale.compiler.internal.codegen.as.ASEmitterTokens;
+import org.apache.royale.compiler.internal.codegen.js.goog.JSGoogEmitterTokens;
 import org.apache.royale.compiler.internal.codegen.js.jx.BlockCloseEmitter;
 import org.apache.royale.compiler.internal.codegen.js.jx.BlockOpenEmitter;
 import org.apache.royale.compiler.internal.codegen.js.jx.CatchEmitter;
@@ -914,7 +915,19 @@ public class JSEmitter extends ASEmitter implements IJSEmitter
 		{
 			write(coercionStart);
         }
-        emitAssignedValue(assignedNode);
+		if (project.getBuiltinType(BuiltinType.FUNCTION).equals(definition) && 
+				assignedNode instanceof MemberAccessExpressionNode) {
+			write(JSGoogEmitterTokens.GOOG_BIND.getToken() + 
+					ASEmitterTokens.PAREN_OPEN.getToken()
+			);
+			emitAssignedValue(assignedNode);
+			write(ASEmitterTokens.COMMA.getToken());
+			MemberAccessExpressionNode maenode = (MemberAccessExpressionNode)assignedNode;
+			getWalker().walk(maenode.getLeftOperandNode());
+			write(ASEmitterTokens.PAREN_CLOSE.getToken());
+		} else {
+			emitAssignedValue(assignedNode);
+		}
 		if (coercionStart != null)
 		{
 			if (coercionEnd != null)


RE: [royale-compiler] 01/01: Works on given test case. Hope I didn't break anything.

Posted by Yishay Weiss <yi...@hotmail.com>.
Not sure if this relates to my comment [1] in the review request.

[1] https://github.com/apache/royale-compiler/pull/144#issuecomment-609487231

From: Greg Dove<ma...@gmail.com>
Sent: Monday, April 6, 2020 12:29 AM
To: Apache Royale Development<ma...@royale.apache.org>
Subject: Re: [royale-compiler] 01/01: Works on given test case. Hope I didn't break anything.

output for the Language.closure method needs 3 args iirc

1. the method reference
2. the 'this' reference that is being bound to
3. the stringified method reference name from (1)

I think the goal should be something like this:

org.apache.royale.utils.Language.closure(this.parentApplication.buttonFunction,
this.parentApplication, ' buttonFunction');

I can't spend more time on that right now, but if you want to try that
might help....


On Mon, Apr 6, 2020 at 9:16 AM Yishay Weiss <yi...@hotmail.com> wrote:

> Hi,
>
> Changing to
>                                                 emitClosureStart();
>
> emitAssignedValue(assignedNode);
>                                                 MemberAccessExpressionNode
> maenode = (MemberAccessExpressionNode)assignedNode;
>
> emitClosureEnd(maenode.getLeftOperandNode(), definition);
>
> Results in
>
>   org.apache.royale.utils.Language.as(c, MyButton).clickFunction =
> org.apache.royale.utils.Language.closure(this.parentApplication.buttonFunction,
> 'Function');
>
> Which fails with
>
> TypeError: Object.defineProperty called on non-object
> Watch
> Call Stack
> org.apache.royale.utils.Language.closure
> Language.js:281
> MyBox.addElement
> MyBox.js:39
>
> From: Greg Dove<ma...@gmail.com>
> Sent: Monday, April 6, 2020 12:07 AM
> To: Apache Royale Development<ma...@royale.apache.org>
> Subject: Re: [royale-compiler] 01/01: Works on given test case. Hope I
> didn't break anything.
>
> Take a look at emitClosureStart and emitClosureEnd I think those will help
> out.
>
>
> On Mon, Apr 6, 2020 at 9:01 AM Greg Dove <gr...@gmail.com> wrote:
>
> >
> > You might find a place in the code where there is something already that
> > has 'needClosure' logic, but the logic that sets it to true does not yet
> > include the specific case you are dealing with.
> >
> > On Mon, Apr 6, 2020 at 8:53 AM Greg Dove <gr...@gmail.com> wrote:
> >
> >> I think it's a great start Yishay. But I'd suggest you look for other
> >> areas of the compiler code where there is a generation of
> Language.closure
> >> output. This should do the same thing I think, but be consistent.
> >>
> >>
> >> On Mon, Apr 6, 2020 at 8:51 AM <yi...@apache.org> wrote:
> >>
> >>> This is an automated email from the ASF dual-hosted git repository.
> >>>
> >>> yishayw pushed a commit to branch issue_143
> >>> in repository https://gitbox.apache.org/repos/asf/royale-compiler.git
> >>>
> >>> commit 634cb4f3362c75317538ba0daedafd19742d00df
> >>> Author: DESKTOP-RH4S838\Yishay <yi...@hotmail.com>
> >>> AuthorDate: Sun Apr 5 23:48:11 2020 +0300
> >>>
> >>>     Works on given test case. Hope I didn't break anything.
> >>>
> >>>     Reference #143
> >>> ---
> >>>  .../royale/compiler/internal/codegen/js/JSEmitter.java    | 15
> >>> ++++++++++++++-
> >>>  1 file changed, 14 insertions(+), 1 deletion(-)
> >>>
> >>> diff --git
> >>>
> a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/JSEmitter.java
> >>>
> b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/JSEmitter.java
> >>> index d24adca..24c65f3 100644
> >>> ---
> >>>
> a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/JSEmitter.java
> >>> +++
> >>>
> b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/JSEmitter.java
> >>> @@ -40,6 +40,7 @@ import
> >>> org.apache.royale.compiler.definitions.metadata.IMetaTag;
> >>>  import
> >>> org.apache.royale.compiler.definitions.metadata.IMetaTagAttribute;
> >>>  import org.apache.royale.compiler.internal.codegen.as.ASEmitter;
> >>>  import org.apache.royale.compiler.internal.codegen.as
> .ASEmitterTokens;
> >>> +import
> >>>
> org.apache.royale.compiler.internal.codegen.js.goog.JSGoogEmitterTokens;
> >>>  import
> >>> org.apache.royale.compiler.internal.codegen.js.jx.BlockCloseEmitter;
> >>>  import
> >>> org.apache.royale.compiler.internal.codegen.js.jx.BlockOpenEmitter;
> >>>  import org.apache.royale.compiler.internal.codegen.js.jx.CatchEmitter;
> >>> @@ -914,7 +915,19 @@ public class JSEmitter extends ASEmitter
> implements
> >>> IJSEmitter
> >>>                 {
> >>>                         write(coercionStart);
> >>>          }
> >>> -        emitAssignedValue(assignedNode);
> >>> +               if
> >>> (project.getBuiltinType(BuiltinType.FUNCTION).equals(definition) &&
> >>> +                               assignedNode instanceof
> >>> MemberAccessExpressionNode) {
> >>> +                       write(JSGoogEmitterTokens.GOOG_BIND.getToken()
> +
> >>> +
> >>>  ASEmitterTokens.PAREN_OPEN.getToken()
> >>> +                       );
> >>> +                       emitAssignedValue(assignedNode);
> >>> +                       write(ASEmitterTokens.COMMA.getToken());
> >>> +                       MemberAccessExpressionNode maenode =
> >>> (MemberAccessExpressionNode)assignedNode;
> >>> +                       getWalker().walk(maenode.getLeftOperandNode());
> >>> +                       write(ASEmitterTokens.PAREN_CLOSE.getToken());
> >>> +               } else {
> >>> +                       emitAssignedValue(assignedNode);
> >>> +               }
> >>>                 if (coercionStart != null)
> >>>                 {
> >>>                         if (coercionEnd != null)
> >>>
> >>>
>
>


Re: [royale-compiler] 01/01: Works on given test case. Hope I didn't break anything.

Posted by Greg Dove <gr...@gmail.com>.
output for the Language.closure method needs 3 args iirc

1. the method reference
2. the 'this' reference that is being bound to
3. the stringified method reference name from (1)

I think the goal should be something like this:

org.apache.royale.utils.Language.closure(this.parentApplication.buttonFunction,
this.parentApplication, ' buttonFunction');

I can't spend more time on that right now, but if you want to try that
might help....


On Mon, Apr 6, 2020 at 9:16 AM Yishay Weiss <yi...@hotmail.com> wrote:

> Hi,
>
> Changing to
>                                                 emitClosureStart();
>
> emitAssignedValue(assignedNode);
>                                                 MemberAccessExpressionNode
> maenode = (MemberAccessExpressionNode)assignedNode;
>
> emitClosureEnd(maenode.getLeftOperandNode(), definition);
>
> Results in
>
>   org.apache.royale.utils.Language.as(c, MyButton).clickFunction =
> org.apache.royale.utils.Language.closure(this.parentApplication.buttonFunction,
> 'Function');
>
> Which fails with
>
> TypeError: Object.defineProperty called on non-object
> Watch
> Call Stack
> org.apache.royale.utils.Language.closure
> Language.js:281
> MyBox.addElement
> MyBox.js:39
>
> From: Greg Dove<ma...@gmail.com>
> Sent: Monday, April 6, 2020 12:07 AM
> To: Apache Royale Development<ma...@royale.apache.org>
> Subject: Re: [royale-compiler] 01/01: Works on given test case. Hope I
> didn't break anything.
>
> Take a look at emitClosureStart and emitClosureEnd I think those will help
> out.
>
>
> On Mon, Apr 6, 2020 at 9:01 AM Greg Dove <gr...@gmail.com> wrote:
>
> >
> > You might find a place in the code where there is something already that
> > has 'needClosure' logic, but the logic that sets it to true does not yet
> > include the specific case you are dealing with.
> >
> > On Mon, Apr 6, 2020 at 8:53 AM Greg Dove <gr...@gmail.com> wrote:
> >
> >> I think it's a great start Yishay. But I'd suggest you look for other
> >> areas of the compiler code where there is a generation of
> Language.closure
> >> output. This should do the same thing I think, but be consistent.
> >>
> >>
> >> On Mon, Apr 6, 2020 at 8:51 AM <yi...@apache.org> wrote:
> >>
> >>> This is an automated email from the ASF dual-hosted git repository.
> >>>
> >>> yishayw pushed a commit to branch issue_143
> >>> in repository https://gitbox.apache.org/repos/asf/royale-compiler.git
> >>>
> >>> commit 634cb4f3362c75317538ba0daedafd19742d00df
> >>> Author: DESKTOP-RH4S838\Yishay <yi...@hotmail.com>
> >>> AuthorDate: Sun Apr 5 23:48:11 2020 +0300
> >>>
> >>>     Works on given test case. Hope I didn't break anything.
> >>>
> >>>     Reference #143
> >>> ---
> >>>  .../royale/compiler/internal/codegen/js/JSEmitter.java    | 15
> >>> ++++++++++++++-
> >>>  1 file changed, 14 insertions(+), 1 deletion(-)
> >>>
> >>> diff --git
> >>>
> a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/JSEmitter.java
> >>>
> b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/JSEmitter.java
> >>> index d24adca..24c65f3 100644
> >>> ---
> >>>
> a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/JSEmitter.java
> >>> +++
> >>>
> b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/JSEmitter.java
> >>> @@ -40,6 +40,7 @@ import
> >>> org.apache.royale.compiler.definitions.metadata.IMetaTag;
> >>>  import
> >>> org.apache.royale.compiler.definitions.metadata.IMetaTagAttribute;
> >>>  import org.apache.royale.compiler.internal.codegen.as.ASEmitter;
> >>>  import org.apache.royale.compiler.internal.codegen.as
> .ASEmitterTokens;
> >>> +import
> >>>
> org.apache.royale.compiler.internal.codegen.js.goog.JSGoogEmitterTokens;
> >>>  import
> >>> org.apache.royale.compiler.internal.codegen.js.jx.BlockCloseEmitter;
> >>>  import
> >>> org.apache.royale.compiler.internal.codegen.js.jx.BlockOpenEmitter;
> >>>  import org.apache.royale.compiler.internal.codegen.js.jx.CatchEmitter;
> >>> @@ -914,7 +915,19 @@ public class JSEmitter extends ASEmitter
> implements
> >>> IJSEmitter
> >>>                 {
> >>>                         write(coercionStart);
> >>>          }
> >>> -        emitAssignedValue(assignedNode);
> >>> +               if
> >>> (project.getBuiltinType(BuiltinType.FUNCTION).equals(definition) &&
> >>> +                               assignedNode instanceof
> >>> MemberAccessExpressionNode) {
> >>> +                       write(JSGoogEmitterTokens.GOOG_BIND.getToken()
> +
> >>> +
> >>>  ASEmitterTokens.PAREN_OPEN.getToken()
> >>> +                       );
> >>> +                       emitAssignedValue(assignedNode);
> >>> +                       write(ASEmitterTokens.COMMA.getToken());
> >>> +                       MemberAccessExpressionNode maenode =
> >>> (MemberAccessExpressionNode)assignedNode;
> >>> +                       getWalker().walk(maenode.getLeftOperandNode());
> >>> +                       write(ASEmitterTokens.PAREN_CLOSE.getToken());
> >>> +               } else {
> >>> +                       emitAssignedValue(assignedNode);
> >>> +               }
> >>>                 if (coercionStart != null)
> >>>                 {
> >>>                         if (coercionEnd != null)
> >>>
> >>>
>
>

RE: [royale-compiler] 01/01: Works on given test case. Hope I didn't break anything.

Posted by Yishay Weiss <yi...@hotmail.com>.
Hi,

Changing to
                                                emitClosureStart();
                                                emitAssignedValue(assignedNode);
                                                MemberAccessExpressionNode maenode = (MemberAccessExpressionNode)assignedNode;
                                                emitClosureEnd(maenode.getLeftOperandNode(), definition);

Results in

  org.apache.royale.utils.Language.as(c, MyButton).clickFunction = org.apache.royale.utils.Language.closure(this.parentApplication.buttonFunction, 'Function');

Which fails with

TypeError: Object.defineProperty called on non-object
Watch
Call Stack
org.apache.royale.utils.Language.closure
Language.js:281
MyBox.addElement
MyBox.js:39

From: Greg Dove<ma...@gmail.com>
Sent: Monday, April 6, 2020 12:07 AM
To: Apache Royale Development<ma...@royale.apache.org>
Subject: Re: [royale-compiler] 01/01: Works on given test case. Hope I didn't break anything.

Take a look at emitClosureStart and emitClosureEnd I think those will help
out.


On Mon, Apr 6, 2020 at 9:01 AM Greg Dove <gr...@gmail.com> wrote:

>
> You might find a place in the code where there is something already that
> has 'needClosure' logic, but the logic that sets it to true does not yet
> include the specific case you are dealing with.
>
> On Mon, Apr 6, 2020 at 8:53 AM Greg Dove <gr...@gmail.com> wrote:
>
>> I think it's a great start Yishay. But I'd suggest you look for other
>> areas of the compiler code where there is a generation of Language.closure
>> output. This should do the same thing I think, but be consistent.
>>
>>
>> On Mon, Apr 6, 2020 at 8:51 AM <yi...@apache.org> wrote:
>>
>>> This is an automated email from the ASF dual-hosted git repository.
>>>
>>> yishayw pushed a commit to branch issue_143
>>> in repository https://gitbox.apache.org/repos/asf/royale-compiler.git
>>>
>>> commit 634cb4f3362c75317538ba0daedafd19742d00df
>>> Author: DESKTOP-RH4S838\Yishay <yi...@hotmail.com>
>>> AuthorDate: Sun Apr 5 23:48:11 2020 +0300
>>>
>>>     Works on given test case. Hope I didn't break anything.
>>>
>>>     Reference #143
>>> ---
>>>  .../royale/compiler/internal/codegen/js/JSEmitter.java    | 15
>>> ++++++++++++++-
>>>  1 file changed, 14 insertions(+), 1 deletion(-)
>>>
>>> diff --git
>>> a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/JSEmitter.java
>>> b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/JSEmitter.java
>>> index d24adca..24c65f3 100644
>>> ---
>>> a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/JSEmitter.java
>>> +++
>>> b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/JSEmitter.java
>>> @@ -40,6 +40,7 @@ import
>>> org.apache.royale.compiler.definitions.metadata.IMetaTag;
>>>  import
>>> org.apache.royale.compiler.definitions.metadata.IMetaTagAttribute;
>>>  import org.apache.royale.compiler.internal.codegen.as.ASEmitter;
>>>  import org.apache.royale.compiler.internal.codegen.as.ASEmitterTokens;
>>> +import
>>> org.apache.royale.compiler.internal.codegen.js.goog.JSGoogEmitterTokens;
>>>  import
>>> org.apache.royale.compiler.internal.codegen.js.jx.BlockCloseEmitter;
>>>  import
>>> org.apache.royale.compiler.internal.codegen.js.jx.BlockOpenEmitter;
>>>  import org.apache.royale.compiler.internal.codegen.js.jx.CatchEmitter;
>>> @@ -914,7 +915,19 @@ public class JSEmitter extends ASEmitter implements
>>> IJSEmitter
>>>                 {
>>>                         write(coercionStart);
>>>          }
>>> -        emitAssignedValue(assignedNode);
>>> +               if
>>> (project.getBuiltinType(BuiltinType.FUNCTION).equals(definition) &&
>>> +                               assignedNode instanceof
>>> MemberAccessExpressionNode) {
>>> +                       write(JSGoogEmitterTokens.GOOG_BIND.getToken() +
>>> +
>>>  ASEmitterTokens.PAREN_OPEN.getToken()
>>> +                       );
>>> +                       emitAssignedValue(assignedNode);
>>> +                       write(ASEmitterTokens.COMMA.getToken());
>>> +                       MemberAccessExpressionNode maenode =
>>> (MemberAccessExpressionNode)assignedNode;
>>> +                       getWalker().walk(maenode.getLeftOperandNode());
>>> +                       write(ASEmitterTokens.PAREN_CLOSE.getToken());
>>> +               } else {
>>> +                       emitAssignedValue(assignedNode);
>>> +               }
>>>                 if (coercionStart != null)
>>>                 {
>>>                         if (coercionEnd != null)
>>>
>>>


Re: [royale-compiler] 01/01: Works on given test case. Hope I didn't break anything.

Posted by Greg Dove <gr...@gmail.com>.
Take a look at emitClosureStart and emitClosureEnd I think those will help
out.


On Mon, Apr 6, 2020 at 9:01 AM Greg Dove <gr...@gmail.com> wrote:

>
> You might find a place in the code where there is something already that
> has 'needClosure' logic, but the logic that sets it to true does not yet
> include the specific case you are dealing with.
>
> On Mon, Apr 6, 2020 at 8:53 AM Greg Dove <gr...@gmail.com> wrote:
>
>> I think it's a great start Yishay. But I'd suggest you look for other
>> areas of the compiler code where there is a generation of Language.closure
>> output. This should do the same thing I think, but be consistent.
>>
>>
>> On Mon, Apr 6, 2020 at 8:51 AM <yi...@apache.org> wrote:
>>
>>> This is an automated email from the ASF dual-hosted git repository.
>>>
>>> yishayw pushed a commit to branch issue_143
>>> in repository https://gitbox.apache.org/repos/asf/royale-compiler.git
>>>
>>> commit 634cb4f3362c75317538ba0daedafd19742d00df
>>> Author: DESKTOP-RH4S838\Yishay <yi...@hotmail.com>
>>> AuthorDate: Sun Apr 5 23:48:11 2020 +0300
>>>
>>>     Works on given test case. Hope I didn't break anything.
>>>
>>>     Reference #143
>>> ---
>>>  .../royale/compiler/internal/codegen/js/JSEmitter.java    | 15
>>> ++++++++++++++-
>>>  1 file changed, 14 insertions(+), 1 deletion(-)
>>>
>>> diff --git
>>> a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/JSEmitter.java
>>> b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/JSEmitter.java
>>> index d24adca..24c65f3 100644
>>> ---
>>> a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/JSEmitter.java
>>> +++
>>> b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/JSEmitter.java
>>> @@ -40,6 +40,7 @@ import
>>> org.apache.royale.compiler.definitions.metadata.IMetaTag;
>>>  import
>>> org.apache.royale.compiler.definitions.metadata.IMetaTagAttribute;
>>>  import org.apache.royale.compiler.internal.codegen.as.ASEmitter;
>>>  import org.apache.royale.compiler.internal.codegen.as.ASEmitterTokens;
>>> +import
>>> org.apache.royale.compiler.internal.codegen.js.goog.JSGoogEmitterTokens;
>>>  import
>>> org.apache.royale.compiler.internal.codegen.js.jx.BlockCloseEmitter;
>>>  import
>>> org.apache.royale.compiler.internal.codegen.js.jx.BlockOpenEmitter;
>>>  import org.apache.royale.compiler.internal.codegen.js.jx.CatchEmitter;
>>> @@ -914,7 +915,19 @@ public class JSEmitter extends ASEmitter implements
>>> IJSEmitter
>>>                 {
>>>                         write(coercionStart);
>>>          }
>>> -        emitAssignedValue(assignedNode);
>>> +               if
>>> (project.getBuiltinType(BuiltinType.FUNCTION).equals(definition) &&
>>> +                               assignedNode instanceof
>>> MemberAccessExpressionNode) {
>>> +                       write(JSGoogEmitterTokens.GOOG_BIND.getToken() +
>>> +
>>>  ASEmitterTokens.PAREN_OPEN.getToken()
>>> +                       );
>>> +                       emitAssignedValue(assignedNode);
>>> +                       write(ASEmitterTokens.COMMA.getToken());
>>> +                       MemberAccessExpressionNode maenode =
>>> (MemberAccessExpressionNode)assignedNode;
>>> +                       getWalker().walk(maenode.getLeftOperandNode());
>>> +                       write(ASEmitterTokens.PAREN_CLOSE.getToken());
>>> +               } else {
>>> +                       emitAssignedValue(assignedNode);
>>> +               }
>>>                 if (coercionStart != null)
>>>                 {
>>>                         if (coercionEnd != null)
>>>
>>>

Re: [royale-compiler] 01/01: Works on given test case. Hope I didn't break anything.

Posted by Greg Dove <gr...@gmail.com>.
You might find a place in the code where there is something already that
has 'needClosure' logic, but the logic that sets it to true does not yet
include the specific case you are dealing with.

On Mon, Apr 6, 2020 at 8:53 AM Greg Dove <gr...@gmail.com> wrote:

> I think it's a great start Yishay. But I'd suggest you look for other
> areas of the compiler code where there is a generation of Language.closure
> output. This should do the same thing I think, but be consistent.
>
>
> On Mon, Apr 6, 2020 at 8:51 AM <yi...@apache.org> wrote:
>
>> This is an automated email from the ASF dual-hosted git repository.
>>
>> yishayw pushed a commit to branch issue_143
>> in repository https://gitbox.apache.org/repos/asf/royale-compiler.git
>>
>> commit 634cb4f3362c75317538ba0daedafd19742d00df
>> Author: DESKTOP-RH4S838\Yishay <yi...@hotmail.com>
>> AuthorDate: Sun Apr 5 23:48:11 2020 +0300
>>
>>     Works on given test case. Hope I didn't break anything.
>>
>>     Reference #143
>> ---
>>  .../royale/compiler/internal/codegen/js/JSEmitter.java    | 15
>> ++++++++++++++-
>>  1 file changed, 14 insertions(+), 1 deletion(-)
>>
>> diff --git
>> a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/JSEmitter.java
>> b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/JSEmitter.java
>> index d24adca..24c65f3 100644
>> ---
>> a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/JSEmitter.java
>> +++
>> b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/JSEmitter.java
>> @@ -40,6 +40,7 @@ import
>> org.apache.royale.compiler.definitions.metadata.IMetaTag;
>>  import org.apache.royale.compiler.definitions.metadata.IMetaTagAttribute;
>>  import org.apache.royale.compiler.internal.codegen.as.ASEmitter;
>>  import org.apache.royale.compiler.internal.codegen.as.ASEmitterTokens;
>> +import
>> org.apache.royale.compiler.internal.codegen.js.goog.JSGoogEmitterTokens;
>>  import
>> org.apache.royale.compiler.internal.codegen.js.jx.BlockCloseEmitter;
>>  import
>> org.apache.royale.compiler.internal.codegen.js.jx.BlockOpenEmitter;
>>  import org.apache.royale.compiler.internal.codegen.js.jx.CatchEmitter;
>> @@ -914,7 +915,19 @@ public class JSEmitter extends ASEmitter implements
>> IJSEmitter
>>                 {
>>                         write(coercionStart);
>>          }
>> -        emitAssignedValue(assignedNode);
>> +               if
>> (project.getBuiltinType(BuiltinType.FUNCTION).equals(definition) &&
>> +                               assignedNode instanceof
>> MemberAccessExpressionNode) {
>> +                       write(JSGoogEmitterTokens.GOOG_BIND.getToken() +
>> +
>>  ASEmitterTokens.PAREN_OPEN.getToken()
>> +                       );
>> +                       emitAssignedValue(assignedNode);
>> +                       write(ASEmitterTokens.COMMA.getToken());
>> +                       MemberAccessExpressionNode maenode =
>> (MemberAccessExpressionNode)assignedNode;
>> +                       getWalker().walk(maenode.getLeftOperandNode());
>> +                       write(ASEmitterTokens.PAREN_CLOSE.getToken());
>> +               } else {
>> +                       emitAssignedValue(assignedNode);
>> +               }
>>                 if (coercionStart != null)
>>                 {
>>                         if (coercionEnd != null)
>>
>>

Re: [royale-compiler] 01/01: Works on given test case. Hope I didn't break anything.

Posted by Greg Dove <gr...@gmail.com>.
I think it's a great start Yishay. But I'd suggest you look for other areas
of the compiler code where there is a generation of Language.closure
output. This should do the same thing I think, but be consistent.


On Mon, Apr 6, 2020 at 8:51 AM <yi...@apache.org> wrote:

> This is an automated email from the ASF dual-hosted git repository.
>
> yishayw pushed a commit to branch issue_143
> in repository https://gitbox.apache.org/repos/asf/royale-compiler.git
>
> commit 634cb4f3362c75317538ba0daedafd19742d00df
> Author: DESKTOP-RH4S838\Yishay <yi...@hotmail.com>
> AuthorDate: Sun Apr 5 23:48:11 2020 +0300
>
>     Works on given test case. Hope I didn't break anything.
>
>     Reference #143
> ---
>  .../royale/compiler/internal/codegen/js/JSEmitter.java    | 15
> ++++++++++++++-
>  1 file changed, 14 insertions(+), 1 deletion(-)
>
> diff --git
> a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/JSEmitter.java
> b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/JSEmitter.java
> index d24adca..24c65f3 100644
> ---
> a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/JSEmitter.java
> +++
> b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/JSEmitter.java
> @@ -40,6 +40,7 @@ import
> org.apache.royale.compiler.definitions.metadata.IMetaTag;
>  import org.apache.royale.compiler.definitions.metadata.IMetaTagAttribute;
>  import org.apache.royale.compiler.internal.codegen.as.ASEmitter;
>  import org.apache.royale.compiler.internal.codegen.as.ASEmitterTokens;
> +import
> org.apache.royale.compiler.internal.codegen.js.goog.JSGoogEmitterTokens;
>  import
> org.apache.royale.compiler.internal.codegen.js.jx.BlockCloseEmitter;
>  import org.apache.royale.compiler.internal.codegen.js.jx.BlockOpenEmitter;
>  import org.apache.royale.compiler.internal.codegen.js.jx.CatchEmitter;
> @@ -914,7 +915,19 @@ public class JSEmitter extends ASEmitter implements
> IJSEmitter
>                 {
>                         write(coercionStart);
>          }
> -        emitAssignedValue(assignedNode);
> +               if
> (project.getBuiltinType(BuiltinType.FUNCTION).equals(definition) &&
> +                               assignedNode instanceof
> MemberAccessExpressionNode) {
> +                       write(JSGoogEmitterTokens.GOOG_BIND.getToken() +
> +
>  ASEmitterTokens.PAREN_OPEN.getToken()
> +                       );
> +                       emitAssignedValue(assignedNode);
> +                       write(ASEmitterTokens.COMMA.getToken());
> +                       MemberAccessExpressionNode maenode =
> (MemberAccessExpressionNode)assignedNode;
> +                       getWalker().walk(maenode.getLeftOperandNode());
> +                       write(ASEmitterTokens.PAREN_CLOSE.getToken());
> +               } else {
> +                       emitAssignedValue(assignedNode);
> +               }
>                 if (coercionStart != null)
>                 {
>                         if (coercionEnd != null)
>
>