You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@royale.apache.org by Harbs <ha...@gmail.com> on 2018/12/24 22:55:37 UTC
Re: [GitHub] Harbs commented on issue #69: compiler omits expressions
with dynamic object access
I tried stepping through the code to see what’s going on.
In VarDeclarationEmitter.emit():
IDefinition leftDef = dyn.getLeftOperandNode().resolveType(getProject());
dyn.getLeftOperandNode() is a MemberAccessExpressionNode of “.” With two sub-nodes of type IdentifierNode. The first is “object” and the second is “coordinate”.
resolveType() on that returns null. It seems to go up the scope and as best as I could understand it seems to be trying to resolve it to a member of a class rather than a member of an object literal. But I’m not sure I was understanding what’s going on…
I don’t know if this is helpful, but I know that I’m confused… ;-)
Harbs
> On Dec 24, 2018, at 8:40 PM, GitBox <gi...@apache.org> wrote:
>
> Harbs commented on issue #69: compiler omits expressions with dynamic object access
> URL: https://github.com/apache/royale-compiler/issues/69#issuecomment-449762572
>
>
> Interesting.
>
> I tried adding the code to an MXML file and I get a NullPointerException.
>
> ````
> <?xml version="1.0" encoding="utf-8"?>
>
> <js:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
> xmlns:js="library://ns.apache.org/royale/basic" xmlns:ns1="*" applicationComplete="onComplete()">
> <fx:Script>
> <![CDATA[
> import org.apache.royale.test.Assert;
>
> private function onComplete():void{
> var object: Object = { coordinate : [ 10, 20 ] };
> var x: Number = object.coordinate[0];
> Assert.strictEqual(x, 10);
> trace("OK");
> }
> ]]>
> </fx:Script>
> <js:valuesImpl>
> <js:SimpleCSSValuesImpl />
> </js:valuesImpl>
> <js:initialView>
> <js:View>
> <js:TextButton text="Click Me"/>
> </js:View>
> </js:initialView>
> </js:Application>
> ````
> Outputs:
> ````
> test_project as: [test_project, org.apache.royale.test.Assert]
> test_project mxml: [org.apache.royale.core.SimpleCSSValuesImpl, org.apache.royale.core.View, org.apache.royale.html.TextButton, test_project, org.apache.royale.core.Application, org.apache.royale.events.Event]
> /test_project/src/test_project.mxml line 11 column 16 Error: Internal error in ASBlockWalker subsystem, when generating code for: /test_project/src/test_project.mxml line 11 column 16: java.lang.NullPointerException
> at org.apache.royale.compiler.internal.codegen.js.jx.VarDeclarationEmitter.emit(VarDeclarationEmitter.java:159)
> at org.apache.royale.compiler.internal.codegen.js.royale.JSRoyaleEmitter.emitVarDeclaration(JSRoyaleEmitter.java:716)
> at org.apache.royale.compiler.internal.codegen.as.ASBlockWalker.visitVariable(ASBlockWalker.java:278)
> at org.apache.royale.compiler.internal.visitor.as.ASNodeSwitch.handle(ASNodeSwitch.java:162)
> at org.apache.royale.compiler.internal.visitor.as.ASNodeHandler.handle(ASNodeHandler.java:85)
> at org.apache.royale.compiler.internal.visitor.as.BeforeAfterStrategy.handle(BeforeAfterStrategy.java:110)
> at org.apache.royale.compiler.internal.codegen.as.ASBlockWalker.walk(ASBlockWalker.java:159)
> at org.apache.royale.compiler.internal.codegen.js.jx.StatementEmitter.emit(StatementEmitter.java:40)
> at org.apache.royale.compiler.internal.codegen.js.jx.StatementEmitter.emit(StatementEmitter.java:29)
> at org.apache.royale.compiler.internal.codegen.js.JSEmitter.emitStatement(JSEmitter.java:323)
> at org.apache.royale.compiler.internal.codegen.js.royale.JSRoyaleEmitter.emitStatement(JSRoyaleEmitter.java:1004)
> at org.apache.royale.compiler.internal.codegen.as.ASBlockWalker.visitBlock(ASBlockWalker.java:349)
> at org.apache.royale.compiler.internal.visitor.as.ASNodeSwitch.handle(ASNodeSwitch.java:278)
> at org.apache.royale.compiler.internal.visitor.as.ASNodeHandler.handle(ASNodeHandler.java:85)
> at org.apache.royale.compiler.internal.visitor.as.BeforeAfterStrategy.handle(BeforeAfterStrategy.java:110)
> at org.apache.royale.compiler.internal.codegen.as.ASBlockWalker.walk(ASBlockWalker.java:159)
> at org.apache.royale.compiler.internal.codegen.as.ASEmitter.emitMethodScope(ASEmitter.java:867)
> at org.apache.royale.compiler.internal.codegen.js.jx.MethodEmitter.emit(MethodEmitter.java:145)
> at org.apache.royale.compiler.internal.codegen.js.royale.JSRoyaleEmitter.emitMethod(JSRoyaleEmitter.java:740)
> at org.apache.royale.compiler.internal.codegen.as.ASBlockWalker.visitFunction(ASBlockWalker.java:290)
> at org.apache.royale.compiler.internal.visitor.as.ASNodeSwitch.handle(ASNodeSwitch.java:152)
> at org.apache.royale.compiler.internal.visitor.as.ASNodeHandler.handle(ASNodeHandler.java:85)
> at org.apache.royale.compiler.internal.visitor.as.BeforeAfterStrategy.handle(BeforeAfterStrategy.java:110)
> at org.apache.royale.compiler.internal.codegen.as.ASBlockWalker.walk(ASBlockWalker.java:159)
> at org.apache.royale.compiler.internal.codegen.mxml.royale.MXMLRoyaleEmitter.emitScripts(MXMLRoyaleEmitter.java:1750)
> at org.apache.royale.compiler.internal.codegen.mxml.royale.MXMLRoyaleEmitter.emitDocument(MXMLRoyaleEmitter.java:709)
> at org.apache.royale.compiler.internal.codegen.mxml.royale.MXMLRoyaleBlockWalker.visitDocument(MXMLRoyaleBlockWalker.java:69)
> at org.apache.royale.compiler.internal.visitor.mxml.MXMLNodeSwitch.handle(MXMLNodeSwitch.java:86)
> at org.apache.royale.compiler.internal.codegen.mxml.MXMLBlockWalker.walk(MXMLBlockWalker.java:153)
> at org.apache.royale.compiler.internal.codegen.mxml.royale.MXMLRoyaleBlockWalker.visitFile(MXMLRoyaleBlockWalker.java:61)
> at org.apache.royale.compiler.internal.visitor.mxml.MXMLNodeSwitch.handle(MXMLNodeSwitch.java:92)
> at org.apache.royale.compiler.internal.codegen.mxml.MXMLBlockWalker.walk(MXMLBlockWalker.java:153)
> at org.apache.royale.compiler.internal.codegen.mxml.MXMLBlockWalker.visitCompilationUnit(MXMLBlockWalker.java:184)
> at org.apache.royale.compiler.internal.codegen.mxml.MXMLWriter.writeTo(MXMLWriter.java:71)
> at org.apache.royale.compiler.clients.MXMLJSCRoyale.compile(MXMLJSCRoyale.java:411)
> at org.apache.royale.compiler.clients.MXMLJSCRoyale._mainNoExit(MXMLJSCRoyale.java:265)
> at org.apache.royale.compiler.clients.MXMLJSCRoyale.mainNoExit(MXMLJSCRoyale.java:222)
> at org.apache.royale.compiler.clients.MXMLJSC._mainNoExit(MXMLJSC.java:365)
> at org.apache.royale.compiler.clients.MXMLJSC.mainNoExit(MXMLJSC.java:300)
> at org.apache.royale.compiler.clients.MXMLJSC.staticMainNoExit(MXMLJSC.java:259)
> at org.apache.royale.compiler.clients.MXMLJSC.main(MXMLJSC.java:241)
> ````
>
> ----------------------------------------------------------------
> This is an automated message from the Apache Git Service.
> To respond to the message, please log on GitHub and use the
> URL above to go to the specific comment.
>
> For queries about this service, please contact Infrastructure at:
> users@infra.apache.org
>
>
> With regards,
> Apache Git Services