Browse Source

Fixed compilation with generic arguments

kindlich 5 years ago
parent
commit
45029d5e80
No known key found for this signature in database

+ 4
- 3
JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/CompilerUtils.java View File

49
 	}
49
 	}
50
 
50
 
51
     public static void tagMethodParameters(JavaBytecodeContext context, JavaCompiledModule module, FunctionHeader header, boolean isStatic) {
51
     public static void tagMethodParameters(JavaBytecodeContext context, JavaCompiledModule module, FunctionHeader header, boolean isStatic) {
52
-		int index = header.getNumberOfTypeParameters();
52
+		int index = isStatic ? 0 : 1;
53
 		for (int i = 0; i < header.typeParameters.length; i++) {
53
 		for (int i = 0; i < header.typeParameters.length; i++) {
54
 			TypeParameter parameter = header.typeParameters[i];
54
 			TypeParameter parameter = header.typeParameters[i];
55
-			module.setTypeParameterInfo(parameter, new JavaTypeParameterInfo(index++));
55
+			module.setTypeParameterInfo(parameter, new JavaTypeParameterInfo(index));
56
+			index++;
56
 		}
57
 		}
57
         for (int i = 0; i < header.parameters.length; i++) {
58
         for (int i = 0; i < header.parameters.length; i++) {
58
             FunctionParameter parameter = header.parameters[i];
59
             FunctionParameter parameter = header.parameters[i];
59
             String parameterType = context.getDescriptor(parameter.type);
60
             String parameterType = context.getDescriptor(parameter.type);
60
-            module.setParameterInfo(parameter, new JavaParameterInfo(isStatic ? index : index + 1, parameterType));
61
+            module.setParameterInfo(parameter, new JavaParameterInfo(index, parameterType));
61
 			index++;
62
 			index++;
62
         }
63
         }
63
     }
64
     }

+ 4
- 3
JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/JavaWriter.java View File

67
 		this.method = method;
67
 		this.method = method;
68
 		this.forDefinition = forDefinition;
68
 		this.forDefinition = forDefinition;
69
 		this.position = position;
69
 		this.position = position;
70
-		
71
-		final MethodVisitor methodVisitor = visitor.visitMethod(isExtension ? method.modifiers | Opcodes.ACC_STATIC : method.modifiers, method.name, descriptor, signature, exceptions);
70
+
71
+		final int access = isExtension ? method.modifiers | ACC_STATIC : method.modifiers;
72
+		final MethodVisitor methodVisitor = visitor.visitMethod(access, method.name, descriptor, signature, exceptions);
72
 		
73
 		
73
 		for (String annotation : annotations) {
74
 		for (String annotation : annotations) {
74
 			methodVisitor.visitAnnotation(annotation, true).visitEnd();
75
 			methodVisitor.visitAnnotation(annotation, true).visitEnd();
75
 		}
76
 		}
76
 		
77
 		
77
-		this.visitor = new LocalVariablesSorter(isExtension ? method.modifiers | Opcodes.ACC_STATIC : method.modifiers, descriptor, methodVisitor);
78
+		this.visitor = new LocalVariablesSorter(access, descriptor, methodVisitor);
78
 		this.nameVariables = nameVariables;
79
 		this.nameVariables = nameVariables;
79
 	}
80
 	}
80
 	
81
 	

Loading…
Cancel
Save