You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by jo...@apache.org on 2021/02/18 23:15:15 UTC

[royale-compiler] branch develop updated (daad508 -> 2c48598)

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

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


    from daad508  build: add playerglobal-source-gen
     new efae99e  ASScope: improved assertion messages for incorrect qname as base name to show the qname
     new e38ce64  ABCGenerator: fix issue where the return type of a native method incorrectly set a qname as the base name, instead of separating out the package into a namespace
     new 2fb42a7  ABCGenerator: fix issue where native methods did not include default argument values in bytecode
     new 3209bb1  playerglobal-source-gen: wrong maven dependency
     new 1c76d57  playerglobal-source-gen: merge parameters when there are multiple constructors
     new 870f3ca  playerglobal-source-gen: special case for XML/XMLList constructors
     new 70c1c9a  playerglobal-source-gen: fix issue where XML/XMLList methods should accept * instead of a specific type
     new 2c48598  playerglobal-source-gen: object methods on prototype

The 8 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:
 .../compiler/internal/as/codegen/ABCGenerator.java |  19 +-
 .../royale/compiler/internal/scopes/ASScope.java   |   6 +-
 playerglobal-source-gen/pom.xml                    |   2 +-
 .../royale/playerglobal/PlayerglobalSourceGen.java | 245 +++++++++++++++++----
 4 files changed, 227 insertions(+), 45 deletions(-)


[royale-compiler] 03/08: ABCGenerator: fix issue where native methods did not include default argument values in bytecode

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

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

commit 2fb42a768c19a8bf3d53c442ac0751cbe1404f3d
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Thu Feb 18 10:17:22 2021 -0800

    ABCGenerator: fix issue where native methods did not include default argument values in bytecode
---
 .../apache/royale/compiler/internal/as/codegen/ABCGenerator.java    | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/compiler/src/main/java/org/apache/royale/compiler/internal/as/codegen/ABCGenerator.java b/compiler/src/main/java/org/apache/royale/compiler/internal/as/codegen/ABCGenerator.java
index bfca01a..14c75c1 100644
--- a/compiler/src/main/java/org/apache/royale/compiler/internal/as/codegen/ABCGenerator.java
+++ b/compiler/src/main/java/org/apache/royale/compiler/internal/as/codegen/ABCGenerator.java
@@ -262,6 +262,9 @@ public class ABCGenerator implements ICodeGenerator
         MethodInfo mi = createMethodInfo(enclosing_scope, func, alternate_name);
         if (mi.isNative())
         {
+            // previous versions didn't add the default argument values to
+            // native methods, but that led to broken signatures -JT
+            mi = createMethodInfoWithOptionalDefaultArgumentValues(enclosing_scope, func, true, alternate_name);
             generateNativeMethod(func, mi, enclosing_scope);
         }
         else
@@ -294,6 +297,9 @@ public class ABCGenerator implements ICodeGenerator
         MethodInfo mi = createMethodInfo(enclosing_scope, func, null);
         if (mi.isNative())
         {
+            // previous versions didn't add the default argument values to
+            // native methods, but that led to broken signatures -JT
+            mi = createMethodInfoWithOptionalDefaultArgumentValues(enclosing_scope, func, true, null);
             generateNativeMethod(func, mi, enclosing_scope);
             return new GenerateFunctionInParallelResult(Futures.immediateFuture(null), mi, Collections.<IVisitor>emptyList());
         }


[royale-compiler] 05/08: playerglobal-source-gen: merge parameters when there are multiple constructors

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

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

commit 1c76d573d93d1eecf7be0f5180b2a4c11986da3f
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Thu Feb 18 11:30:44 2021 -0800

    playerglobal-source-gen: merge parameters when there are multiple constructors
---
 .../royale/playerglobal/PlayerglobalSourceGen.java | 181 ++++++++++++++++++---
 1 file changed, 160 insertions(+), 21 deletions(-)

diff --git a/playerglobal-source-gen/src/main/java/org/apache/royale/playerglobal/PlayerglobalSourceGen.java b/playerglobal-source-gen/src/main/java/org/apache/royale/playerglobal/PlayerglobalSourceGen.java
index 8b0aa7a..e58e160 100644
--- a/playerglobal-source-gen/src/main/java/org/apache/royale/playerglobal/PlayerglobalSourceGen.java
+++ b/playerglobal-source-gen/src/main/java/org/apache/royale/playerglobal/PlayerglobalSourceGen.java
@@ -31,6 +31,7 @@ import java.util.Set;
 
 import org.apache.commons.io.FileUtils;
 import org.dom4j.Document;
+import org.dom4j.DocumentHelper;
 import org.dom4j.Element;
 import org.dom4j.io.SAXReader;
 
@@ -285,7 +286,7 @@ class PlayerglobalSourceGen {
 			isDynamic = true;
 		}
 
-		Element apiConstructorElement = apiClassifierElement.element("apiConstructor");
+		List<Element> apiConstructorElements = apiClassifierElement.elements("apiConstructor");
 		List<Element> apiOperationElements = apiClassifierElement.elements("apiOperation");
 		List<Element> apiValueElements = apiClassifierElement.elements("apiValue");
 
@@ -332,8 +333,8 @@ class PlayerglobalSourceGen {
 		classBuilder.append(" ");
 		classBuilder.append("{");
 		classBuilder.append("\n");
-		if (apiConstructorElement != null) {
-			parseConstructor(apiConstructorElement, className, classBuilder);
+		if (apiConstructorElements.size() > 0) {
+			parseConstructor(apiConstructorElements, className, classBuilder);
 		}
 		for (Element apiOperationElement : apiOperationElements) {
 			parseFunction(apiOperationElement, className, false, classBuilder);
@@ -754,28 +755,34 @@ class PlayerglobalSourceGen {
 		functionBuilder.append("\n");
 	}
 
-	private void parseConstructor(Element apiConstructorElement, String contextClassName, StringBuilder functionBuilder)
-			throws Exception {
-		String constructorName = contextClassName != null ? contextClassName
-				: apiConstructorElement.element("apiName").getTextTrim();
-
+	private void parseConstructor(List<Element> apiConstructorElements, String contextClassName,
+			StringBuilder functionBuilder) throws Exception {
+		String constructorName = contextClassName;
 		String access = null;
+		List<Element> apiParamElements = null;
 
-		Element apiConstructorDetailElement = apiConstructorElement.element("apiConstructorDetail");
-		if (apiConstructorDetailElement == null) {
-			throw new Exception("apiConstructorDetail not found for: " + constructorName);
-		}
-		Element apiConstructorDefElement = apiConstructorDetailElement.element("apiConstructorDef");
-		if (apiConstructorDefElement == null) {
-			throw new Exception("apiConstructorDef not found for: " + constructorName);
-		}
+		for (Element apiConstructorElement : apiConstructorElements) {
+			if (constructorName == null) {
+				constructorName = apiConstructorElement.element("apiName").getTextTrim();
+			}
 
-		Element apiAccessElement = apiConstructorDefElement.element("apiAccess");
-		if (apiAccessElement != null) {
-			access = apiAccessElement.attributeValue("value");
-		}
+			Element apiConstructorDetailElement = apiConstructorElement.element("apiConstructorDetail");
+			if (apiConstructorDetailElement == null) {
+				throw new Exception("apiConstructorDetail not found for: " + constructorName);
+			}
+			Element apiConstructorDefElement = apiConstructorDetailElement.element("apiConstructorDef");
+			if (apiConstructorDefElement == null) {
+				throw new Exception("apiConstructorDef not found for: " + constructorName);
+			}
 
-		List<Element> apiParamElements = apiConstructorDefElement.elements("apiParam");
+			Element apiAccessElement = apiConstructorDefElement.element("apiAccess");
+			if (apiAccessElement != null) {
+				access = apiAccessElement.attributeValue("value");
+			}
+
+			List<Element> newApiParamElements = apiConstructorDefElement.elements("apiParam");
+			apiParamElements = mergeParameters(apiParamElements, newApiParamElements);
+		}
 
 		functionBuilder.append("\t");
 		if (access != null && access.length() > 0) {
@@ -792,6 +799,138 @@ class PlayerglobalSourceGen {
 		functionBuilder.append("\n");
 	}
 
+	private List<Element> mergeParameters(List<Element> apiParamElements1, List<Element> apiParamElements2)
+			throws Exception {
+		if (apiParamElements1 == null) {
+			return apiParamElements2;
+		}
+		if (apiParamElements2 == null) {
+			return apiParamElements1;
+		}
+		ArrayList<Element> result = new ArrayList<Element>();
+		for (int i = 0, count = Math.max(apiParamElements1.size(), apiParamElements2.size()); i < count; i++) {
+			Element apiParamElement1 = (apiParamElements1.size() > i) ? apiParamElements1.get(i) : null;
+			Element apiParamElement2 = (apiParamElements2.size() > i) ? apiParamElements2.get(i) : null;
+			if (apiParamElement1 == null) {
+				Element apiDataElement2 = apiParamElement2.element("apiData");
+				if (apiDataElement2 == null) {
+					apiDataElement2 = DocumentHelper.createElement("apiData");
+					apiDataElement2.setText("null");
+					apiParamElement2.add(apiDataElement2);
+				}
+				boolean isRest = false;
+				Element apiTypeElement2 = apiParamElement2.element("apiType");
+				if (apiTypeElement2 != null) {
+					String apiTypeValue2 = apiTypeElement2.attributeValue("value");
+					if ("restParam".equals(apiTypeValue2)) {
+						isRest = true;
+					}
+					apiParamElement2.remove(apiTypeElement2);
+				}
+				apiTypeElement2 = DocumentHelper.createElement("apiType");
+				if (isRest) {
+					apiTypeElement2.addAttribute("value", "restParam");
+				} else {
+					apiTypeElement2.addAttribute("value", "any");
+				}
+				apiParamElement2.add(apiTypeElement2);
+				Element apiOperationClassifierElement2 = apiParamElement2.element("apiOperationClassifier");
+				if (apiOperationClassifierElement2 != null) {
+					apiParamElement2.remove(apiOperationClassifierElement2);
+				}
+				result.add(apiParamElement2);
+				if (isRest) {
+					//nothing after rest
+					break;
+				}
+				continue;
+			}
+			if (apiParamElement2 == null) {
+				Element apiDataElement1 = apiParamElement1.element("apiData");
+				if (apiDataElement1 == null) {
+					apiDataElement1 = DocumentHelper.createElement("apiData");
+					apiDataElement1.setText("null");
+					apiParamElement1.add(apiDataElement1);
+				}
+				boolean isRest = false;
+				Element apiTypeElement1 = apiParamElement1.element("apiType");
+				if (apiTypeElement1 != null) {
+					String apiTypeValue1 = apiTypeElement1.attributeValue("value");
+					if ("restParam".equals(apiTypeValue1)) {
+						isRest = true;
+					}
+					apiParamElement1.remove(apiTypeElement1);
+				}
+				apiTypeElement1 = DocumentHelper.createElement("apiType");
+				if (isRest) {
+					apiTypeElement1.addAttribute("value", "restParam");
+				} else {
+					apiTypeElement1.addAttribute("value", "any");
+				}
+				apiParamElement1.add(apiTypeElement1);
+				Element apiOperationClassifierElement1 = apiParamElement1.element("apiOperationClassifier");
+				if (apiOperationClassifierElement1 != null) {
+					apiParamElement1.remove(apiOperationClassifierElement1);
+				}
+				result.add(apiParamElement1);
+				if (isRest) {
+					//nothing after rest
+					break;
+				}
+				continue;
+			}
+
+			String paramName = "param" + i;
+			boolean isRest = false;
+			Element apiTypeElement1 = apiParamElement1.element("apiType");
+			if (apiTypeElement1 != null) {
+				String apiTypeValue1 = apiTypeElement1.attributeValue("value");
+				if ("restParam".equals(apiTypeValue1)) {
+					isRest = true;
+					Element apiItemNameElement1 = apiParamElement1.element("apiItemName");
+					if (apiItemNameElement1 != null) {
+						//keep the existing name
+						paramName = apiItemNameElement1.getTextTrim();
+					}
+				}
+			}
+			Element apiTypeElement2 = apiParamElement2.element("apiType");
+			if (apiTypeElement2 != null) {
+				String apiTypeValue2 = apiTypeElement2.attributeValue("value");
+				if ("restParam".equals(apiTypeValue2)) {
+					isRest = true;
+					Element apiItemNameElement2 = apiParamElement2.element("apiItemName");
+					if (apiItemNameElement2 != null) {
+						//keep the existing name
+						paramName = apiItemNameElement2.getTextTrim();
+					}
+				}
+			}
+			Element newApiParamElement = DocumentHelper.createElement("apiParam");
+			Element apiItemNameElement = DocumentHelper.createElement("apiItemName");
+			apiItemNameElement.setText(paramName);
+			newApiParamElement.add(apiItemNameElement);
+			Element newApiTypeElement = DocumentHelper.createElement("apiType");
+			if (isRest) {
+				newApiTypeElement.addAttribute("value", "restParam");
+			} else {
+				newApiTypeElement.addAttribute("value", "any");
+			}
+			newApiParamElement.add(newApiTypeElement);
+			if (!isRest) {
+				Element newApiDataElement = DocumentHelper.createElement("apiData");
+				newApiDataElement.setText("null");
+				newApiParamElement.add(newApiDataElement);
+			}
+			result.add(newApiParamElement);
+			if (isRest) {
+				//nothing after rest
+				break;
+			}
+		}
+		return result;
+	}
+
 	private String parseReturnOrParamType(Element apiTypeElement, String contextClassName) throws Exception {
 		String apiTypeValue = apiTypeElement.attributeValue("value");
 		if ("restParam".equals(apiTypeValue)) {


[royale-compiler] 07/08: playerglobal-source-gen: fix issue where XML/XMLList methods should accept * instead of a specific type

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

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

commit 70c1c9a610da2518634515f759240f3f413775ef
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Thu Feb 18 12:49:00 2021 -0800

    playerglobal-source-gen: fix issue where XML/XMLList methods should accept * instead of a specific type
    
    The docs here are wrong and don't match the compiler behavior
---
 .../apache/royale/playerglobal/PlayerglobalSourceGen.java | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/playerglobal-source-gen/src/main/java/org/apache/royale/playerglobal/PlayerglobalSourceGen.java b/playerglobal-source-gen/src/main/java/org/apache/royale/playerglobal/PlayerglobalSourceGen.java
index 88f1449..5d0ae34 100644
--- a/playerglobal-source-gen/src/main/java/org/apache/royale/playerglobal/PlayerglobalSourceGen.java
+++ b/playerglobal-source-gen/src/main/java/org/apache/royale/playerglobal/PlayerglobalSourceGen.java
@@ -67,6 +67,10 @@ class PlayerglobalSourceGen {
 	}
 
 	private static final List<String> VECTOR_SUFFIXES = Arrays.asList("$double", "$int", "$uint", "$object");
+	private static final List<String> XML_ANY_METHODS = Arrays.asList("addNamespace", "appendChild", "attribute",
+			"child", "contains", "descendants", "elements", "insertChildAfter", "insertChildBefore", "namespace",
+			"prependChild", "processingInstructions", "removeNamespace", "replace", "setChildren", "setName",
+			"setNamespace");
 
 	private File sourceFolder;
 	private File targetFolder;
@@ -958,10 +962,18 @@ class PlayerglobalSourceGen {
 		}
 	}
 
+	private boolean isXMLMethodThatNeedsParamsTypedAsAny(String contextClassName, String contextFunctionName) {
+		if (!"XML".equals(contextClassName) && !"XMLList".equals(contextClassName)) {
+			return false;
+		}
+		return XML_ANY_METHODS.contains(contextFunctionName);
+	}
+
 	private void parseParameters(List<Element> apiParamElements, String contextClassName, String contextFunctionName,
 			StringBuilder functionBuilder) throws Exception {
 		boolean isXMLConstructor = ("XML".equals(contextClassName) && "XML".equals(contextFunctionName))
 				|| ("XMLList".equals(contextClassName) && "XMLList".equals(contextFunctionName));
+		boolean forceAnyType = isXMLMethodThatNeedsParamsTypedAsAny(contextClassName, contextFunctionName);
 		for (int i = 0; i < apiParamElements.size(); i++) {
 			if (i > 0) {
 				functionBuilder.append(", ");
@@ -990,6 +1002,9 @@ class PlayerglobalSourceGen {
 					paramType = apiOperationClassifierElement.getTextTrim();
 					paramType = paramType.replace(":", ".");
 				}
+				if (forceAnyType) {
+					paramType = "*";
+				}
 				if (paramType != null) {
 					functionBuilder.append(":");
 					functionBuilder.append(paramType);


[royale-compiler] 04/08: playerglobal-source-gen: wrong maven dependency

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

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

commit 3209bb1f46b8a62dab993b7cc26704d1635dc782
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Thu Feb 18 11:29:53 2021 -0800

    playerglobal-source-gen: wrong maven dependency
---
 playerglobal-source-gen/pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/playerglobal-source-gen/pom.xml b/playerglobal-source-gen/pom.xml
index 2f7825d..4926a6f 100644
--- a/playerglobal-source-gen/pom.xml
+++ b/playerglobal-source-gen/pom.xml
@@ -78,7 +78,7 @@
       <version>2.4</version>
     </dependency>
     <dependency>
-      <groupId>org.dom4j</groupId>
+      <groupId>dom4j</groupId>
       <artifactId>dom4j</artifactId>
       <version>1.6.1</version>
     </dependency>


[royale-compiler] 06/08: playerglobal-source-gen: special case for XML/XMLList constructors

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

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

commit 870f3cab75e92a38757aa9c544ddf980a19339b6
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Thu Feb 18 11:56:33 2021 -0800

    playerglobal-source-gen: special case for XML/XMLList constructors
---
 .../royale/playerglobal/PlayerglobalSourceGen.java | 39 +++++++++++++---------
 1 file changed, 23 insertions(+), 16 deletions(-)

diff --git a/playerglobal-source-gen/src/main/java/org/apache/royale/playerglobal/PlayerglobalSourceGen.java b/playerglobal-source-gen/src/main/java/org/apache/royale/playerglobal/PlayerglobalSourceGen.java
index e58e160..88f1449 100644
--- a/playerglobal-source-gen/src/main/java/org/apache/royale/playerglobal/PlayerglobalSourceGen.java
+++ b/playerglobal-source-gen/src/main/java/org/apache/royale/playerglobal/PlayerglobalSourceGen.java
@@ -747,7 +747,7 @@ class PlayerglobalSourceGen {
 		functionBuilder.append("function ");
 		functionBuilder.append(functionName);
 		functionBuilder.append("(");
-		parseParameters(apiParamElements, contextClassName, functionBuilder);
+		parseParameters(apiParamElements, contextClassName, functionName, functionBuilder);
 		functionBuilder.append(")");
 		functionBuilder.append(":");
 		functionBuilder.append(returnType);
@@ -793,7 +793,7 @@ class PlayerglobalSourceGen {
 		functionBuilder.append("function ");
 		functionBuilder.append(constructorName);
 		functionBuilder.append("(");
-		parseParameters(apiParamElements, contextClassName, functionBuilder);
+		parseParameters(apiParamElements, contextClassName, constructorName, functionBuilder);
 		functionBuilder.append(")");
 		functionBuilder.append(";");
 		functionBuilder.append("\n");
@@ -958,8 +958,10 @@ class PlayerglobalSourceGen {
 		}
 	}
 
-	private void parseParameters(List<Element> apiParamElements, String contextClassName, StringBuilder functionBuilder)
-			throws Exception {
+	private void parseParameters(List<Element> apiParamElements, String contextClassName, String contextFunctionName,
+			StringBuilder functionBuilder) throws Exception {
+		boolean isXMLConstructor = ("XML".equals(contextClassName) && "XML".equals(contextFunctionName))
+				|| ("XMLList".equals(contextClassName) && "XMLList".equals(contextFunctionName));
 		for (int i = 0; i < apiParamElements.size(); i++) {
 			if (i > 0) {
 				functionBuilder.append(", ");
@@ -979,18 +981,23 @@ class PlayerglobalSourceGen {
 				throw new Exception("apiItemName not found");
 			}
 			functionBuilder.append(apiItemNameElement.getTextTrim());
-			Element apiOperationClassifierElement = apiParamElement.element("apiOperationClassifier");
-			if (apiOperationClassifierElement != null) {
-				paramType = apiOperationClassifierElement.getTextTrim();
-				paramType = paramType.replace(":", ".");
-			}
-			if (paramType != null) {
-				functionBuilder.append(":");
-				functionBuilder.append(paramType);
-			}
-			Element apiDataElement = apiParamElement.element("apiData");
-			if (apiDataElement != null) {
-				writeVariableOrParameterValue(apiDataElement, paramType, functionBuilder);
+			if (isXMLConstructor) {
+				//workaround for missing data in asdoc dita
+				functionBuilder.append(":* = null");
+			} else {
+				Element apiOperationClassifierElement = apiParamElement.element("apiOperationClassifier");
+				if (apiOperationClassifierElement != null) {
+					paramType = apiOperationClassifierElement.getTextTrim();
+					paramType = paramType.replace(":", ".");
+				}
+				if (paramType != null) {
+					functionBuilder.append(":");
+					functionBuilder.append(paramType);
+				}
+				Element apiDataElement = apiParamElement.element("apiData");
+				if (apiDataElement != null) {
+					writeVariableOrParameterValue(apiDataElement, paramType, functionBuilder);
+				}
 			}
 		}
 	}


[royale-compiler] 01/08: ASScope: improved assertion messages for incorrect qname as base name to show the qname

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

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

commit efae99eb7c3ba75c66ad05e42b4db7eaf6ed1763
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Thu Feb 18 10:14:34 2021 -0800

    ASScope: improved assertion messages for incorrect qname as base name to show the qname
---
 .../java/org/apache/royale/compiler/internal/scopes/ASScope.java    | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/compiler/src/main/java/org/apache/royale/compiler/internal/scopes/ASScope.java b/compiler/src/main/java/org/apache/royale/compiler/internal/scopes/ASScope.java
index faa68c3..33bcc66 100644
--- a/compiler/src/main/java/org/apache/royale/compiler/internal/scopes/ASScope.java
+++ b/compiler/src/main/java/org/apache/royale/compiler/internal/scopes/ASScope.java
@@ -1141,7 +1141,7 @@ public abstract class ASScope extends ASScopeBase
     {
 
         assert accumulator.isEmpty() : "findProperty() should not be called with a non-empty collection";
-        assert baseName.indexOf('.') == -1 : "baseName must not be any sort of qname";
+        assert baseName.indexOf('.') == -1 : "baseName must not be any sort of qname " + baseName;
 
         // Walk the scope chain starting with this scope.
         // This loop may go as far as the file scope, whose containing scope is null. 
@@ -1462,7 +1462,7 @@ public abstract class ASScope extends ASScopeBase
             // which may have already computed and cached the result.
             return getContainingScope().findProperty(project, baseName, dt, canEscapeWith);
         }
-        assert baseName.indexOf('.') == -1 : "baseName must not be any sort of qname";
+        assert baseName.indexOf('.') == -1 : "baseName must not be any sort of qname " + baseName;
         CompilerProject compilerProject = (CompilerProject)project;
         ASScopeCache scopeCache = compilerProject.getCacheForScope(this);
         return filterWith(scopeCache.findProperty(baseName, dt, canEscapeWith), canEscapeWith);
@@ -1622,7 +1622,7 @@ public abstract class ASScope extends ASScopeBase
      */
     public IDefinition findPropertyQualified(ICompilerProject project, INamespaceDefinition qual, String baseName, DependencyType dt, boolean canEscapeWith)
     {
-        assert baseName.indexOf('.') == -1 : "baseName must not be any sort of qname";
+        assert baseName.indexOf('.') == -1 : "baseName must not be any sort of qname " + baseName;
 
         // Can't find a property if we don't know what its qualifier is
         if( qual == null )


[royale-compiler] 08/08: playerglobal-source-gen: object methods on prototype

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

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

commit 2c48598960a796937351884126a2c0df7f9fca1c
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Thu Feb 18 14:06:23 2021 -0800

    playerglobal-source-gen: object methods on prototype
---
 .../org/apache/royale/playerglobal/PlayerglobalSourceGen.java  | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/playerglobal-source-gen/src/main/java/org/apache/royale/playerglobal/PlayerglobalSourceGen.java b/playerglobal-source-gen/src/main/java/org/apache/royale/playerglobal/PlayerglobalSourceGen.java
index 5d0ae34..4da3a3d 100644
--- a/playerglobal-source-gen/src/main/java/org/apache/royale/playerglobal/PlayerglobalSourceGen.java
+++ b/playerglobal-source-gen/src/main/java/org/apache/royale/playerglobal/PlayerglobalSourceGen.java
@@ -67,6 +67,9 @@ class PlayerglobalSourceGen {
 	}
 
 	private static final List<String> VECTOR_SUFFIXES = Arrays.asList("$double", "$int", "$uint", "$object");
+	//From the docs: Methods of the Object class are dynamically created on Object's prototype.
+	private static final List<String> OBJECT_PROTOTYPE_METHODS = Arrays.asList("hasOwnProperty", "isPrototypeOf",
+			"propertyIsEnumerable", "setPropertyIsEnumerable", "toString", "toLocaleString", "valueOf");
 	private static final List<String> XML_ANY_METHODS = Arrays.asList("addNamespace", "appendChild", "attribute",
 			"child", "contains", "descendants", "elements", "insertChildAfter", "insertChildBefore", "namespace",
 			"prependChild", "processingInstructions", "removeNamespace", "replace", "setChildren", "setName",
@@ -728,9 +731,10 @@ class PlayerglobalSourceGen {
 
 		List<Element> apiParamElements = apiOperationDefElement.elements("apiParam");
 
-		if ("public".equals(access) && ("toString".equals(functionName) || "toLocaleString".equals(functionName))
-				|| "valueOf".equals(functionName) || "hasOwnProperty".equals(functionName)
-				|| "propertyIsEnumerable".equals(functionName)) {
+		if ("Object".equals(contextClassName) && OBJECT_PROTOTYPE_METHODS.contains(functionName)) {
+			return;
+		}
+		if ("toString".equals(functionName) && isOverride) {
 			return;
 		}
 


[royale-compiler] 02/08: ABCGenerator: fix issue where the return type of a native method incorrectly set a qname as the base name, instead of separating out the package into a namespace

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

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

commit e38ce64d6211e147f28ccb9abb85ecbd7d4e7218
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Thu Feb 18 10:16:20 2021 -0800

    ABCGenerator: fix issue where the return type of a native method incorrectly set a qname as the base name, instead of separating out the package into a namespace
---
 .../royale/compiler/internal/as/codegen/ABCGenerator.java   | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/compiler/src/main/java/org/apache/royale/compiler/internal/as/codegen/ABCGenerator.java b/compiler/src/main/java/org/apache/royale/compiler/internal/as/codegen/ABCGenerator.java
index 7e93f95..bfca01a 100644
--- a/compiler/src/main/java/org/apache/royale/compiler/internal/as/codegen/ABCGenerator.java
+++ b/compiler/src/main/java/org/apache/royale/compiler/internal/as/codegen/ABCGenerator.java
@@ -39,6 +39,7 @@ import org.apache.royale.abc.instructionlist.InstructionList;
 import org.apache.royale.abc.semantics.MethodBodyInfo;
 import org.apache.royale.abc.semantics.MethodInfo;
 import org.apache.royale.abc.semantics.Name;
+import org.apache.royale.abc.semantics.Namespace;
 import org.apache.royale.abc.semantics.PooledValue;
 import org.apache.royale.abc.visitors.IMethodBodyVisitor;
 import org.apache.royale.abc.visitors.IMethodVisitor;
@@ -325,7 +326,17 @@ public class ABCGenerator implements ICodeGenerator
         // but for native types, as the burm isn't run, we need to set
         // the return type here.
         String returnType = func.getReturnType();
-        mi.setReturnType(new Name(returnType));
+        int lastDotIndex = returnType.lastIndexOf('.');
+        if (lastDotIndex != -1)
+        {
+            Namespace ns = new Namespace(CONSTANT_PackageNs, returnType.substring(0, lastDotIndex));
+            String baseName = returnType.substring(lastDotIndex + 1);
+            mi.setReturnType(new Name(ns, baseName));
+        }
+        else
+        {
+            mi.setReturnType(new Name(returnType));
+        }
         
         mv.visitEnd();
     }