Ver código fonte

Merge remote-tracking branch 'Stan/development' into WIP/functionalInterfaces

kindlich 6 anos atrás
pai
commit
c69b92718a
Nenhuma chave conhecida encontrada para esta assinatura no banco de dados

+ 20
- 0
JavaShared/src/main/java/org/openzen/zenscript/javashared/JavaContext.java Ver arquivo

@@ -13,6 +13,7 @@ import org.openzen.zencode.shared.CodePosition;
13 13
 import org.openzen.zenscript.codemodel.FunctionHeader;
14 14
 import org.openzen.zenscript.codemodel.FunctionParameter;
15 15
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
16
+import org.openzen.zenscript.codemodel.Modifiers;
16 17
 import org.openzen.zenscript.codemodel.Module;
17 18
 import org.openzen.zenscript.codemodel.definition.VariantDefinition;
18 19
 import org.openzen.zenscript.codemodel.definition.ZSPackage;
@@ -100,6 +101,25 @@ public abstract class JavaContext {
100 101
 		return getPackageName(pkg.parent) + "/" + pkg.name;
101 102
 	}
102 103
 	
104
+	public JavaMethod getFunctionalInterface(StoredType type) {
105
+		if (type.getSpecifiedStorage() instanceof JavaFunctionalInterfaceStorageTag) {
106
+			JavaFunctionalInterfaceStorageTag tag = (JavaFunctionalInterfaceStorageTag)type.getSpecifiedStorage();
107
+			return tag.method;
108
+		} else {
109
+			FunctionTypeID functionType = (FunctionTypeID)type.type;
110
+			JavaSynthesizedFunctionInstance function = getFunction(functionType);
111
+			
112
+			return new JavaMethod(
113
+					function.getCls(),
114
+					JavaMethod.Kind.INTERFACE,
115
+					function.getMethod(),
116
+					false,
117
+					getMethodDescriptor(function.getHeader()),
118
+					Modifiers.PUBLIC | Modifiers.ABSTRACT,
119
+					function.getHeader().getReturnType().isGeneric());
120
+		}
121
+	}
122
+	
103 123
 	protected abstract JavaSyntheticClassGenerator getTypeGenerator();
104 124
 		
105 125
 	public abstract String getDescriptor(TypeID type);

+ 3
- 1
JavaShared/src/main/java/org/openzen/zenscript/javashared/JavaFunctionalInterfaceStorageTag.java Ver arquivo

@@ -15,9 +15,11 @@ import org.openzen.zenscript.codemodel.type.storage.UniqueStorageTag;
15 15
 
16 16
 public class JavaFunctionalInterfaceStorageTag implements StorageTag {
17 17
 	public final Method functionalInterfaceMethod;
18
+	public final JavaMethod method;
18 19
 	
19
-	public JavaFunctionalInterfaceStorageTag(Method functionalInterfaceMethod) {
20
+	public JavaFunctionalInterfaceStorageTag(Method functionalInterfaceMethod, JavaMethod method) {
20 21
 		this.functionalInterfaceMethod = functionalInterfaceMethod;
22
+		this.method = method;
21 23
 	}
22 24
 
23 25
 	@Override

+ 5
- 0
JavaShared/src/main/java/org/openzen/zenscript/javashared/JavaSynthesizedFunctionInstance.java Ver arquivo

@@ -5,6 +5,7 @@
5 5
  */
6 6
 package org.openzen.zenscript.javashared;
7 7
 
8
+import org.openzen.zenscript.codemodel.FunctionHeader;
8 9
 import org.openzen.zenscript.codemodel.type.TypeID;
9 10
 
10 11
 /**
@@ -27,4 +28,8 @@ public class JavaSynthesizedFunctionInstance {
27 28
 	public String getMethod() {
28 29
 		return function.method;
29 30
 	}
31
+	
32
+	public FunctionHeader getHeader() {
33
+		return function.header;
34
+	}
30 35
 }

Carregando…
Cancelar
Salvar