Просмотр исходного кода

Fix maps expecting a class instead of an interface

Jared 5 лет назад
Родитель
Сommit
b09c1b6677
Аккаунт пользователя с таким Email не найден

+ 8
- 8
JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/JavaExpressionVisitor.java Просмотреть файл

@@ -111,14 +111,14 @@ public class JavaExpressionVisitor implements ExpressionVisitor<Void>, JavaNativ
111 111
 	private static final JavaMethod ENUM_NAME = JavaMethod.getNativeVirtual(JavaClass.ENUM, "name", "()Ljava/lang/String;");
112 112
 	private static final JavaMethod ENUM_ORDINAL = JavaMethod.getNativeVirtual(JavaClass.ENUM, "ordinal", "()I");
113 113
 	private static final JavaMethod HASHMAP_INIT = JavaMethod.getNativeConstructor(JavaClass.HASHMAP, "()V");
114
-	private static final JavaMethod MAP_GET = JavaMethod.getNativeVirtual(JavaClass.MAP, "get", "(Ljava/lang/Object;)Ljava/lang/Object;");
115
-	private static final JavaMethod MAP_PUT = JavaMethod.getNativeVirtual(JavaClass.MAP, "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
116
-	private static final JavaMethod MAP_PUT_ALL = JavaMethod.getNativeVirtual(JavaClass.MAP, "putAll", "(Ljava/util/Map;)V");
117
-	private static final JavaMethod MAP_CONTAINS_KEY = JavaMethod.getNativeVirtual(JavaClass.MAP, "containsKey", "(Ljava/lang/Object;)Z");
118
-	private static final JavaMethod MAP_SIZE = JavaMethod.getNativeVirtual(JavaClass.MAP, "size", "()I");
119
-	private static final JavaMethod MAP_ISEMPTY = JavaMethod.getNativeVirtual(JavaClass.MAP, "isEmpty", "()Z");
120
-	private static final JavaMethod MAP_KEYS = JavaMethod.getNativeVirtual(JavaClass.MAP, "keys", "()Ljava/lang/Object;");
121
-	private static final JavaMethod MAP_VALUES = JavaMethod.getNativeVirtual(JavaClass.MAP, "values", "()Ljava/lang/Object;");
114
+	private static final JavaMethod MAP_GET = JavaMethod.getInterface(JavaClass.HASHMAP, "get", "(Ljava/lang/Object;)Ljava/lang/Object;");
115
+	private static final JavaMethod MAP_PUT = JavaMethod.getInterface(JavaClass.MAP, "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
116
+	private static final JavaMethod MAP_PUT_ALL = JavaMethod.getInterface(JavaClass.MAP, "putAll", "(Ljava/util/Map;)V");
117
+	private static final JavaMethod MAP_CONTAINS_KEY = JavaMethod.getInterface(JavaClass.MAP, "containsKey", "(Ljava/lang/Object;)Z");
118
+	private static final JavaMethod MAP_SIZE = JavaMethod.getInterface(JavaClass.MAP, "size", "()I");
119
+	private static final JavaMethod MAP_ISEMPTY = JavaMethod.getInterface(JavaClass.MAP, "isEmpty", "()Z");
120
+	private static final JavaMethod MAP_KEYS = JavaMethod.getInterface(JavaClass.MAP, "keys", "()Ljava/lang/Object;");
121
+	private static final JavaMethod MAP_VALUES = JavaMethod.getInterface(JavaClass.MAP, "values", "()Ljava/lang/Object;");
122 122
 	private static final JavaMethod ARRAYS_COPY_OF_RANGE_OBJECTS = JavaMethod.getNativeStatic(JavaClass.ARRAYS, "copyOfRange", "([Ljava/lang/Object;II)[Ljava/lang/Object;");
123 123
 	private static final JavaMethod ARRAYS_COPY_OF_RANGE_BOOLS = JavaMethod.getNativeStatic(JavaClass.ARRAYS, "copyOfRange", "([ZII)[Z");
124 124
 	private static final JavaMethod ARRAYS_COPY_OF_RANGE_BYTES = JavaMethod.getNativeStatic(JavaClass.ARRAYS, "copyOfRange", "([BII)[B");

+ 4
- 0
JavaShared/src/main/java/org/openzen/zenscript/javashared/JavaMethod.java Просмотреть файл

@@ -39,6 +39,10 @@ public class JavaMethod {
39 39
 	public static JavaMethod getNativeVirtual(JavaClass cls, String name, String descriptor) {
40 40
 		return new JavaMethod(cls, Kind.INSTANCE, name, false, descriptor, JavaModifiers.PUBLIC, false);
41 41
 	}
42
+    
43
+    public static JavaMethod getInterface(JavaClass cls, String name, String descriptor) {
44
+        return new JavaMethod(cls, Kind.INTERFACE, name, false, descriptor, JavaModifiers.PUBLIC, false);
45
+    }
42 46
 
43 47
 	public static JavaMethod getNativeExpansion(JavaClass cls, String name, String descriptor) {
44 48
 		return new JavaMethod(cls, Kind.EXPANSION, name, false, descriptor, JavaModifiers.PUBLIC | JavaModifiers.STATIC, false);

Загрузка…
Отмена
Сохранить