|
@@ -8,16 +8,7 @@ package org.openzen.zencode.java;
|
8
|
8
|
import org.openzen.zencode.shared.CodePosition;
|
9
|
9
|
import org.openzen.zencode.shared.CompileException;
|
10
|
10
|
import org.openzen.zencode.shared.LiteralSourceFile;
|
11
|
|
-import org.openzen.zenscript.codemodel.FunctionHeader;
|
12
|
|
-import org.openzen.zenscript.codemodel.FunctionParameter;
|
13
|
|
-import org.openzen.zenscript.codemodel.GenericMapper;
|
14
|
|
-import org.openzen.zenscript.codemodel.HighLevelDefinition;
|
15
|
|
-import org.openzen.zenscript.codemodel.Modifiers;
|
16
|
|
-import org.openzen.zenscript.codemodel.Module;
|
17
|
|
-import org.openzen.zenscript.codemodel.ModuleSpace;
|
18
|
|
-import org.openzen.zenscript.codemodel.OperatorType;
|
19
|
|
-import org.openzen.zenscript.codemodel.PackageDefinitions;
|
20
|
|
-import org.openzen.zenscript.codemodel.SemanticModule;
|
|
11
|
+import org.openzen.zenscript.codemodel.*;
|
21
|
12
|
import org.openzen.zenscript.codemodel.annotations.AnnotationDefinition;
|
22
|
13
|
import org.openzen.zenscript.codemodel.context.CompilingPackage;
|
23
|
14
|
import org.openzen.zenscript.codemodel.context.FileResolutionContext;
|
|
@@ -64,13 +55,7 @@ import org.openzen.zenscript.codemodel.type.storage.AutoStorageTag;
|
64
|
55
|
import org.openzen.zenscript.codemodel.type.storage.StaticStorageTag;
|
65
|
56
|
import org.openzen.zenscript.codemodel.type.storage.StorageTag;
|
66
|
57
|
import org.openzen.zenscript.codemodel.type.storage.StorageType;
|
67
|
|
-import org.openzen.zenscript.javashared.JavaClass;
|
68
|
|
-import org.openzen.zenscript.javashared.JavaCompiledModule;
|
69
|
|
-import org.openzen.zenscript.javashared.JavaField;
|
70
|
|
-import org.openzen.zenscript.javashared.JavaFunctionalInterfaceStorageTag;
|
71
|
|
-import org.openzen.zenscript.javashared.JavaImplementation;
|
72
|
|
-import org.openzen.zenscript.javashared.JavaMethod;
|
73
|
|
-import org.openzen.zenscript.javashared.JavaModifiers;
|
|
58
|
+import org.openzen.zenscript.javashared.*;
|
74
|
59
|
import org.openzen.zenscript.lexer.ParseException;
|
75
|
60
|
import org.openzen.zenscript.lexer.ZSTokenParser;
|
76
|
61
|
import org.openzen.zenscript.parser.BracketExpressionParser;
|
|
@@ -88,9 +73,8 @@ import java.lang.reflect.Parameter;
|
88
|
73
|
import java.lang.reflect.ParameterizedType;
|
89
|
74
|
import java.lang.reflect.Type;
|
90
|
75
|
import java.lang.reflect.TypeVariable;
|
91
|
|
-import java.util.Collections;
|
92
|
|
-import java.util.HashMap;
|
93
|
|
-import java.util.Map;
|
|
76
|
+import java.util.*;
|
|
77
|
+import java.util.stream.Collectors;
|
94
|
78
|
|
95
|
79
|
/**
|
96
|
80
|
* @author Stan Hebben
|
|
@@ -462,7 +446,11 @@ public class JavaNativeModule {
|
462
|
446
|
// if(!method.isAnnotationPresent(ZenCodeType.Method.class))
|
463
|
447
|
// continue;
|
464
|
448
|
|
465
|
|
- if(!method.getParameterTypes()[0].isAssignableFrom(getClassFromType(expandedType)))
|
|
449
|
+ final Class<?> classFromType = getClassFromType(expandedType);
|
|
450
|
+ if(classFromType == null) {
|
|
451
|
+ //TODO REMOVE
|
|
452
|
+ System.err.println("Could not get class for type " + expandedType + " attempting to do stuff anyways");
|
|
453
|
+ } else if(!method.getParameterTypes()[0].isAssignableFrom(classFromType))
|
466
|
454
|
throw new IllegalArgumentException("Cannot add extension method " + method + " as its first parameter does not match the extended type.");
|
467
|
455
|
|
468
|
456
|
|
|
@@ -543,7 +531,8 @@ public class JavaNativeModule {
|
543
|
531
|
return ent.getKey();
|
544
|
532
|
}
|
545
|
533
|
|
546
|
|
- throw new IllegalArgumentException("Could not find class for type " + type);
|
|
534
|
+ return null;
|
|
535
|
+ //throw new IllegalArgumentException("Could not find class for type " + type);
|
547
|
536
|
}
|
548
|
537
|
|
549
|
538
|
private Parameter[] getExpansionParameters(Method method){
|
|
@@ -564,21 +553,22 @@ public class JavaNativeModule {
|
564
|
553
|
}
|
565
|
554
|
|
566
|
555
|
|
567
|
|
- final ZSPackage zsPackage = getPackage(className);
|
568
|
|
- final String[] split = className.split("\\.");
|
569
|
|
- final String actualName = split[split.length-1];
|
|
556
|
+ try {
|
|
557
|
+ final ZSPackage zsPackage = getPackage(className);
|
|
558
|
+ final String[] split = className.split("\\.");
|
|
559
|
+ final String actualName = split[split.length - 1];
|
570
|
560
|
|
571
|
|
- for (HighLevelDefinition value : this.definitionByClass.values()) {
|
572
|
|
- if(actualName.equals(value.name) && value.pkg.equals(zsPackage))
|
573
|
|
- return registry.getForMyDefinition(value);
|
|
561
|
+ for (HighLevelDefinition value : this.definitionByClass.values()) {
|
|
562
|
+ if (actualName.equals(value.name) && value.pkg.equals(zsPackage))
|
|
563
|
+ return registry.getForMyDefinition(value);
|
|
564
|
+ }
|
|
565
|
+ } catch (IllegalArgumentException ignored){
|
574
|
566
|
}
|
575
|
567
|
|
576
|
568
|
|
577
|
569
|
//TODO: Can we get by with only this?
|
578
|
|
- final ZSPackage outerPkg = new ZSPackage(ZSPackage.createRoot(), "");
|
579
|
|
- outerPkg.add(pkg.name, pkg);
|
580
|
|
- final CompilingPackage rootCompiling = new CompilingPackage(outerPkg, module);
|
581
|
|
- final ModuleTypeResolutionContext context = new ModuleTypeResolutionContext(registry, new AnnotationDefinition[0], StorageType.getStandard(), outerPkg, rootCompiling, globals);
|
|
570
|
+ final CompilingPackage rootCompiling = new CompilingPackage(pkg.parent, module);
|
|
571
|
+ final ModuleTypeResolutionContext context = new ModuleTypeResolutionContext(registry, new AnnotationDefinition[0], StorageType.getStandard(), pkg.parent, rootCompiling, globals);
|
582
|
572
|
|
583
|
573
|
try {
|
584
|
574
|
final ZSTokenParser tokens = ZSTokenParser.create(new LiteralSourceFile("type reading: " + className, className), bep, 4);
|