Browse Source

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

kindlich 6 years ago
parent
commit
c69b92718a
No known key found for this signature in database

+ 20
- 0
JavaShared/src/main/java/org/openzen/zenscript/javashared/JavaContext.java View File

13
 import org.openzen.zenscript.codemodel.FunctionHeader;
13
 import org.openzen.zenscript.codemodel.FunctionHeader;
14
 import org.openzen.zenscript.codemodel.FunctionParameter;
14
 import org.openzen.zenscript.codemodel.FunctionParameter;
15
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
15
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
16
+import org.openzen.zenscript.codemodel.Modifiers;
16
 import org.openzen.zenscript.codemodel.Module;
17
 import org.openzen.zenscript.codemodel.Module;
17
 import org.openzen.zenscript.codemodel.definition.VariantDefinition;
18
 import org.openzen.zenscript.codemodel.definition.VariantDefinition;
18
 import org.openzen.zenscript.codemodel.definition.ZSPackage;
19
 import org.openzen.zenscript.codemodel.definition.ZSPackage;
100
 		return getPackageName(pkg.parent) + "/" + pkg.name;
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
 	protected abstract JavaSyntheticClassGenerator getTypeGenerator();
123
 	protected abstract JavaSyntheticClassGenerator getTypeGenerator();
104
 		
124
 		
105
 	public abstract String getDescriptor(TypeID type);
125
 	public abstract String getDescriptor(TypeID type);

+ 3
- 1
JavaShared/src/main/java/org/openzen/zenscript/javashared/JavaFunctionalInterfaceStorageTag.java View File

15
 
15
 
16
 public class JavaFunctionalInterfaceStorageTag implements StorageTag {
16
 public class JavaFunctionalInterfaceStorageTag implements StorageTag {
17
 	public final Method functionalInterfaceMethod;
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
 		this.functionalInterfaceMethod = functionalInterfaceMethod;
21
 		this.functionalInterfaceMethod = functionalInterfaceMethod;
22
+		this.method = method;
21
 	}
23
 	}
22
 
24
 
23
 	@Override
25
 	@Override

+ 5
- 0
JavaShared/src/main/java/org/openzen/zenscript/javashared/JavaSynthesizedFunctionInstance.java View File

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

Loading…
Cancel
Save