groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject [groovy] 01/02: Trivial refactoring: Rename `CALL_TYPES` to `CallType`
Date Tue, 31 Dec 2019 16:08:22 GMT
This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 81a5966e4a90d0cdfb7c26ccd675ea9c06bbe3bd
Author: Daniel Sun <sunlan@apache.org>
AuthorDate: Tue Dec 31 22:34:36 2019 +0800

    Trivial refactoring: Rename `CALL_TYPES` to `CallType`
    
    (cherry picked from commit f6b91fd4db82ed7897fdefcd834fef2902aeb7d9)
---
 .../classgen/asm/indy/InvokeDynamicWriter.java     |  8 +--
 .../codehaus/groovy/vmplugin/v7/IndyInterface.java | 63 +++++++++++++++-------
 .../org/codehaus/groovy/vmplugin/v7/Selector.java  | 18 +++----
 3 files changed, 56 insertions(+), 33 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/classgen/asm/indy/InvokeDynamicWriter.java
b/src/main/java/org/codehaus/groovy/classgen/asm/indy/InvokeDynamicWriter.java
index d156570..a1c2876 100644
--- a/src/main/java/org/codehaus/groovy/classgen/asm/indy/InvokeDynamicWriter.java
+++ b/src/main/java/org/codehaus/groovy/classgen/asm/indy/InvokeDynamicWriter.java
@@ -44,10 +44,10 @@ import java.lang.invoke.MethodHandles.Lookup;
 import java.lang.invoke.MethodType;
 
 import static org.codehaus.groovy.classgen.asm.BytecodeHelper.getTypeDescription;
-import static org.codehaus.groovy.vmplugin.v7.IndyInterface.CALL_TYPES.CAST;
-import static org.codehaus.groovy.vmplugin.v7.IndyInterface.CALL_TYPES.GET;
-import static org.codehaus.groovy.vmplugin.v7.IndyInterface.CALL_TYPES.INIT;
-import static org.codehaus.groovy.vmplugin.v7.IndyInterface.CALL_TYPES.METHOD;
+import static org.codehaus.groovy.vmplugin.v7.IndyInterface.CallType.CAST;
+import static org.codehaus.groovy.vmplugin.v7.IndyInterface.CallType.GET;
+import static org.codehaus.groovy.vmplugin.v7.IndyInterface.CallType.INIT;
+import static org.codehaus.groovy.vmplugin.v7.IndyInterface.CallType.METHOD;
 import static org.codehaus.groovy.vmplugin.v7.IndyInterface.GROOVY_OBJECT;
 import static org.codehaus.groovy.vmplugin.v7.IndyInterface.IMPLICIT_THIS;
 import static org.codehaus.groovy.vmplugin.v7.IndyInterface.SAFE_NAVIGATION;
diff --git a/src/main/java/org/codehaus/groovy/vmplugin/v7/IndyInterface.java b/src/main/java/org/codehaus/groovy/vmplugin/v7/IndyInterface.java
index 866b45e..75c2dcd 100644
--- a/src/main/java/org/codehaus/groovy/vmplugin/v7/IndyInterface.java
+++ b/src/main/java/org/codehaus/groovy/vmplugin/v7/IndyInterface.java
@@ -52,19 +52,42 @@ public class IndyInterface {
         /**
          * Enum for easy differentiation between call types
          */
-        public enum CALL_TYPES {
-            /**Method invocation type*/         METHOD("invoke"), 
-            /**Constructor invocation type*/    INIT("init"), 
-            /**Get property invocation type*/   GET("getProperty"), 
-            /**Set property invocation type*/   SET("setProperty"),
-            /**Cast invocation type*/           CAST("cast");
-            /**The name of the call site type*/
+        public enum CallType {
+            /**
+             * Method invocation type
+             */
+            METHOD("invoke"),
+            /**
+             * Constructor invocation type
+             */
+            INIT("init"),
+            /**
+             * Get property invocation type
+             */
+            GET("getProperty"),
+            /**
+             * Set property invocation type
+             */
+            SET("setProperty"),
+            /**
+             * Cast invocation type
+             */
+            CAST("cast");
+            /**
+             * The name of the call site type
+             */
             private final String name;
-            CALL_TYPES(String callSiteName) {
+
+            CallType(String callSiteName) {
                 this.name = callSiteName;
             }
-            /** Returns the name of the call site type */
-            public String getCallSiteName(){ return name; }
+
+            /**
+             * Returns the name of the call site type
+             */
+            public String getCallSiteName() {
+                return name;
+            }
         }
 
         /** Logger */
@@ -140,16 +163,16 @@ public class IndyInterface {
             boolean thisCall = (flags&THIS_CALL)!=0;
             boolean spreadCall = (flags&SPREAD_CALL)!=0;
             int callID;
-            if (callType.equals(CALL_TYPES.METHOD.getCallSiteName())) {
-                callID = CALL_TYPES.METHOD.ordinal();
-            } else if (callType.equals(CALL_TYPES.INIT.getCallSiteName())) {
-                callID = CALL_TYPES.INIT.ordinal();
-            } else if (callType.equals(CALL_TYPES.GET.getCallSiteName())) {
-                callID = CALL_TYPES.GET.ordinal();
-            } else if (callType.equals(CALL_TYPES.SET.getCallSiteName())) {
-                callID = CALL_TYPES.SET.ordinal();
-            } else if (callType.equals(CALL_TYPES.CAST.getCallSiteName())) {
-                callID = CALL_TYPES.CAST.ordinal();
+            if (callType.equals(CallType.METHOD.getCallSiteName())) {
+                callID = CallType.METHOD.ordinal();
+            } else if (callType.equals(CallType.INIT.getCallSiteName())) {
+                callID = CallType.INIT.ordinal();
+            } else if (callType.equals(CallType.GET.getCallSiteName())) {
+                callID = CallType.GET.ordinal();
+            } else if (callType.equals(CallType.SET.getCallSiteName())) {
+                callID = CallType.SET.ordinal();
+            } else if (callType.equals(CallType.CAST.getCallSiteName())) {
+                callID = CallType.CAST.ordinal();
             }else {
                 throw new GroovyBugError("Unknown call type: "+callType);
             }
diff --git a/src/main/java/org/codehaus/groovy/vmplugin/v7/Selector.java b/src/main/java/org/codehaus/groovy/vmplugin/v7/Selector.java
index a505580..55d4ee1 100644
--- a/src/main/java/org/codehaus/groovy/vmplugin/v7/Selector.java
+++ b/src/main/java/org/codehaus/groovy/vmplugin/v7/Selector.java
@@ -51,7 +51,7 @@ import org.codehaus.groovy.runtime.metaclass.NewStaticMetaMethod;
 import org.codehaus.groovy.runtime.metaclass.ReflectionMetaMethod;
 import org.codehaus.groovy.runtime.wrappers.Wrapper;
 import org.codehaus.groovy.vmplugin.VMPluginFactory;
-import org.codehaus.groovy.vmplugin.v7.IndyInterface.CALL_TYPES;
+import org.codehaus.groovy.vmplugin.v7.IndyInterface.CallType;
 
 import java.lang.invoke.MethodHandle;
 import java.lang.invoke.MethodHandles;
@@ -113,16 +113,16 @@ public abstract class Selector {
     public boolean thisCall;
     public Class selectionBase;
     public boolean catchException = true;
-    public CALL_TYPES callType;
+    public CallType callType;
 
     /** Cache values for read-only access */
-    private static final CALL_TYPES[] CALL_TYPES_VALUES = CALL_TYPES.values();
+    private static final CallType[] CALL_TYPE_VALUES = CallType.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];
+        CallType callType = CALL_TYPE_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);
@@ -156,7 +156,7 @@ public abstract class Selector {
         private final Class<?> staticSourceType, staticTargetType;
 
         public CastSelector(MutableCallSite callSite, Object[] arguments) {
-            super(callSite, Selector.class, "", CALL_TYPES.CAST, false, false, false, arguments);
+            super(callSite, Selector.class, "", CallType.CAST, false, false, false, arguments);
             this.staticSourceType = callSite.type().parameterType(0);
             this.staticTargetType = callSite.type().returnType();
         }
@@ -279,7 +279,7 @@ public abstract class Selector {
     private static class PropertySelector extends MethodSelector {
         private boolean insertName = false;
 
-        public PropertySelector(MutableCallSite callSite, Class sender, String methodName,
CALL_TYPES callType, boolean safeNavigation, boolean thisCall, boolean spreadCall, Object[]
arguments) {
+        public PropertySelector(MutableCallSite callSite, Class sender, String methodName,
CallType callType, boolean safeNavigation, boolean thisCall, boolean spreadCall, Object[]
arguments) {
             super(callSite, sender, methodName, callType, safeNavigation, thisCall, spreadCall,
arguments);
         }
 
@@ -380,7 +380,7 @@ public abstract class Selector {
     private static class InitSelector extends MethodSelector {
         private boolean beanConstructor;
 
-        public InitSelector(MutableCallSite callSite, Class sender, String methodName, CALL_TYPES
callType, boolean safeNavigation, boolean thisCall, boolean spreadCall, Object[] arguments)
{
+        public InitSelector(MutableCallSite callSite, Class sender, String methodName, CallType
callType, boolean safeNavigation, boolean thisCall, boolean spreadCall, Object[] arguments)
{
             super(callSite, sender, methodName, callType, safeNavigation, thisCall, spreadCall,
arguments);
         }
 
@@ -504,7 +504,7 @@ public abstract class Selector {
         private static final Object[] SINGLE_NULL_ARRAY = { null };
         protected MetaClass mc;
         private boolean isCategoryMethod;
-        public MethodSelector(MutableCallSite callSite, Class sender, String methodName,
CALL_TYPES callType, Boolean safeNavigation, Boolean thisCall, Boolean spreadCall, Object[]
arguments) {
+        public MethodSelector(MutableCallSite callSite, Class sender, String methodName,
CallType callType, Boolean safeNavigation, Boolean thisCall, Boolean spreadCall, Object[]
arguments) {
             this.callType = callType;
             this.targetType = callSite.type();
             this.name = methodName;
@@ -989,7 +989,7 @@ public abstract class Selector {
                 getMetaClass();
                 if (LOG_ENABLED) LOG.info("meta class is "+mc);
                 setSelectionBase();
-                MetaClassImpl mci = getMetaClassImpl(mc, callType != CALL_TYPES.GET);
+                MetaClassImpl mci = getMetaClassImpl(mc, callType != CallType.GET);
                 chooseMeta(mci);
                 setHandleForMetaMethod();
                 setMetaClassCallHandleIfNedded(mci!=null);


Mime
View raw message