Browse Source

Added TypeParsing to JNM#getTypeFromName

kindlich 5 years ago
parent
commit
215e92e5bf
No known key found for this signature in database

+ 21
- 0
JavaIntegration/src/main/java/org/openzen/zencode/java/JavaNativeModule.java View File

@@ -75,6 +75,7 @@ import org.openzen.zenscript.lexer.ParseException;
75 75
 import org.openzen.zenscript.lexer.ZSTokenParser;
76 76
 import org.openzen.zenscript.parser.BracketExpressionParser;
77 77
 import org.openzen.zenscript.parser.expression.ParsedExpression;
78
+import org.openzen.zenscript.parser.type.IParsedType;
78 79
 import stdlib.Strings;
79 80
 
80 81
 import java.io.IOException;
@@ -557,6 +558,12 @@ public class JavaNativeModule {
557 558
 				return value;
558 559
 		}
559 560
 
561
+		for (TypeID value : this.unsignedByClass.values()) {
562
+			if(value.toString().equals(className))
563
+				return value;
564
+		}
565
+
566
+
560 567
 		final ZSPackage zsPackage = getPackage(className);
561 568
 		final String[] split = className.split("\\.");
562 569
 		final String actualName = split[split.length-1];
@@ -566,6 +573,20 @@ public class JavaNativeModule {
566 573
 				return registry.getForMyDefinition(value);
567 574
 		}
568 575
 
576
+
577
+		//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);
582
+
583
+		try {
584
+			final ZSTokenParser tokens = ZSTokenParser.create(new LiteralSourceFile("type reading: " + className, className), bep, 4);
585
+			return IParsedType.parse(tokens).compileUnstored(context);
586
+		} catch (Exception ignored) {
587
+		}
588
+
589
+
569 590
 		return null;
570 591
 	}
571 592
 

Loading…
Cancel
Save