瀏覽代碼

WIP: More work on generic parameters in expansions

kindlich 4 年之前
父節點
當前提交
8f1960209a
沒有發現已知的金鑰在資料庫的簽署中

+ 9
- 1
JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/CompilerUtils.java 查看文件

@@ -18,6 +18,8 @@ import org.openzen.zenscript.javabytecode.JavaBytecodeContext;
18 18
 import org.openzen.zenscript.javashared.JavaCompiledModule;
19 19
 import org.openzen.zenscript.javashared.JavaTypeParameterInfo;
20 20
 
21
+import java.util.List;
22
+
21 23
 public class CompilerUtils {
22 24
 
23 25
 	private CompilerUtils() {}
@@ -48,8 +50,14 @@ public class CompilerUtils {
48 50
 		return out;
49 51
 	}
50 52
 
51
-    public static void tagMethodParameters(JavaBytecodeContext context, JavaCompiledModule module, FunctionHeader header, boolean isStatic) {
53
+    public static void tagMethodParameters(JavaBytecodeContext context, JavaCompiledModule module, FunctionHeader header, boolean isStatic, List<TypeParameter> baseTypeTypeParameters) {
52 54
 		int index = isStatic ? 0 : 1;
55
+
56
+		for (TypeParameter baseTypeTypeParameter : baseTypeTypeParameters) {
57
+			module.setTypeParameterInfo(baseTypeTypeParameter, new JavaTypeParameterInfo(index));
58
+			index++;
59
+		}
60
+
53 61
 		for (int i = 0; i < header.typeParameters.length; i++) {
54 62
 			TypeParameter parameter = header.typeParameters[i];
55 63
 			module.setTypeParameterInfo(parameter, new JavaTypeParameterInfo(index));

+ 31
- 9
JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/JavaExpressionVisitor.java 查看文件

@@ -8,6 +8,7 @@ import org.openzen.zenscript.codemodel.CompareType;
8 8
 import org.openzen.zenscript.codemodel.FunctionParameter;
9 9
 import org.openzen.zenscript.codemodel.expression.*;
10 10
 import org.openzen.zenscript.codemodel.expression.switchvalue.VariantOptionSwitchValue;
11
+import org.openzen.zenscript.codemodel.generic.TypeParameter;
11 12
 import org.openzen.zenscript.codemodel.member.ref.DefinitionMemberRef;
12 13
 import org.openzen.zenscript.codemodel.member.ref.FieldMemberRef;
13 14
 import org.openzen.zenscript.codemodel.statement.ReturnStatement;
@@ -23,10 +24,8 @@ import org.openzen.zenscript.javashared.*;
23 24
 
24 25
 import java.lang.reflect.Method;
25 26
 import java.lang.reflect.Modifier;
26
-import java.util.Arrays;
27
-import java.util.Comparator;
28
-import java.util.Objects;
29
-import java.util.StringJoiner;
27
+import java.util.*;
28
+import java.util.stream.Collectors;
30 29
 
31 30
 public class JavaExpressionVisitor implements ExpressionVisitor<Void>, JavaNativeTranslator<Void> {
32 31
     private static final JavaMethod OBJECTS_TOSTRING = JavaMethod.getNativeStatic(new JavaClass("java.util", "Objects", JavaClass.Kind.CLASS), "toString", "(Ljava/lang/Object;)Ljava/lang/String;");
@@ -384,11 +383,24 @@ public class JavaExpressionVisitor implements ExpressionVisitor<Void>, JavaNativ
384 383
 		if (builtin == null) {
385 384
 			expression.target.accept(this);
386 385
 
386
+			final List<TypeParameter> typeParameters;
387
+			{
388
+				final List<TypeParameter> parameters = new ArrayList<>(
389
+						Arrays.asList(expression.member.getTarget().definition.typeParameters)
390
+				);
391
+
392
+				expression.member.getOwnerType().type.extractTypeParameters(parameters);
393
+				for (FunctionParameter parameter : expression.instancedHeader.parameters) {
394
+					parameter.type.type.extractTypeParameters(parameters);
395
+				}
396
+				typeParameters = parameters.stream().distinct().collect(Collectors.toList());
397
+			}
398
+
387 399
 			JavaMethod methodInfo = context.getJavaMethod(expression.member);
388
-			for (int i = 0; i < expression.arguments.typeArguments.length; i++) {
389
-				if (methodInfo.typeParameterArguments[i]) {
390
-					StoredType arguments = expression.arguments.typeArguments[i];
391 400
 
401
+			if(methodInfo.compile) {
402
+				for (TypeParameter typeParameter : typeParameters) {
403
+					javaWriter.aConstNull(); // TODO: Replace with actual class
392 404
 				}
393 405
 			}
394 406
 
@@ -1951,7 +1963,7 @@ public class JavaExpressionVisitor implements ExpressionVisitor<Void>, JavaNativ
1951 1963
 
1952 1964
 	@Override
1953 1965
 	public Void visitFunction(FunctionExpression expression) {
1954
-		CompilerUtils.tagMethodParameters(context, module, expression.header, false);
1966
+		CompilerUtils.tagMethodParameters(context, module, expression.header, false, Collections.emptyList());
1955 1967
 
1956 1968
         /*if (expression.header.parameters.length == 0 && expression.body instanceof ReturnStatement && expression.body.hasTag(MatchExpression.class) && expression.closure.captures.isEmpty()) {
1957 1969
             ((ReturnStatement) expression.body).value.accept(this);
@@ -2188,6 +2200,15 @@ public class JavaExpressionVisitor implements ExpressionVisitor<Void>, JavaNativ
2188 2200
 				javaWriter.getField(context.getJavaField(expression.getter));
2189 2201
 				return null;
2190 2202
 			}
2203
+
2204
+
2205
+			final List<TypeParameter> typeParameters = new ArrayList<>();
2206
+			expression.getter.member.getType().type.extractTypeParameters(typeParameters);
2207
+
2208
+			for (TypeParameter typeParameter : typeParameters) {
2209
+				javaWriter.aConstNull(); //TODO: Replace with actual type
2210
+			}
2211
+
2191 2212
 			if (!checkAndExecuteMethodInfo(expression.getter, expression.type, expression))
2192 2213
 				throw new IllegalStateException("Call target has no method info!");
2193 2214
 
@@ -3516,7 +3537,8 @@ public class JavaExpressionVisitor implements ExpressionVisitor<Void>, JavaNativ
3516 3537
 								}
3517 3538
 								
3518 3539
 								if (funcExpression instanceof FunctionExpression && ((FunctionExpression) funcExpression).body instanceof ReturnStatement) {
3519
-									CompilerUtils.tagMethodParameters(context, module, ((FunctionExpression) funcExpression).header, false);
3540
+									CompilerUtils.tagMethodParameters(context, module, ((FunctionExpression) funcExpression).header, false, Collections
3541
+                                            .emptyList());
3520 3542
 									((ReturnStatement) ((FunctionExpression) funcExpression).body).value.accept(visitor);
3521 3543
 									javaWriter.addVariableInfo(new JavaLocalVariableInfo(projectedElementType, projectedElementLocal, inlineBegin, ((FunctionExpression) funcExpression).header.parameters[0].name, inlineEnd));
3522 3544
 									

+ 3
- 1
JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/definitions/JavaDefinitionVisitor.java 查看文件

@@ -29,6 +29,7 @@ import org.openzen.zenscript.javashared.JavaTypeGenericVisitor;
29 29
 import org.openzen.zenscript.javashared.JavaVariantOption;
30 30
 
31 31
 import java.util.ArrayList;
32
+import java.util.Collections;
32 33
 import java.util.List;
33 34
 
34 35
 
@@ -145,7 +146,8 @@ public class JavaDefinitionVisitor implements DefinitionVisitor<byte[]> {
145 146
 
146 147
 	@Override
147 148
 	public byte[] visitFunction(FunctionDefinition definition) {
148
-		CompilerUtils.tagMethodParameters(context, context.getJavaModule(definition.module), definition.header, true);
149
+		CompilerUtils.tagMethodParameters(context, context.getJavaModule(definition.module), definition.header, true, Collections
150
+                .emptyList());
149 151
 
150 152
         final String signature = context.getMethodSignature(definition.header);
151 153
 		final JavaMethod method = context.getJavaMethod(definition.caller);

+ 116
- 11
JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/definitions/JavaExpansionMemberVisitor.java 查看文件

@@ -5,6 +5,7 @@ import org.objectweb.asm.Label;
5 5
 import org.objectweb.asm.Type;
6 6
 import org.openzen.zenscript.codemodel.FunctionParameter;
7 7
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
8
+import org.openzen.zenscript.codemodel.generic.TypeParameter;
8 9
 import org.openzen.zenscript.codemodel.member.*;
9 10
 import org.openzen.zenscript.codemodel.type.StoredType;
10 11
 import org.openzen.zenscript.javabytecode.JavaBytecodeContext;
@@ -15,6 +16,9 @@ import org.openzen.zenscript.javashared.JavaCompiledModule;
15 16
 import org.openzen.zenscript.javashared.JavaField;
16 17
 import org.openzen.zenscript.javashared.JavaMethod;
17 18
 
19
+import java.util.ArrayList;
20
+import java.util.stream.Collectors;
21
+
18 22
 public class JavaExpansionMemberVisitor implements MemberVisitor<Void> {
19 23
 
20 24
 	private final ClassWriter writer;
@@ -79,38 +83,76 @@ public class JavaExpansionMemberVisitor implements MemberVisitor<Void> {
79 83
 		if (!method.compile)
80 84
 			return null;
81 85
 
86
+		final ArrayList<TypeParameter> typeParameters = new ArrayList<>();
87
+		expandedClass.type.extractTypeParameters(typeParameters);
82 88
 
83
-		CompilerUtils.tagMethodParameters(context, javaModule, member.header, member.isStatic());
89
+		CompilerUtils.tagMethodParameters(context, javaModule, member.header, member.isStatic(), typeParameters);
84 90
 
85 91
 		final String expandedClassDescriptor = context.getDescriptor(expandedClass);
92
+		final String expandedClassSignature = context.getSignature(expandedClass);
86 93
 		final Label methodStart = new Label();
87 94
 		final Label methodEnd = new Label();
88 95
 		final String methodSignature;
96
+		final String methodDescriptor;
97
+
98
+
89 99
 
90 100
 		if (!isStatic) {
91
-			methodSignature = "(" + expandedClassDescriptor + context.getMethodSignature(member.header).substring(1);
101
+			String methodSignature1 = context.getMethodSignature(member.header);
102
+
103
+			//Add the expanded type as first generic parameter to the list.
104
+			if(!typeParameters.isEmpty()){
105
+				final String collect = typeParameters.stream()
106
+						.map(t -> t.name + ":" + "Ljava/lang/Object;")
107
+						.collect(Collectors.joining("", "<", ""));
108
+				if(methodSignature1.startsWith("<")) {
109
+					methodSignature1 = collect + methodSignature1.substring(1);
110
+				} else {
111
+					methodSignature1 = collect + ">" + methodSignature1;
112
+				}
113
+			}
114
+
115
+			final StringBuilder typeParamSigBuilder = new StringBuilder();
116
+			final StringBuilder typeParamDescBuilder = new StringBuilder();
117
+			int i = 1;
118
+			for (TypeParameter typeParameter : typeParameters) {
119
+				typeParamSigBuilder.append("Ljava/lang/Class<T").append(typeParameter.name).append(";>;");
120
+				typeParamDescBuilder.append("Ljava/lang/Class;");
121
+			}
122
+
123
+
124
+			final int index = methodSignature1.lastIndexOf('(') + 1;
125
+			methodSignature = methodSignature1.substring(0, index) + expandedClassSignature + typeParamSigBuilder.toString() + methodSignature1.substring(index);
126
+			methodDescriptor = "(" + expandedClassDescriptor + typeParamDescBuilder.toString() + context.getMethodDescriptor(member.header).substring(1);
92 127
 		} else {
93 128
 			methodSignature = context.getMethodSignature(member.header);
129
+			methodDescriptor = context.getMethodDescriptor(member.header);
94 130
 		}
95 131
 
96 132
 
97
-		final JavaWriter methodWriter = new JavaWriter(member.position, writer, true, method, definition, true, methodSignature, methodSignature, null);
133
+		final JavaWriter methodWriter = new JavaWriter(member.position, writer, true, method, definition, true, methodSignature, methodDescriptor, null);
98 134
 		methodWriter.label(methodStart);
99 135
 
100 136
 		if (!isStatic) {
101 137
 			methodWriter.nameVariable(0, "expandedObj", methodStart, methodEnd, Type.getType(expandedClassDescriptor));
102 138
 			methodWriter.nameParameter(0, "expandedObj");
103
-			for (final FunctionParameter parameter : member.header.parameters) {
104
-				methodWriter.nameParameter(0, parameter.name);
105
-				methodWriter.nameVariable(javaModule.getParameterInfo(parameter).index, parameter.name, methodStart, methodEnd, context.getType(parameter.type));
106
-			}
107
-		} else {
108
-			for (final FunctionParameter parameter : member.header.parameters) {
109
-				methodWriter.nameParameter(0, parameter.name);
110
-				methodWriter.nameVariable(javaModule.getParameterInfo(parameter).index, parameter.name, methodStart, methodEnd, context.getType(parameter.type));
139
+
140
+			for (TypeParameter typeParameter : typeParameters) {
141
+				methodWriter.nameParameter(0, "typeOf" + typeParameter.name);
142
+				methodWriter.nameVariable(javaModule.getTypeParameterInfo(typeParameter).parameterIndex, "typeOf" + typeParameter.name, methodStart, methodEnd, Type.getType(Class.class));
111 143
 			}
112 144
 		}
113 145
 
146
+		for (TypeParameter typeParameter : member.header.typeParameters) {
147
+			methodWriter.nameParameter(0, "typeOf" + typeParameter.name);
148
+			methodWriter.nameVariable(javaModule.getTypeParameterInfo(typeParameter).parameterIndex, "typeOf" + typeParameter.name, methodStart, methodEnd, Type.getType(Class.class));
149
+		}
150
+
151
+		for (final FunctionParameter parameter : member.header.parameters) {
152
+			methodWriter.nameParameter(0, parameter.name);
153
+			methodWriter.nameVariable(javaModule.getParameterInfo(parameter).index, parameter.name, methodStart, methodEnd, context.getType(parameter.type));
154
+		}
155
+
114 156
 
115 157
 		{
116 158
 			final JavaStatementVisitor statementVisitor = new JavaStatementVisitor(context, javaModule, methodWriter);
@@ -126,6 +168,69 @@ public class JavaExpansionMemberVisitor implements MemberVisitor<Void> {
126 168
 
127 169
 	@Override
128 170
 	public Void visitGetter(GetterMember member) {
171
+		final boolean isStatic = member.isStatic();
172
+		final StoredType returnType = member.getType();
173
+		final String descriptor;
174
+		final String signature;
175
+
176
+		final ArrayList<TypeParameter> typeParameters = new ArrayList<>();
177
+		expandedClass.type.extractTypeParameters(typeParameters);
178
+
179
+		final String descMiddle, signatureMiddle, signatureStart;
180
+		if(typeParameters.isEmpty()) {
181
+			descMiddle = signatureMiddle = signatureStart = "";
182
+		} else {
183
+			final StringBuilder descMiddleBuilder = new StringBuilder();
184
+			final StringBuilder signatureMiddleBuilder = new StringBuilder();
185
+			final StringBuilder signatureStartBuilder = new StringBuilder("<");
186
+
187
+			for (TypeParameter typeParameter : typeParameters) {
188
+				descMiddleBuilder.append("Ljava/lang/Class;");
189
+				signatureMiddleBuilder.append("Ljava/lang/Class<T").append(typeParameter.name).append(";>;");
190
+				signatureStartBuilder.append(typeParameter.name).append(":Ljava/lang/Object;");
191
+			}
192
+
193
+			descMiddle = descMiddleBuilder.toString();
194
+			signatureMiddle = signatureMiddleBuilder.toString();
195
+			signatureStart = signatureStartBuilder.append(">").toString();
196
+		}
197
+
198
+		if (isStatic) {
199
+			descriptor = "(" + descMiddle + ")" + context.getDescriptor(returnType);
200
+			signature = signatureStart + "(" + signatureMiddle + ")" + context.getSignature(returnType);
201
+		} else {
202
+			descriptor = "(" + context.getDescriptor(expandedClass) + descMiddle + ")" + context.getDescriptor(returnType);
203
+			signature = signatureStart + "(" + context.getSignature(expandedClass) + signatureMiddle + ")" + context.getSignature(returnType);
204
+		}
205
+
206
+		final Label methodStart = new Label();
207
+		final Label methodEnd = new Label();
208
+
209
+		final JavaMethod method = context.getJavaMethod(member);
210
+		final JavaWriter methodWriter = new JavaWriter(member.position, this.writer, true, method, definition, true, signature, descriptor, new String[0]);
211
+
212
+		methodWriter.label(methodStart);
213
+
214
+		if (!isStatic) {
215
+			methodWriter.nameVariable(0, "expandedObj", methodStart, methodEnd, context.getType(this.expandedClass));
216
+			methodWriter.nameParameter(0, "expandedObj");
217
+		}
218
+
219
+		int i = isStatic ? 0 : 1;
220
+		for (TypeParameter typeParameter : typeParameters) {
221
+			final String name = "typeOf" + typeParameter.name;
222
+			methodWriter.nameVariable(i, name, methodStart, methodEnd, Type.getType(Class.class));
223
+			methodWriter.nameParameter(0, name);
224
+		}
225
+
226
+		{
227
+			final JavaStatementVisitor statementVisitor = new JavaStatementVisitor(context, javaModule, methodWriter);
228
+			statementVisitor.start();
229
+			member.body.accept(statementVisitor);
230
+			methodWriter.label(methodEnd);
231
+			statementVisitor.end();
232
+		}
233
+
129 234
 		return null;
130 235
 	}
131 236
 

+ 2
- 1
JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/definitions/JavaMemberVisitor.java 查看文件

@@ -12,6 +12,7 @@ import org.openzen.zenscript.codemodel.expression.Expression;
12 12
 import org.openzen.zenscript.codemodel.member.*;
13 13
 import org.openzen.zenscript.javabytecode.compiler.*;
14 14
 
15
+import java.util.Collections;
15 16
 import java.util.List;
16 17
 import org.openzen.zenscript.javabytecode.JavaBytecodeContext;
17 18
 import org.openzen.zenscript.javashared.JavaClass;
@@ -129,7 +130,7 @@ public class JavaMemberVisitor implements MemberVisitor<Void> {
129 130
 
130 131
     @Override
131 132
     public Void visitMethod(MethodMember member) {
132
-        CompilerUtils.tagMethodParameters(context, javaModule, member.header, member.isStatic());
133
+        CompilerUtils.tagMethodParameters(context, javaModule, member.header, member.isStatic(), Collections.emptyList());
133 134
 
134 135
         final boolean isAbstract = member.body == null || Modifiers.isAbstract(member.getEffectiveModifiers());
135 136
         final JavaMethod method = context.getJavaMethod(member);

+ 18
- 3
JavaShared/src/main/java/org/openzen/zenscript/javashared/JavaContext.java 查看文件

@@ -125,7 +125,11 @@ public abstract class JavaContext {
125 125
 	public abstract String getDescriptor(TypeID type);
126 126
 	
127 127
 	public abstract String getDescriptor(StoredType type);
128
-	
128
+
129
+	public String getSignature(StoredType type) {
130
+		return new JavaTypeGenericVisitor(this).getGenericSignature(type);
131
+	}
132
+
129 133
 	public void addModule(Module module, JavaCompiledModule target) {
130 134
 		modules.put(module, target);
131 135
 
@@ -225,12 +229,23 @@ public abstract class JavaContext {
225 229
 	}
226 230
 
227 231
 	public String getMethodDescriptorExpansion(FunctionHeader header, StoredType expandedType) {
228
-		return getMethodDescriptor(header, false, getDescriptor(expandedType));
232
+		StringBuilder startBuilder = new StringBuilder(getDescriptor(expandedType));
233
+		final List<TypeParameter> typeParameters = new ArrayList<>();
234
+		expandedType.type.extractTypeParameters(typeParameters);
235
+		for (TypeParameter typeParameter : typeParameters) {
236
+			startBuilder.append("Ljava/lang/Class;");
237
+		}
238
+
239
+		return getMethodDescriptor(header, false, startBuilder.toString());
229 240
 	}
230 241
 	
231 242
     public String getMethodSignature(FunctionHeader header) {
232
-        return new JavaTypeGenericVisitor(this).getGenericMethodSignature(header);
243
+        return getMethodSignature(header, true);
233 244
     }
245
+
246
+    public String getMethodSignature(FunctionHeader header, boolean withGenerics) {
247
+		return new JavaTypeGenericVisitor(this).getGenericMethodSignature(header, withGenerics);
248
+	}
234 249
 	
235 250
 	public String getEnumConstructorDescriptor(FunctionHeader header) {
236 251
 		return getMethodDescriptor(header, true, "");

+ 52
- 3
JavaShared/src/main/java/org/openzen/zenscript/javashared/JavaTypeGenericVisitor.java 查看文件

@@ -4,7 +4,9 @@ import org.openzen.zenscript.codemodel.FunctionHeader;
4 4
 import org.openzen.zenscript.codemodel.FunctionParameter;
5 5
 import org.openzen.zenscript.codemodel.generic.*;
6 6
 import org.openzen.zenscript.codemodel.type.*;
7
+import org.openzen.zenscript.codemodel.type.storage.ValueStorageTag;
7 8
 
9
+import java.util.Arrays;
8 10
 import java.util.Collection;
9 11
 
10 12
 public class JavaTypeGenericVisitor implements TypeVisitorWithContext<StoredType, String, RuntimeException> {
@@ -59,6 +61,34 @@ public class JavaTypeGenericVisitor implements TypeVisitorWithContext<StoredType
59 61
 				getGenericSignature(header.getReturnType());
60 62
 	}
61 63
 
64
+	public String getGenericMethodSignature(FunctionHeader header, boolean addGenerics) {
65
+		final StringBuilder sb = new StringBuilder();
66
+		final boolean doGenerics = addGenerics && header.typeParameters.length > 0;
67
+
68
+		if(doGenerics) {
69
+			sb.append("<");
70
+			for (TypeParameter typeParameter : header.typeParameters) {
71
+				//TODO: Eventually replace with upper bound
72
+				sb.append(typeParameter.name).append(":").append("Ljava/lang/Object;");
73
+			}
74
+			sb.append(">");
75
+		}
76
+
77
+
78
+		sb.append("(");
79
+		if(doGenerics) {
80
+			for (TypeParameter typeParameter : header.typeParameters) {
81
+				//TODO: Eventually replace with -TT; or +TT; for "? super T" and "? extends T"
82
+				sb.append("Ljava/lang/Class<T").append(typeParameter.name).append(";>;");
83
+			}
84
+		}
85
+
86
+		sb.append(getGenericSignature(header.parameters));
87
+		sb.append(")");
88
+		sb.append(getGenericSignature(header.getReturnType()));
89
+		return sb.toString();
90
+	}
91
+
62 92
 
63 93
 	public String getGenericBounds(Collection<TypeParameterBound> collection) {
64 94
 		if (collection == null)
@@ -93,12 +123,17 @@ public class JavaTypeGenericVisitor implements TypeVisitorWithContext<StoredType
93 123
 
94 124
 	@Override
95 125
 	public String visitArray(StoredType context, ArrayTypeID array) {
96
-		return this.context.getDescriptor(array);
126
+		final char[] dim = new char[array.dimension];
127
+		Arrays.fill(dim, '[');
128
+		return new String(dim) + this.context.getSignature(array.elementType);
97 129
 	}
98 130
 
99 131
 	@Override
100 132
 	public String visitAssoc(StoredType context, AssocTypeID assoc) {
101
-		return this.context.getDescriptor(assoc);
133
+		return "Ljava/util/Map<"
134
+				+ assoc.keyType.type.accept(context, this)
135
+				+ assoc.valueType.type.accept(context, this)
136
+				+ ">;";
102 137
 	}
103 138
 
104 139
 	@Override
@@ -113,7 +148,21 @@ public class JavaTypeGenericVisitor implements TypeVisitorWithContext<StoredType
113 148
 
114 149
 	@Override
115 150
 	public String visitFunction(StoredType context, FunctionTypeID function) {
116
-		return this.context.getDescriptor(function);
151
+		final JavaSynthesizedFunctionInstance function1 = this.context.getFunction(function);
152
+		if(function1.typeArguments == null || function1.typeArguments.length == 0) {
153
+			return this.context.getDescriptor(function);
154
+		}
155
+
156
+		StringBuilder sb = new StringBuilder("L").append(function1.getCls().internalName).append("<");
157
+		for (TypeID typeArgument : function1.typeArguments) {
158
+			final String n = typeArgument instanceof GenericTypeID
159
+					? ((GenericTypeID) typeArgument).parameter.name
160
+					: "Ljava/lang/Object"; //Can latter even happen?
161
+
162
+			sb.append("T").append(n).append(";");
163
+		}
164
+
165
+		return sb.append(">;").toString();
117 166
 	}
118 167
 
119 168
 	@Override

Loading…
取消
儲存