Take a look at emitClosureStart and emitClosureEnd I think those will help out.
On Mon, Apr 6, 2020 at 9:01 AM Greg Dove <[email protected]> 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 <[email protected]> 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 <[email protected]> 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 <[email protected]> >>> 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) >>> >>>
