You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by jw...@apache.org on 2017/07/08 19:29:03 UTC

[1/2] groovy git commit: GROOVY-8222: Setting Source Position in newly created PropertyExpression (closes #559)

Repository: groovy
Updated Branches:
  refs/heads/GROOVY_2_5_X 1e36ffc9a -> ebebbddc8


GROOVY-8222: Setting Source Position in newly created PropertyExpression (closes #559)


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/ebebbddc
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/ebebbddc
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/ebebbddc

Branch: refs/heads/GROOVY_2_5_X
Commit: ebebbddc8f4eb314211409571b6867ed03e3c37b
Parents: e0575e6
Author: Arsen Babakhanyan <ar...@gmail.com>
Authored: Sun Jun 11 18:06:29 2017 +0400
Committer: John Wagenleitner <jw...@apache.org>
Committed: Sat Jul 8 12:28:21 2017 -0700

----------------------------------------------------------------------
 .../org/codehaus/groovy/classgen/AsmClassGenerator.java   | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/ebebbddc/src/main/org/codehaus/groovy/classgen/AsmClassGenerator.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/classgen/AsmClassGenerator.java b/src/main/org/codehaus/groovy/classgen/AsmClassGenerator.java
index 68be508..6f50af8 100644
--- a/src/main/org/codehaus/groovy/classgen/AsmClassGenerator.java
+++ b/src/main/org/codehaus/groovy/classgen/AsmClassGenerator.java
@@ -1219,7 +1219,7 @@ public class AsmClassGenerator extends ClassGenerator {
 
         BytecodeVariable variable = controller.getCompileStack().getVariable(variableName, false);
         if (variable == null) {
-            processClassVariable(variableName);
+            processClassVariable(expression);
         } else {
             controller.getOperandStack().loadOrStoreVariable(variable, expression.isUseReferenceDirectly());
         }
@@ -1243,7 +1243,7 @@ public class AsmClassGenerator extends ClassGenerator {
         }
     }
 
-    private void processClassVariable(String name) {
+    private void processClassVariable(VariableExpression expression) {
         if (passingParams && controller.isInScriptBody()) {
             //TODO: check if this part is actually used
             MethodVisitor mv = controller.getMethodVisitor();
@@ -1252,11 +1252,13 @@ public class AsmClassGenerator extends ClassGenerator {
             mv.visitInsn(DUP);
 
             loadThisOrOwner();
-            mv.visitLdcInsn(name);
+            mv.visitLdcInsn(expression.getName());
 
             mv.visitMethodInsn(INVOKESPECIAL, "org/codehaus/groovy/runtime/ScriptReference", "<init>", "(Lgroovy/lang/Script;Ljava/lang/String;)V", false);
         } else {
-            PropertyExpression pexp = new PropertyExpression(new VariableExpression("this"), name);
+            PropertyExpression pexp = new PropertyExpression(new VariableExpression("this"), expression.getName());
+            pexp.getObjectExpression().setSourcePosition(expression);
+            pexp.getProperty().setSourcePosition(expression);
             pexp.setImplicitThis(true);
             visitPropertyExpression(pexp);
         }


[2/2] groovy git commit: cache CALL_TYPES values for read-only access

Posted by jw...@apache.org.
cache CALL_TYPES values for read-only access

Avoid array allocations done by the compiler generated
Enum.values() method.


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/e0575e66
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/e0575e66
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/e0575e66

Branch: refs/heads/GROOVY_2_5_X
Commit: e0575e661095e219637e88e9be382a7b895db5b3
Parents: 1e36ffc
Author: John Wagenleitner <jw...@apache.org>
Authored: Sat Jul 8 12:09:47 2017 -0700
Committer: John Wagenleitner <jw...@apache.org>
Committed: Sat Jul 8 12:28:21 2017 -0700

----------------------------------------------------------------------
 src/main/org/codehaus/groovy/vmplugin/v7/Selector.java | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/e0575e66/src/main/org/codehaus/groovy/vmplugin/v7/Selector.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/vmplugin/v7/Selector.java b/src/main/org/codehaus/groovy/vmplugin/v7/Selector.java
index df388a8..f2bda52 100644
--- a/src/main/org/codehaus/groovy/vmplugin/v7/Selector.java
+++ b/src/main/org/codehaus/groovy/vmplugin/v7/Selector.java
@@ -88,11 +88,14 @@ public abstract class Selector {
     public boolean catchException = true;
     public CALL_TYPES callType;
 
+    /** Cache values for read-only access */
+    private static final CALL_TYPES[] CALL_TYPES_VALUES = CALL_TYPES.values();
+
     /**
      * Returns the Selector
      */
     public static Selector getSelector(MutableCallSite callSite, Class sender, String methodName, int callID, boolean safeNavigation, boolean thisCall, boolean spreadCall, Object[] arguments) {
-        CALL_TYPES callType = CALL_TYPES.values()[callID];
+        CALL_TYPES callType = CALL_TYPES_VALUES[callID];
         switch (callType) {
             case INIT: return new InitSelector(callSite, sender, methodName, callType, safeNavigation, thisCall, spreadCall, arguments);
             case METHOD: return new MethodSelector(callSite, sender, methodName, callType, safeNavigation, thisCall, spreadCall, arguments);