Quellcode durchsuchen

Fix recursion when methods return or accept a value of their defining class. Fixed bracket expressions with a postfix expression.

Stan Hebben vor 6 Jahren
Ursprung
Commit
6fa2a38b30

+ 4
- 1
JavaIntegration/src/main/java/org/openzen/zencode/java/JavaNativeModule.java Datei anzeigen

@@ -14,7 +14,9 @@ import java.lang.reflect.Type;
14 14
 import java.lang.reflect.TypeVariable;
15 15
 import java.util.Collections;
16 16
 import java.util.HashMap;
17
+import java.util.HashSet;
17 18
 import java.util.Map;
19
+import java.util.Set;
18 20
 import org.openzen.zencode.shared.CodePosition;
19 21
 import org.openzen.zenscript.codemodel.FunctionHeader;
20 22
 import org.openzen.zenscript.codemodel.FunctionParameter;
@@ -42,6 +44,7 @@ import org.openzen.zenscript.codemodel.member.GetterMember;
42 44
 import org.openzen.zenscript.codemodel.member.MethodMember;
43 45
 import org.openzen.zenscript.codemodel.member.OperatorMember;
44 46
 import org.openzen.zenscript.codemodel.member.SetterMember;
47
+import org.openzen.zenscript.codemodel.member.ref.FunctionalMemberRef;
45 48
 import org.openzen.zenscript.codemodel.partial.PartialStaticMemberGroupExpression;
46 49
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
47 50
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
@@ -146,7 +149,6 @@ public class JavaNativeModule {
146 149
 			return definitionByClass.get(cls);
147 150
 		
148 151
 		HighLevelDefinition result = convertClass(cls);
149
-		definitionByClass.put(cls, result);
150 152
 		return result;
151 153
 	}
152 154
 	
@@ -253,6 +255,7 @@ public class JavaNativeModule {
253 255
 		
254 256
 		definition.typeParameters = typeParameters;
255 257
 		compiled.setClassInfo(definition, javaClass);
258
+		definitionByClass.put(cls, definition);
256 259
 		
257 260
 		StoredType thisType = new StoredType(registry.getForMyDefinition(definition), AutoStorageTag.INSTANCE);
258 261
 		for (Field field : cls.getDeclaredFields()) {

+ 6
- 6
Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedExpression.java Datei anzeigen

@@ -357,12 +357,6 @@ public abstract class ParsedExpression {
357 357
 					// try! can thus be used to convert from exception-based to result-based and vice versa
358 358
 					return new ParsedTryRethrowExpression(position, readUnaryExpression(position, parser, options));
359 359
 				}
360
-			case T_LESS:// bracket expression
361
-				parser.next();
362
-				if (parser.bracketParser == null)
363
-					throw new ParseException(position, "Bracket expression detected but no bracket parser present");
364
-				
365
-				return parser.bracketParser.parse(position, parser);
366 360
 			default:
367 361
 				return readPostfixExpression(position, parser, options);
368 362
 		}
@@ -558,6 +552,12 @@ public abstract class ParsedExpression {
558 552
 				parser.required(T_ACLOSE, "} expected");
559 553
 				return new ParsedMatchExpression(position, source, cases);
560 554
 			}
555
+			case T_LESS:// bracket expression
556
+				parser.next();
557
+				if (parser.bracketParser == null)
558
+					throw new ParseException(position, "Bracket expression detected but no bracket parser present");
559
+				
560
+				return parser.bracketParser.parse(position, parser);
561 561
 			default: {
562 562
 				IParsedType type = IParsedType.parse(parser);
563 563
 				if (type == null) {

+ 4
- 0
ScriptingExample/scripts/integration.zs Datei anzeigen

@@ -20,3 +20,7 @@ something.dump();
20 20
 
21 21
 val objects = makeArray(5);
22 22
 printMany(objects);
23
+
24
+
25
+println(<test string>);
26
+println(<test string>.length);

+ 5
- 0
ScriptingExample/src/main/java/org/openzen/zenscript/scriptingexample/TestClass.java Datei anzeigen

@@ -28,4 +28,9 @@ public class TestClass implements ZenCodeType {
28 28
 	public void dump() {
29 29
 		System.out.println("TestClass " + name);
30 30
 	}
31
+	
32
+	@Method
33
+	public TestClass wrap(String quotes) {
34
+		return new TestClass(quotes + name + quotes);
35
+	}
31 36
 }

Laden…
Abbrechen
Speichern