Browse Source

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

Stan Hebben 6 years ago
parent
commit
6fa2a38b30

+ 4
- 1
JavaIntegration/src/main/java/org/openzen/zencode/java/JavaNativeModule.java View File

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

+ 6
- 6
Parser/src/main/java/org/openzen/zenscript/parser/expression/ParsedExpression.java View File

357
 					// try! can thus be used to convert from exception-based to result-based and vice versa
357
 					// try! can thus be used to convert from exception-based to result-based and vice versa
358
 					return new ParsedTryRethrowExpression(position, readUnaryExpression(position, parser, options));
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
 			default:
360
 			default:
367
 				return readPostfixExpression(position, parser, options);
361
 				return readPostfixExpression(position, parser, options);
368
 		}
362
 		}
558
 				parser.required(T_ACLOSE, "} expected");
552
 				parser.required(T_ACLOSE, "} expected");
559
 				return new ParsedMatchExpression(position, source, cases);
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
 			default: {
561
 			default: {
562
 				IParsedType type = IParsedType.parse(parser);
562
 				IParsedType type = IParsedType.parse(parser);
563
 				if (type == null) {
563
 				if (type == null) {

+ 4
- 0
ScriptingExample/scripts/integration.zs View File

20
 
20
 
21
 val objects = makeArray(5);
21
 val objects = makeArray(5);
22
 printMany(objects);
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 View File

28
 	public void dump() {
28
 	public void dump() {
29
 		System.out.println("TestClass " + name);
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
 }

Loading…
Cancel
Save