nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/types/Type.java
equal
deleted
inserted
replaced
63 import java.util.concurrent.ConcurrentHashMap; |
63 import java.util.concurrent.ConcurrentHashMap; |
64 import java.util.concurrent.ConcurrentMap; |
64 import java.util.concurrent.ConcurrentMap; |
65 import jdk.internal.org.objectweb.asm.Handle; |
65 import jdk.internal.org.objectweb.asm.Handle; |
66 import jdk.internal.org.objectweb.asm.MethodVisitor; |
66 import jdk.internal.org.objectweb.asm.MethodVisitor; |
67 import jdk.nashorn.internal.codegen.CompilerConstants.Call; |
67 import jdk.nashorn.internal.codegen.CompilerConstants.Call; |
|
68 import jdk.nashorn.internal.runtime.Context; |
68 import jdk.nashorn.internal.runtime.ScriptObject; |
69 import jdk.nashorn.internal.runtime.ScriptObject; |
69 import jdk.nashorn.internal.runtime.Undefined; |
70 import jdk.nashorn.internal.runtime.Undefined; |
70 import jdk.nashorn.internal.runtime.linker.Bootstrap; |
71 import jdk.nashorn.internal.runtime.linker.Bootstrap; |
71 |
72 |
72 /** |
73 /** |
254 case jdk.internal.org.objectweb.asm.Type.LONG: |
255 case jdk.internal.org.objectweb.asm.Type.LONG: |
255 return LONG; |
256 return LONG; |
256 case jdk.internal.org.objectweb.asm.Type.DOUBLE: |
257 case jdk.internal.org.objectweb.asm.Type.DOUBLE: |
257 return NUMBER; |
258 return NUMBER; |
258 case jdk.internal.org.objectweb.asm.Type.OBJECT: |
259 case jdk.internal.org.objectweb.asm.Type.OBJECT: |
|
260 if (Context.isStructureClass(itype.getClassName())) { |
|
261 return SCRIPT_OBJECT; |
|
262 } |
259 try { |
263 try { |
260 return Type.typeFor(Class.forName(itype.getClassName())); |
264 return Type.typeFor(Class.forName(itype.getClassName())); |
261 } catch(final ClassNotFoundException e) { |
265 } catch(final ClassNotFoundException e) { |
262 throw new AssertionError(e); |
266 throw new AssertionError(e); |
263 } |
267 } |
947 public static final Type SCRIPT_OBJECT = putInCache(new ObjectType(ScriptObject.class)); |
951 public static final Type SCRIPT_OBJECT = putInCache(new ObjectType(ScriptObject.class)); |
948 |
952 |
949 /** |
953 /** |
950 * This is the singleton for integer arrays |
954 * This is the singleton for integer arrays |
951 */ |
955 */ |
952 public static final ArrayType INT_ARRAY = new ArrayType(int[].class) { |
956 public static final ArrayType INT_ARRAY = putInCache(new ArrayType(int[].class) { |
953 private static final long serialVersionUID = 1L; |
957 private static final long serialVersionUID = 1L; |
954 |
958 |
955 @Override |
959 @Override |
956 public void astore(final MethodVisitor method) { |
960 public void astore(final MethodVisitor method) { |
957 method.visitInsn(IASTORE); |
961 method.visitInsn(IASTORE); |
971 |
975 |
972 @Override |
976 @Override |
973 public Type getElementType() { |
977 public Type getElementType() { |
974 return INT; |
978 return INT; |
975 } |
979 } |
976 }; |
980 }); |
977 |
981 |
978 /** |
982 /** |
979 * This is the singleton for long arrays |
983 * This is the singleton for long arrays |
980 */ |
984 */ |
981 public static final ArrayType LONG_ARRAY = new ArrayType(long[].class) { |
985 public static final ArrayType LONG_ARRAY = putInCache(new ArrayType(long[].class) { |
982 private static final long serialVersionUID = 1L; |
986 private static final long serialVersionUID = 1L; |
983 |
987 |
984 @Override |
988 @Override |
985 public void astore(final MethodVisitor method) { |
989 public void astore(final MethodVisitor method) { |
986 method.visitInsn(LASTORE); |
990 method.visitInsn(LASTORE); |
1000 |
1004 |
1001 @Override |
1005 @Override |
1002 public Type getElementType() { |
1006 public Type getElementType() { |
1003 return LONG; |
1007 return LONG; |
1004 } |
1008 } |
1005 }; |
1009 }); |
1006 |
1010 |
1007 /** |
1011 /** |
1008 * This is the singleton for numeric arrays |
1012 * This is the singleton for numeric arrays |
1009 */ |
1013 */ |
1010 public static final ArrayType NUMBER_ARRAY = new ArrayType(double[].class) { |
1014 public static final ArrayType NUMBER_ARRAY = putInCache(new ArrayType(double[].class) { |
1011 private static final long serialVersionUID = 1L; |
1015 private static final long serialVersionUID = 1L; |
1012 |
1016 |
1013 @Override |
1017 @Override |
1014 public void astore(final MethodVisitor method) { |
1018 public void astore(final MethodVisitor method) { |
1015 method.visitInsn(DASTORE); |
1019 method.visitInsn(DASTORE); |
1029 |
1033 |
1030 @Override |
1034 @Override |
1031 public Type getElementType() { |
1035 public Type getElementType() { |
1032 return NUMBER; |
1036 return NUMBER; |
1033 } |
1037 } |
1034 }; |
1038 }); |
1035 |
|
1036 /** Singleton for method handle arrays used for properties etc. */ |
|
1037 public static final ArrayType METHODHANDLE_ARRAY = putInCache(new ArrayType(MethodHandle[].class)); |
|
1038 |
|
1039 /** This is the singleton for string arrays */ |
|
1040 public static final ArrayType STRING_ARRAY = putInCache(new ArrayType(String[].class)); |
|
1041 |
1039 |
1042 /** This is the singleton for object arrays */ |
1040 /** This is the singleton for object arrays */ |
1043 public static final ArrayType OBJECT_ARRAY = putInCache(new ArrayType(Object[].class)); |
1041 public static final ArrayType OBJECT_ARRAY = putInCache(new ArrayType(Object[].class)); |
1044 |
1042 |
1045 /** This type, always an object type, just a toString override */ |
1043 /** This type, always an object type, just a toString override */ |