You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by gr...@apache.org on 2020/03/16 07:33:15 UTC

[royale-compiler] branch develop updated (b7751d1 -> ff8aa37)

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

gregdove pushed a change to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git.


    from b7751d1  Merge pull request #121 from chrisdutz/develop
     new 8c0b0ab  Fix a NullPointerException when handling bindings with 'this', e.g. text="{this.someBindable}"
     new ff8aa37  Match Flex for IEventDispatcher-ness with Bindable classes that receive the IEventDispatcher upgrades from the compiler.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../internal/codegen/databinding/BindingInfo.java  | 38 ++++++++++++++++------
 .../semantics/MethodBodySemanticChecker.java       | 28 +++++++++++++---
 2 files changed, 52 insertions(+), 14 deletions(-)


[royale-compiler] 01/02: Fix a NullPointerException when handling bindings with 'this', e.g. text="{this.someBindable}"

Posted by gr...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 8c0b0ab10681445543ad31cefa6008bab76cb066
Author: greg-dove <gr...@gmail.com>
AuthorDate: Mon Mar 16 19:57:40 2020 +1300

    Fix a NullPointerException when handling bindings with 'this', e.g. text="{this.someBindable}"
---
 .../internal/codegen/databinding/BindingInfo.java  | 38 ++++++++++++++++------
 1 file changed, 28 insertions(+), 10 deletions(-)

diff --git a/compiler/src/main/java/org/apache/royale/compiler/internal/codegen/databinding/BindingInfo.java b/compiler/src/main/java/org/apache/royale/compiler/internal/codegen/databinding/BindingInfo.java
index aa58aec..30c3c8d 100644
--- a/compiler/src/main/java/org/apache/royale/compiler/internal/codegen/databinding/BindingInfo.java
+++ b/compiler/src/main/java/org/apache/royale/compiler/internal/codegen/databinding/BindingInfo.java
@@ -24,6 +24,7 @@ import java.util.List;
 
 
 import org.apache.royale.compiler.common.DependencyType;
+import org.apache.royale.compiler.constants.IASKeywordConstants;
 import org.apache.royale.compiler.definitions.IAccessorDefinition;
 import org.apache.royale.compiler.definitions.IConstantDefinition;
 import org.apache.royale.compiler.definitions.IDefinition;
@@ -455,11 +456,24 @@ public class BindingInfo implements Comparable<BindingInfo>
             return;
         
         IExpressionNode expressionNodeForGetter = expressionNodesForGetter.get(0);
+        //if it is a MemberAccessExpressionNode, and the first node is Identifier 'this' , then we will only examine right operand node
+        boolean hadThis = false;
+        if (expressionNodeForGetter instanceof MemberAccessExpressionNode) {
+            if (((MemberAccessExpressionNode) expressionNodeForGetter).getLeftOperandNode() instanceof IIdentifierNode
+                && ((IIdentifierNode) ((MemberAccessExpressionNode) expressionNodeForGetter).getLeftOperandNode()).getName().equals(IASKeywordConstants.THIS)
+            ) {
+                expressionNodeForGetter = ((MemberAccessExpressionNode) expressionNodeForGetter).getRightOperandNode();
+                hadThis = true;
+            }
+        }
+
+
         if (expressionNodeForGetter instanceof IIdentifierNode)
         {
             String name = ((IIdentifierNode)expressionNodeForGetter).getName();
             IReference ref = ReferenceFactory.lexicalReference(project.getWorkspace(), name);
-            IDefinition def = ref.resolve(project, scope, DependencyType.EXPRESSION, false);
+            ASScope resolutionScope = hadThis ? ((TypeScope) scope).getInstanceScope() : scope;
+            IDefinition def = ref.resolve(project, resolutionScope, DependencyType.EXPRESSION, false);
             if (def instanceof IVariableDefinition)
             {
                 // here we have decided that the binding expression is a variable
@@ -487,7 +501,11 @@ public class BindingInfo implements Comparable<BindingInfo>
         else if (expressionNodeForGetter instanceof MemberAccessExpressionNode)
         {
         	MemberAccessExpressionNode mae = (MemberAccessExpressionNode)expressionNodeForGetter;
-            IDefinition def = mae.resolve(project);
+            IDefinition def;
+        	if (hadThis) {
+        	    def = expressionNodesForGetter.get(0).resolve(project);
+            }
+            else def = mae.resolve(project);
             if (def != null && def.isPublic() && 
             		(def instanceof IAccessorDefinition ||
             		 def instanceof IConstantDefinition ||
@@ -496,14 +514,14 @@ public class BindingInfo implements Comparable<BindingInfo>
             	IExpressionNode leftSide = mae.getLeftOperandNode();
             	if (leftSide instanceof IIdentifierNode)
             	{
-            		IDefinition leftDef = leftSide.resolve(project);
-		        	if (leftDef.isPublic())
-		        	{
-		        		if (leftDef instanceof ClassDefinition)
-		        			classDef = (ClassDefinition)leftDef;
-		        		sourceString = leftDef.getBaseName() + "." + def.getBaseName();
-		                isSimplePublicProperty = true;            		
-		        	}
+                    IDefinition leftDef = leftSide.resolve(project);
+                    if (leftDef.isPublic())
+                    {
+                        if (leftDef instanceof ClassDefinition)
+                            classDef = (ClassDefinition)leftDef;
+                        sourceString = leftDef.getBaseName() + "." + def.getBaseName();
+                        isSimplePublicProperty = true;
+                    }
             	}
             	else if (leftSide instanceof MemberAccessExpressionNode)
             	{


[royale-compiler] 02/02: Match Flex for IEventDispatcher-ness with Bindable classes that receive the IEventDispatcher upgrades from the compiler.

Posted by gr...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit ff8aa37f90c5084e7176fd5d4861276b71375b81
Author: greg-dove <gr...@gmail.com>
AuthorDate: Mon Mar 16 20:01:06 2020 +1300

    Match Flex for IEventDispatcher-ness with Bindable classes that receive the IEventDispatcher upgrades from the compiler.
---
 .../semantics/MethodBodySemanticChecker.java       | 28 ++++++++++++++++++----
 1 file changed, 24 insertions(+), 4 deletions(-)

diff --git a/compiler/src/main/java/org/apache/royale/compiler/internal/semantics/MethodBodySemanticChecker.java b/compiler/src/main/java/org/apache/royale/compiler/internal/semantics/MethodBodySemanticChecker.java
index 349a4a8..5640c8d 100644
--- a/compiler/src/main/java/org/apache/royale/compiler/internal/semantics/MethodBodySemanticChecker.java
+++ b/compiler/src/main/java/org/apache/royale/compiler/internal/semantics/MethodBodySemanticChecker.java
@@ -66,11 +66,14 @@ import org.apache.royale.compiler.definitions.ISetterDefinition;
 import org.apache.royale.compiler.definitions.ITypeDefinition;
 import org.apache.royale.compiler.definitions.IVariableDefinition;
 import org.apache.royale.compiler.definitions.references.INamespaceReference;
+import org.apache.royale.compiler.internal.as.codegen.*;
 import org.apache.royale.compiler.internal.definitions.AmbiguousDefinition;
 import org.apache.royale.compiler.internal.definitions.VariableDefinition;
+import org.apache.royale.compiler.internal.scopes.ASProjectScope;
 import org.apache.royale.compiler.problems.*;
 import org.apache.royale.compiler.projects.ICompilerProject;
 import org.apache.royale.compiler.scopes.IASScope;
+import org.apache.royale.compiler.scopes.IDefinitionSet;
 import org.apache.royale.compiler.tree.ASTNodeID;
 import org.apache.royale.compiler.tree.as.IASNode;
 import org.apache.royale.compiler.tree.as.IBinaryOperatorNode;
@@ -90,10 +93,6 @@ import org.apache.royale.compiler.tree.as.IScopedNode;
 import org.apache.royale.compiler.tree.as.ITypedExpressionNode;
 import org.apache.royale.compiler.tree.as.IUnaryOperatorNode;
 import org.apache.royale.compiler.tree.as.IVariableNode;
-import org.apache.royale.compiler.internal.as.codegen.ABCGeneratingReducer;
-import org.apache.royale.compiler.internal.as.codegen.Binding;
-import org.apache.royale.compiler.internal.as.codegen.InlineFunctionLexicalScope;
-import org.apache.royale.compiler.internal.as.codegen.LexicalScope;
 import org.apache.royale.compiler.internal.definitions.AccessorDefinition;
 import org.apache.royale.compiler.internal.definitions.ClassDefinition;
 import org.apache.royale.compiler.internal.definitions.ClassTraitsDefinition;
@@ -847,6 +846,13 @@ public class MethodBodySemanticChecker
         }
     }
 
+    private IInterfaceDefinition iEventDispatcher(){
+        String iEventDispatcherPackage = BindableHelper.NAME_IEVENT_DISPATCHER.getQualifiers().getSingleQualifier().getName();
+        String iEventDispatcherName = BindableHelper.NAME_IEVENT_DISPATCHER.getBaseName();
+        IDefinition iEventDispatcher =  ((ASProjectScope)(project.getScope())).findDefinitionByName(iEventDispatcherPackage + "." + iEventDispatcherName);
+        if (iEventDispatcher instanceof IInterfaceDefinition) return (IInterfaceDefinition) iEventDispatcher;
+        return null;
+    }
 
     /**
      *  Check a function call.
@@ -864,6 +870,19 @@ public class MethodBodySemanticChecker
         }
 
         IDefinition def = method_binding.getDefinition();
+        if (def == null) {
+            IDefinition defCheck = SemanticUtils.getDefinitionOfUnderlyingType(iNode,true, project);
+            if (defCheck instanceof IClassDefinition) {
+                //if we are adding the bindable IEventDispatcher implementation, then we should allow those IEventDispatcher methods
+                    if (((IClassDefinition)defCheck).needsEventDispatcher(project)) {
+                    IInterfaceDefinition iEventDispatcher =  iEventDispatcher();
+                    IDefinitionSet bindingMethodCheck = iEventDispatcher.getContainedScope().getLocalDefinitionSetByName( method_binding.getName().getBaseName());
+                    if (bindingMethodCheck!=null && bindingMethodCheck.getSize() == 1) {
+                        def = bindingMethodCheck.getDefinition(0);
+                    }
+                }
+            }
+        }
 
         if ( def == null && utils.definitionCanBeAnalyzed(method_binding) )
         {
@@ -878,6 +897,7 @@ public class MethodBodySemanticChecker
             }
             else if ( SemanticUtils.hasExplicitStem(iNode) && utils.hasUnderlyingType(iNode) )
             {
+
                 addProblem(new StrictUndefinedMethodProblem( 
                     roundUpUsualSuspects(method_binding, iNode), 
                     method_binding.getName().getBaseName(),