Преглед изворни кода

- Separated calls from casts

- Fixed priorities for brackets in the code formatter
- Added code position to definitions
- In a FieldMember the final status is now stored in the modifiers instead of a separate field
- WIP on implementing function definitions properly
Stan Hebben пре 6 година
родитељ
комит
ae21c007d9
32 измењених фајлова са 176 додато и 73 уклоњено
  1. 15
    11
      CodeFormatter/src/main/java/org/openzen/zenscript/formatter/ExpressionFormatter.java
  2. 2
    2
      CodeFormatter/src/main/java/org/openzen/zenscript/formatter/OperatorPriority.java
  3. 4
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/HighLevelDefinition.java
  4. 3
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/AliasDefinition.java
  5. 5
    4
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/ClassDefinition.java
  6. 3
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/EnumDefinition.java
  7. 3
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/ExpansionDefinition.java
  8. 18
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/FunctionDefinition.java
  9. 3
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/InterfaceDefinition.java
  10. 3
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/StructDefinition.java
  11. 6
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CallArguments.java
  12. 32
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CastExpression.java
  13. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/Expression.java
  14. 2
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ExpressionVisitor.java
  15. 8
    3
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/CasterMember.java
  16. 4
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/DefinitionMember.java
  17. 3
    4
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/FieldMember.java
  18. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ICasterMember.java
  19. 1
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/partial/PartialStaticMemberGroupExpression.java
  20. 5
    6
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/member/TypeMemberBuilder.java
  21. 6
    6
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/member/TypeMembers.java
  22. 11
    2
      JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/JavaExpressionVisitor.java
  23. 1
    1
      Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedAlias.java
  24. 1
    1
      Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedClass.java
  25. 1
    1
      Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedEnum.java
  26. 1
    1
      Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedExpansion.java
  27. 1
    1
      Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedFunction.java
  28. 1
    1
      Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedInterface.java
  29. 1
    1
      Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedStruct.java
  30. 2
    1
      Parser/src/main/java/org/openzen/zenscript/parser/member/ParsedField.java
  31. 24
    7
      ScriptingExample/src/main/java/org/openzen/zenscript/scriptingexample/GlobalRegistry.java
  32. 4
    3
      ScriptingExample/src/main/java/org/openzen/zenscript/scriptingexample/Main.java

+ 15
- 11
CodeFormatter/src/main/java/org/openzen/zenscript/formatter/ExpressionFormatter.java Прегледај датотеку

@@ -16,6 +16,7 @@ import org.openzen.zenscript.codemodel.expression.CapturedDirectExpression;
16 16
 import org.openzen.zenscript.codemodel.expression.CapturedLocalVariableExpression;
17 17
 import org.openzen.zenscript.codemodel.expression.CapturedParameterExpression;
18 18
 import org.openzen.zenscript.codemodel.expression.CapturedThisExpression;
19
+import org.openzen.zenscript.codemodel.expression.CastExpression;
19 20
 import org.openzen.zenscript.codemodel.expression.CheckNullExpression;
20 21
 import org.openzen.zenscript.codemodel.expression.CoalesceExpression;
21 22
 import org.openzen.zenscript.codemodel.expression.ConditionalExpression;
@@ -63,7 +64,6 @@ import org.openzen.zenscript.codemodel.expression.StaticGetterExpression;
63 64
 import org.openzen.zenscript.codemodel.expression.StaticSetterExpression;
64 65
 import org.openzen.zenscript.codemodel.expression.ThisExpression;
65 66
 import org.openzen.zenscript.codemodel.expression.WrapOptionalExpression;
66
-import org.openzen.zenscript.codemodel.member.CasterMember;
67 67
 import org.openzen.zenscript.codemodel.member.OperatorMember;
68 68
 import org.openzen.zenscript.codemodel.type.ITypeID;
69 69
 import org.openzen.zenscript.shared.StringUtils;
@@ -232,16 +232,6 @@ public class ExpressionFormatter implements ExpressionVisitor<ExpressionString>
232 232
 				default:
233 233
 					throw new UnsupportedOperationException("Unknown operator: " + operator.operator);
234 234
 			}
235
-		} else if (expression.member instanceof CasterMember) {
236
-			CasterMember casterMember = (CasterMember) expression.member;
237
-			
238
-			StringBuilder result = new StringBuilder();
239
-			result.append(expression.target.accept(this).value);
240
-			if (!casterMember.isImplicit()) {
241
-				result.append(" as ");
242
-				result.append(casterMember.toType.accept(typeFormatter));
243
-			}
244
-			return new ExpressionString(result.toString(), OperatorPriority.PRIMARY);
245 235
 		} else {
246 236
 			StringBuilder result = new StringBuilder();
247 237
 			result.append(expression.target.accept(this).value);
@@ -263,6 +253,9 @@ public class ExpressionFormatter implements ExpressionVisitor<ExpressionString>
263 253
 	}
264 254
 	
265 255
 	private void format(StringBuilder result, CallArguments arguments) {
256
+		if (arguments == null || arguments.typeArguments == null)
257
+			throw new IllegalArgumentException("Arguments cannot be null!");
258
+		
266 259
 		if (arguments.typeArguments.length > 0) {
267 260
 			result.append("<");
268 261
 			
@@ -310,6 +303,17 @@ public class ExpressionFormatter implements ExpressionVisitor<ExpressionString>
310 303
 	public ExpressionString visitCapturedThis(CapturedThisExpression expression) {
311 304
 		return new ExpressionString("this", OperatorPriority.PRIMARY);
312 305
 	}
306
+	
307
+	@Override
308
+	public ExpressionString visitCast(CastExpression expression) {
309
+		StringBuilder result = new StringBuilder();
310
+		result.append(expression.target.accept(this).value);
311
+		if (!expression.isImplicit) {
312
+			result.append(" as ");
313
+			result.append(expression.member.toType.accept(typeFormatter));
314
+		}
315
+		return new ExpressionString(result.toString(), OperatorPriority.PRIMARY);
316
+	}
313 317
 
314 318
 	@Override
315 319
 	public ExpressionString visitCheckNull(CheckNullExpression expression) {

+ 2
- 2
CodeFormatter/src/main/java/org/openzen/zenscript/formatter/OperatorPriority.java Прегледај датотеку

@@ -64,10 +64,10 @@ public enum OperatorPriority {
64 64
 	}
65 65
 	
66 66
 	public static boolean shouldWrapLeft(OperatorPriority inner, OperatorPriority outer) {
67
-		return inner == outer || inner.priority > outer.priority;
67
+		return inner == outer || inner.priority <= outer.priority;
68 68
 	}
69 69
 	
70 70
 	public static boolean shouldWrapRight(OperatorPriority inner, OperatorPriority outer) {
71
-		return (inner == outer && inner.isCommutative) || (inner.priority > outer.priority);
71
+		return (inner == outer && inner.isCommutative) || (inner.priority <= outer.priority);
72 72
 	}
73 73
 }

+ 4
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/HighLevelDefinition.java Прегледај датотеку

@@ -13,6 +13,7 @@ import org.openzen.zenscript.codemodel.generic.TypeParameter;
13 13
 import org.openzen.zenscript.codemodel.member.FieldMember;
14 14
 import org.openzen.zenscript.codemodel.member.IDefinitionMember;
15 15
 import org.openzen.zenscript.codemodel.type.ITypeID;
16
+import org.openzen.zenscript.shared.CodePosition;
16 17
 import org.openzen.zenscript.shared.Taggable;
17 18
 
18 19
 /**
@@ -20,6 +21,7 @@ import org.openzen.zenscript.shared.Taggable;
20 21
  * @author Hoofdgebruiker
21 22
  */
22 23
 public abstract class HighLevelDefinition extends Taggable {
24
+	public final CodePosition position;
23 25
 	public final ZSPackage pkg;
24 26
 	public final String name;
25 27
 	public final int modifiers;
@@ -29,7 +31,8 @@ public abstract class HighLevelDefinition extends Taggable {
29 31
 	public HighLevelDefinition outerDefinition;
30 32
 	public ITypeID superType;
31 33
 	
32
-	public HighLevelDefinition(ZSPackage pkg, String name, int modifiers, HighLevelDefinition outerDefinition) {
34
+	public HighLevelDefinition(CodePosition position, ZSPackage pkg, String name, int modifiers, HighLevelDefinition outerDefinition) {
35
+		this.position = position;
33 36
 		this.pkg = pkg;
34 37
 		this.name = name;
35 38
 		this.modifiers = modifiers;

+ 3
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/AliasDefinition.java Прегледај датотеку

@@ -7,6 +7,7 @@ package org.openzen.zenscript.codemodel.definition;
7 7
 
8 8
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
9 9
 import org.openzen.zenscript.codemodel.type.ITypeID;
10
+import org.openzen.zenscript.shared.CodePosition;
10 11
 
11 12
 /**
12 13
  *
@@ -15,8 +16,8 @@ import org.openzen.zenscript.codemodel.type.ITypeID;
15 16
 public class AliasDefinition extends HighLevelDefinition {
16 17
 	public ITypeID type;
17 18
 	
18
-	public AliasDefinition(ZSPackage pkg, String name, int modifiers, HighLevelDefinition outerDefinition) {
19
-		super(pkg, name, modifiers, outerDefinition);
19
+	public AliasDefinition(CodePosition position, ZSPackage pkg, String name, int modifiers, HighLevelDefinition outerDefinition) {
20
+		super(position, pkg, name, modifiers, outerDefinition);
20 21
 	}
21 22
 	
22 23
 	public void setType(ITypeID type) {

+ 5
- 4
CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/ClassDefinition.java Прегледај датотеку

@@ -7,18 +7,19 @@ package org.openzen.zenscript.codemodel.definition;
7 7
 
8 8
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
9 9
 import org.openzen.zenscript.codemodel.type.ITypeID;
10
+import org.openzen.zenscript.shared.CodePosition;
10 11
 
11 12
 /**
12 13
  *
13 14
  * @author Hoofdgebruiker
14 15
  */
15 16
 public class ClassDefinition extends HighLevelDefinition {
16
-	public ClassDefinition(ZSPackage pkg, String name, int modifiers) {
17
-		this(pkg, name, modifiers, null);
17
+	public ClassDefinition(CodePosition position, ZSPackage pkg, String name, int modifiers) {
18
+		this(position, pkg, name, modifiers, null);
18 19
 	}
19 20
 	
20
-	public ClassDefinition(ZSPackage pkg, String name, int modifiers, HighLevelDefinition outerDefinition) {
21
-		super(pkg, name, modifiers, outerDefinition);
21
+	public ClassDefinition(CodePosition position, ZSPackage pkg, String name, int modifiers, HighLevelDefinition outerDefinition) {
22
+		super(position, pkg, name, modifiers, outerDefinition);
22 23
 	}
23 24
 	
24 25
 	public void setSuperclass(ITypeID superclass) {

+ 3
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/EnumDefinition.java Прегледај датотеку

@@ -6,14 +6,15 @@
6 6
 package org.openzen.zenscript.codemodel.definition;
7 7
 
8 8
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
9
+import org.openzen.zenscript.shared.CodePosition;
9 10
 
10 11
 /**
11 12
  *
12 13
  * @author Hoofdgebruiker
13 14
  */
14 15
 public class EnumDefinition extends HighLevelDefinition {
15
-	public EnumDefinition(ZSPackage pkg, String name, int modifiers, HighLevelDefinition outerDefinition) {
16
-		super(pkg, name, modifiers, outerDefinition);
16
+	public EnumDefinition(CodePosition position, ZSPackage pkg, String name, int modifiers, HighLevelDefinition outerDefinition) {
17
+		super(position, pkg, name, modifiers, outerDefinition);
17 18
 	}
18 19
 
19 20
 	@Override

+ 3
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/ExpansionDefinition.java Прегледај датотеку

@@ -7,6 +7,7 @@ package org.openzen.zenscript.codemodel.definition;
7 7
 
8 8
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
9 9
 import org.openzen.zenscript.codemodel.type.ITypeID;
10
+import org.openzen.zenscript.shared.CodePosition;
10 11
 
11 12
 /**
12 13
  *
@@ -15,8 +16,8 @@ import org.openzen.zenscript.codemodel.type.ITypeID;
15 16
 public class ExpansionDefinition extends HighLevelDefinition {
16 17
 	public ITypeID target;
17 18
 	
18
-	public ExpansionDefinition(ZSPackage pkg, int modifiers, HighLevelDefinition outerDefinition) {
19
-		super(pkg, null, modifiers, outerDefinition);
19
+	public ExpansionDefinition(CodePosition position, ZSPackage pkg, int modifiers, HighLevelDefinition outerDefinition) {
20
+		super(position, pkg, null, modifiers, outerDefinition);
20 21
 	}
21 22
 
22 23
 	@Override

+ 18
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/FunctionDefinition.java Прегледај датотеку

@@ -8,7 +8,13 @@ package org.openzen.zenscript.codemodel.definition;
8 8
 import java.util.List;
9 9
 import org.openzen.zenscript.codemodel.FunctionHeader;
10 10
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
11
+import org.openzen.zenscript.codemodel.Modifiers;
12
+import org.openzen.zenscript.codemodel.OperatorType;
13
+import org.openzen.zenscript.codemodel.member.OperatorMember;
11 14
 import org.openzen.zenscript.codemodel.statement.Statement;
15
+import org.openzen.zenscript.codemodel.type.member.DefinitionMemberGroup;
16
+import org.openzen.zenscript.codemodel.type.member.TypeMemberPriority;
17
+import org.openzen.zenscript.shared.CodePosition;
12 18
 
13 19
 /**
14 20
  *
@@ -17,17 +23,27 @@ import org.openzen.zenscript.codemodel.statement.Statement;
17 23
 public class FunctionDefinition extends HighLevelDefinition {
18 24
 	public FunctionHeader header;
19 25
 	public List<Statement> statements;
26
+	public OperatorMember caller;
27
+	public DefinitionMemberGroup callerGroup = new DefinitionMemberGroup();
20 28
 	
21
-	public FunctionDefinition(ZSPackage pkg, String name, int modifiers, HighLevelDefinition outerDefinition) {
22
-		super(pkg, name, modifiers, outerDefinition);
29
+	public FunctionDefinition(CodePosition position, ZSPackage pkg, String name, int modifiers, HighLevelDefinition outerDefinition) {
30
+		super(position, pkg, name, modifiers, outerDefinition);
31
+	}
32
+	
33
+	public FunctionDefinition(CodePosition position, ZSPackage pkg, String name, int modifiers, FunctionHeader header) {
34
+		this(position, pkg, name, modifiers, (HighLevelDefinition) null);
35
+		setHeader(header);
23 36
 	}
24 37
 	
25 38
 	public void setHeader(FunctionHeader header) {
26 39
 		this.header = header;
40
+		addMember(caller = new OperatorMember(position, modifiers | Modifiers.MODIFIER_STATIC, OperatorType.CALL, header));
41
+		callerGroup.addMethod(caller, TypeMemberPriority.SPECIFIED);
27 42
 	}
28 43
 	
29 44
 	public void setCode(List<Statement> statements) {
30 45
 		this.statements = statements;
46
+		caller.setBody(statements);
31 47
 	}
32 48
 
33 49
 	@Override

+ 3
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/InterfaceDefinition.java Прегледај датотеку

@@ -9,6 +9,7 @@ import java.util.ArrayList;
9 9
 import java.util.List;
10 10
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
11 11
 import org.openzen.zenscript.codemodel.type.ITypeID;
12
+import org.openzen.zenscript.shared.CodePosition;
12 13
 
13 14
 /**
14 15
  *
@@ -17,8 +18,8 @@ import org.openzen.zenscript.codemodel.type.ITypeID;
17 18
 public class InterfaceDefinition extends HighLevelDefinition {
18 19
 	private final List<ITypeID> baseInterfaces = new ArrayList<>();
19 20
 	
20
-	public InterfaceDefinition(ZSPackage pkg, String name, int modifiers, HighLevelDefinition outerDefinition) {
21
-		super(pkg, name, modifiers, outerDefinition);
21
+	public InterfaceDefinition(CodePosition position, ZSPackage pkg, String name, int modifiers, HighLevelDefinition outerDefinition) {
22
+		super(position, pkg, name, modifiers, outerDefinition);
22 23
 	}
23 24
 	
24 25
 	public void addBaseInterface(ITypeID baseInterface) {

+ 3
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/StructDefinition.java Прегледај датотеку

@@ -6,14 +6,15 @@
6 6
 package org.openzen.zenscript.codemodel.definition;
7 7
 
8 8
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
9
+import org.openzen.zenscript.shared.CodePosition;
9 10
 
10 11
 /**
11 12
  *
12 13
  * @author Hoofdgebruiker
13 14
  */
14 15
 public class StructDefinition extends HighLevelDefinition {
15
-	public StructDefinition(ZSPackage pkg, String name, int modifiers, HighLevelDefinition outerDefinition) {
16
-		super(pkg, name, modifiers, outerDefinition);
16
+	public StructDefinition(CodePosition position, ZSPackage pkg, String name, int modifiers, HighLevelDefinition outerDefinition) {
17
+		super(position, pkg, name, modifiers, outerDefinition);
17 18
 	}
18 19
 
19 20
 	@Override

+ 6
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CallArguments.java Прегледај датотеку

@@ -12,8 +12,8 @@ import org.openzen.zenscript.codemodel.type.ITypeID;
12 12
  * @author Hoofdgebruiker
13 13
  */
14 14
 public class CallArguments {
15
-	public static final CallArguments EMPTY = new CallArguments(new Expression[0]);
16 15
 	public static final ITypeID[] NO_TYPE_ARGUMENTS = new ITypeID[0];
16
+	public static final CallArguments EMPTY = new CallArguments(new Expression[0]);
17 17
 	
18 18
 	public final ITypeID[] typeArguments;
19 19
 	public final Expression[] arguments;
@@ -24,6 +24,11 @@ public class CallArguments {
24 24
 	}
25 25
 	
26 26
 	public CallArguments(ITypeID[] typeArguments, Expression[] arguments) {
27
+		if (typeArguments == null)
28
+			throw new IllegalArgumentException("Type arguments cannot be null!");
29
+		if (arguments == null)
30
+			throw new IllegalArgumentException("Arguments cannot be null!");
31
+		
27 32
 		this.typeArguments = typeArguments;
28 33
 		this.arguments = arguments;
29 34
 	}

+ 32
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/CastExpression.java Прегледај датотеку

@@ -0,0 +1,32 @@
1
+/*
2
+ * To change this license header, choose License Headers in Project Properties.
3
+ * To change this template file, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+package org.openzen.zenscript.codemodel.expression;
7
+
8
+import org.openzen.zenscript.codemodel.member.CasterMember;
9
+import org.openzen.zenscript.shared.CodePosition;
10
+
11
+/**
12
+ *
13
+ * @author Hoofdgebruiker
14
+ */
15
+public class CastExpression extends Expression {
16
+	public final Expression target;
17
+	public final CasterMember member;
18
+	public final boolean isImplicit;
19
+	
20
+	public CastExpression(CodePosition position, Expression target, CasterMember member, boolean isImplicit) {
21
+		super(position, member.getTargetType());
22
+		
23
+		this.target = target;
24
+		this.member = member;
25
+		this.isImplicit = isImplicit;
26
+	}
27
+
28
+	@Override
29
+	public <T> T accept(ExpressionVisitor<T> visitor) {
30
+		return visitor.visitCast(this);
31
+	}
32
+}

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/Expression.java Прегледај датотеку

@@ -51,7 +51,7 @@ public abstract class Expression implements IPartialExpression {
51 51
 	}
52 52
 	
53 53
 	public Expression castImplicit(CodePosition position, TypeScope scope, ITypeID asType) {
54
-		return scope.getTypeMembers(type).castImplicit(position, this, asType);
54
+		return scope.getTypeMembers(type).castImplicit(position, this, asType, true);
55 55
 	}
56 56
 	
57 57
 	@Override

+ 2
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ExpressionVisitor.java Прегледај датотеку

@@ -30,6 +30,8 @@ public interface ExpressionVisitor<T> {
30 30
 	
31 31
 	public T visitCapturedThis(CapturedThisExpression expression);
32 32
 	
33
+	public T visitCast(CastExpression expression);
34
+	
33 35
 	public T visitCheckNull(CheckNullExpression expression);
34 36
 	
35 37
 	public T visitCoalesce(CoalesceExpression expression);

+ 8
- 3
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/CasterMember.java Прегледај датотеку

@@ -9,7 +9,7 @@ import java.util.Map;
9 9
 import org.openzen.zenscript.codemodel.FunctionHeader;
10 10
 import org.openzen.zenscript.codemodel.Modifiers;
11 11
 import org.openzen.zenscript.codemodel.expression.CallArguments;
12
-import org.openzen.zenscript.codemodel.expression.CallExpression;
12
+import org.openzen.zenscript.codemodel.expression.CastExpression;
13 13
 import org.openzen.zenscript.codemodel.expression.Expression;
14 14
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
15 15
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
@@ -52,8 +52,13 @@ public class CasterMember extends FunctionalMember implements ICasterMember {
52 52
 	}
53 53
 
54 54
 	@Override
55
-	public Expression cast(CodePosition position, Expression value, ITypeID toType) {
56
-		return new CallExpression(position, value, this, header, CallArguments.EMPTY);
55
+	public Expression call(CodePosition position, Expression target, FunctionHeader instancedHeader, CallArguments arguments) {
56
+		throw new UnsupportedOperationException("Cannot call a caster!");
57
+	}
58
+
59
+	@Override
60
+	public Expression cast(CodePosition position, Expression value, boolean implicit) {
61
+		return new CastExpression(position, value, this, implicit);
57 62
 	}
58 63
 	
59 64
 	@Override

+ 4
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/DefinitionMember.java Прегледај датотеку

@@ -30,4 +30,8 @@ public abstract class DefinitionMember extends Taggable implements IDefinitionMe
30 30
 	public boolean isStatic() {
31 31
 		return Modifiers.isStatic(modifiers);
32 32
 	}
33
+	
34
+	public boolean isFinal() {
35
+		return Modifiers.isFinal(modifiers);
36
+	}
33 37
 }

+ 3
- 4
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/FieldMember.java Прегледај датотеку

@@ -6,6 +6,7 @@
6 6
 package org.openzen.zenscript.codemodel.member;
7 7
 
8 8
 import java.util.Map;
9
+import org.openzen.zenscript.codemodel.Modifiers;
9 10
 import org.openzen.zenscript.codemodel.expression.Expression;
10 11
 import org.openzen.zenscript.codemodel.generic.TypeParameter;
11 12
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
@@ -21,15 +22,13 @@ import org.openzen.zenscript.shared.CodePosition;
21 22
 public class FieldMember extends DefinitionMember {
22 23
 	public final String name;
23 24
 	public final ITypeID type;
24
-	public final boolean isFinal;
25 25
 	public Expression initializer;
26 26
 	
27
-	public FieldMember(CodePosition position, int modifiers, String name, ITypeID type, boolean isFinal) {
27
+	public FieldMember(CodePosition position, int modifiers, String name, ITypeID type) {
28 28
 		super(position, modifiers);
29 29
 		
30 30
 		this.name = name;
31 31
 		this.type = type;
32
-		this.isFinal = isFinal;
33 32
 	}
34 33
 	
35 34
 	public void setInitializer(Expression initializer) {
@@ -43,7 +42,7 @@ public class FieldMember extends DefinitionMember {
43 42
 
44 43
 	@Override
45 44
 	public DefinitionMember instance(GlobalTypeRegistry registry, Map<TypeParameter, ITypeID> mapping) {
46
-		return new FieldMember(position, modifiers, name, type.withGenericArguments(registry, mapping), isFinal);
45
+		return new FieldMember(position, modifiers, name, type.withGenericArguments(registry, mapping));
47 46
 	}
48 47
 
49 48
 	@Override

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/ICasterMember.java Прегледај датотеку

@@ -16,7 +16,7 @@ import org.openzen.zenscript.shared.CodePosition;
16 16
 public interface ICasterMember extends IDefinitionMember {
17 17
 	public ITypeID getTargetType();
18 18
 	
19
-	public Expression cast(CodePosition position, Expression value, ITypeID toType);
19
+	public Expression cast(CodePosition position, Expression value, boolean implicit);
20 20
 	
21 21
 	public boolean isImplicit();
22 22
 }

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/partial/PartialStaticMemberGroupExpression.java Прегледај датотеку

@@ -62,7 +62,7 @@ public class PartialStaticMemberGroupExpression implements IPartialExpression {
62 62
 
63 63
 	@Override
64 64
 	public Expression call(CodePosition position, TypeScope scope, List<ITypeID> hints, CallArguments arguments) {
65
-		throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
65
+		return group.callStatic(position, scope, arguments);
66 66
 	}
67 67
 	
68 68
 	@Override

+ 5
- 6
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/member/TypeMemberBuilder.java Прегледај датотеку

@@ -16,7 +16,6 @@ import org.openzen.zenscript.codemodel.OperatorType;
16 16
 import org.openzen.zenscript.codemodel.definition.ClassDefinition;
17 17
 import org.openzen.zenscript.codemodel.definition.EnumDefinition;
18 18
 import org.openzen.zenscript.codemodel.definition.StructDefinition;
19
-import org.openzen.zenscript.codemodel.expression.CallArguments;
20 19
 import org.openzen.zenscript.codemodel.expression.CallTranslator;
21 20
 import org.openzen.zenscript.codemodel.expression.ConstantCharExpression;
22 21
 import org.openzen.zenscript.codemodel.expression.ConstantUIntExpression;
@@ -144,7 +143,7 @@ public class TypeMemberBuilder implements ITypeVisitor<Void> {
144 143
 			FunctionHeader addHeader = new FunctionHeader(VOID, new FunctionParameter(baseType, "value"));
145 144
 			members.addMethod(new MethodMember(CodePosition.BUILTIN, 0, "add", addHeader), TypeMemberPriority.SPECIFIED);
146 145
 
147
-			members.addField(new FieldMember(CodePosition.BUILTIN, 0, "length", INT, false), TypeMemberPriority.SPECIFIED);
146
+			members.addField(new FieldMember(CodePosition.BUILTIN, Modifiers.MODIFIER_FINAL, "length", INT), TypeMemberPriority.SPECIFIED);
148 147
 		}
149 148
 
150 149
 		members.addGetter(new GetterMember(CodePosition.BUILTIN, 0, "empty", BOOL), TypeMemberPriority.SPECIFIED);
@@ -172,7 +171,7 @@ public class TypeMemberBuilder implements ITypeVisitor<Void> {
172 171
 		
173 172
 		members.addOperator(new OperatorMember(BUILTIN, 0, OperatorType.CONTAINS, new FunctionHeader(BOOL, new FunctionParameter(keyType, "key"))), TypeMemberPriority.SPECIFIED);
174 173
 
175
-		members.addField(new FieldMember(BUILTIN, 0, "length", INT, true), TypeMemberPriority.SPECIFIED);
174
+		members.addField(new FieldMember(BUILTIN, Modifiers.MODIFIER_FINAL, "length", INT), TypeMemberPriority.SPECIFIED);
176 175
 		members.addGetter(new GetterMember(BUILTIN, 0, "empty", BOOL), TypeMemberPriority.SPECIFIED);
177 176
 		members.addGetter(new GetterMember(BUILTIN, 0, "keys", cache.getRegistry().getArray(keyType, 1)), TypeMemberPriority.SPECIFIED);
178 177
 		return null;
@@ -252,8 +251,8 @@ public class TypeMemberBuilder implements ITypeVisitor<Void> {
252 251
 		ITypeID fromType = range.from;
253 252
 		ITypeID toType = range.to;
254 253
 
255
-		members.addField(new FieldMember(BUILTIN, 0, "from", fromType, true), TypeMemberPriority.SPECIFIED);
256
-		members.addField(new FieldMember(BUILTIN, 0, "to", toType, true), TypeMemberPriority.SPECIFIED);
254
+		members.addField(new FieldMember(BUILTIN, Modifiers.MODIFIER_FINAL, "from", fromType), TypeMemberPriority.SPECIFIED);
255
+		members.addField(new FieldMember(BUILTIN, Modifiers.MODIFIER_FINAL, "to", toType), TypeMemberPriority.SPECIFIED);
257 256
 		members.addIterator(new RangeIterator(range), TypeMemberPriority.SPECIFIED);
258 257
 		return null;
259 258
 	}
@@ -478,6 +477,6 @@ public class TypeMemberBuilder implements ITypeVisitor<Void> {
478 477
 	}
479 478
 	
480 479
 	private static CallTranslator castedTargetCall(FunctionalMember member, CasterMember caster) {
481
-		return call -> member.call(call.position, caster.call(call.position, call.target, CallArguments.EMPTY), call.arguments);
480
+		return call -> member.call(call.position, caster.cast(call.position, call.target, true), call.arguments);
482 481
 	}
483 482
 }

+ 6
- 6
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/member/TypeMembers.java Прегледај датотеку

@@ -305,7 +305,7 @@ public final class TypeMembers {
305 305
 		return false;
306 306
 	}
307 307
 	
308
-	public Expression castImplicit(CodePosition position, Expression value, ITypeID toType) {
308
+	public Expression castImplicit(CodePosition position, Expression value, ITypeID toType, boolean implicit) {
309 309
 		if (toType == type || toType == BasicTypeID.UNDETERMINED)
310 310
 			return value;
311 311
 		if (toType == null)
@@ -314,15 +314,15 @@ public final class TypeMembers {
314 314
 		if (type == BasicTypeID.NULL && toType.isOptional())
315 315
 			return new NullExpression(position, toType);
316 316
 		if (toType.isOptional() && canCastImplicit(toType.unwrap()))
317
-			return new WrapOptionalExpression(position, castImplicit(position, value, toType.unwrap()), toType);
317
+			return new WrapOptionalExpression(position, castImplicit(position, value, toType.unwrap(), implicit), toType);
318 318
 		if (toType.isConst() && canCastImplicit(toType.unwrap()))
319
-			return new MakeConstExpression(position, castImplicit(position, value, toType.unwrap()), toType);
319
+			return new MakeConstExpression(position, castImplicit(position, value, toType.unwrap(), implicit), toType);
320 320
 		if (type.isOptional() && type.unwrap() == toType)
321 321
 			return new CheckNullExpression(position, value);
322 322
 		
323 323
 		for (TypeMember<ICasterMember> caster : casters) {
324 324
 			if (caster.member.isImplicit() && toType == caster.member.getTargetType())
325
-				return caster.member.cast(position, value, toType);
325
+				return caster.member.cast(position, value, implicit);
326 326
 		}
327 327
 		for (TypeMember<ImplementationMember> implementation : implementations) {
328 328
 			if (implementation.member.type == toType)
@@ -334,11 +334,11 @@ public final class TypeMembers {
334 334
 	
335 335
 	public Expression castExplicit(CodePosition position, Expression value, ITypeID toType, boolean optional) {
336 336
 		if (this.canCastImplicit(toType))
337
-			return castImplicit(position, value, toType);
337
+			return castImplicit(position, value, toType, false);
338 338
 		
339 339
 		for (TypeMember<ICasterMember> caster : casters)
340 340
 			if (toType == caster.member.getTargetType())
341
-				return caster.member.cast(position, value, toType);
341
+				return caster.member.cast(position, value, false);
342 342
 		
343 343
 		throw new CompileException(position, CompileExceptionCode.INVALID_CAST, "Cannot cast " + toString() + " to " + toType + ", even explicitly");
344 344
 	}

+ 11
- 2
JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/JavaExpressionVisitor.java Прегледај датотеку

@@ -85,6 +85,15 @@ public class JavaExpressionVisitor implements ExpressionVisitor<Void> {
85 85
     public Void visitCapturedThis(CapturedThisExpression expression) {
86 86
         return null;
87 87
     }
88
+	
89
+	@Override
90
+    public Void visitCast(CastExpression expression) {
91
+		expression.target.accept(this);
92
+        if (!checkAndExecuteByteCodeImplementation(expression.member) && !checkAndExecuteMethodInfo(expression.member))
93
+            throw new IllegalStateException("Call target has no method info!");
94
+		
95
+        return null;
96
+	}
88 97
 
89 98
     @Override
90 99
     public Void visitCheckNull(CheckNullExpression expression) {
@@ -326,7 +335,7 @@ public class JavaExpressionVisitor implements ExpressionVisitor<Void> {
326 335
 
327 336
     @Override
328 337
     public Void visitSetField(SetFieldExpression expression) {
329
-        if (expression.field.isFinal)
338
+        if (expression.field.isFinal())
330 339
             throw new CompileException(expression.position, CompileExceptionCode.CANNOT_SET_FINAL_VARIABLE, "Cannot set a final field!");
331 340
         expression.value.accept(this);
332 341
         if (!checkAndPutFieldInfo(expression.field, false))
@@ -353,7 +362,7 @@ public class JavaExpressionVisitor implements ExpressionVisitor<Void> {
353 362
 
354 363
     @Override
355 364
     public Void visitSetStaticField(SetStaticFieldExpression expression) {
356
-        if (expression.field.isFinal)
365
+        if (expression.field.isFinal())
357 366
             throw new CompileException(expression.position, CompileExceptionCode.CANNOT_SET_FINAL_VARIABLE, "Cannot set a final field!");
358 367
         expression.value.accept(this);
359 368
         if (!checkAndPutFieldInfo(expression.field, true))

+ 1
- 1
Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedAlias.java Прегледај датотеку

@@ -43,7 +43,7 @@ public class ParsedAlias extends ParsedDefinition {
43 43
 		this.parameters = parameters;
44 44
 		this.type = type;
45 45
 		
46
-		compiled = new AliasDefinition(pkg, name, modifiers, outerDefinition);
46
+		compiled = new AliasDefinition(position, pkg, name, modifiers, outerDefinition);
47 47
 	}
48 48
 	
49 49
 	@Override

+ 1
- 1
Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedClass.java Прегледај датотеку

@@ -52,7 +52,7 @@ public class ParsedClass extends BaseParsedDefinition {
52 52
 		this.genericParameters = genericParameters;
53 53
 		this.superclass = superclass;
54 54
 		
55
-		compiled = new ClassDefinition(pkg, name, modifiers, outerDefinition);
55
+		compiled = new ClassDefinition(position, pkg, name, modifiers, outerDefinition);
56 56
 		for (ParsedGenericParameter parameter : genericParameters)
57 57
 			compiled.addGenericParameter(parameter.compiled);
58 58
 	}

+ 1
- 1
Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedEnum.java Прегледај датотеку

@@ -51,7 +51,7 @@ public class ParsedEnum extends BaseParsedDefinition {
51 51
 		
52 52
 		this.enumValues = enumValues;
53 53
 		
54
-		compiled = new EnumDefinition(pkg, name, modifiers, outerDefinition);
54
+		compiled = new EnumDefinition(position, pkg, name, modifiers, outerDefinition);
55 55
 	}
56 56
 
57 57
 	@Override

+ 1
- 1
Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedExpansion.java Прегледај датотеку

@@ -45,7 +45,7 @@ public class ParsedExpansion extends BaseParsedDefinition {
45 45
 		this.parameters = parameters;
46 46
 		this.target = target;
47 47
 		
48
-		this.compiled = new ExpansionDefinition(pkg, modifiers, outerDefinition);
48
+		this.compiled = new ExpansionDefinition(position, pkg, modifiers, outerDefinition);
49 49
 		for (ParsedGenericParameter parameter : parameters)
50 50
 			compiled.addGenericParameter(parameter.compiled);
51 51
 	}

+ 1
- 1
Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedFunction.java Прегледај датотеку

@@ -41,7 +41,7 @@ public class ParsedFunction extends ParsedDefinition {
41 41
 		this.header = header;
42 42
 		this.body = body;
43 43
 		
44
-		compiled = new FunctionDefinition(pkg, name, modifiers, outerDefinition);
44
+		compiled = new FunctionDefinition(position, pkg, name, modifiers, outerDefinition);
45 45
 	}
46 46
 
47 47
 	@Override

+ 1
- 1
Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedInterface.java Прегледај датотеку

@@ -54,7 +54,7 @@ public class ParsedInterface extends BaseParsedDefinition {
54 54
 		this.genericParameters = genericParameters;
55 55
 		this.superInterfaces = superInterfaces;
56 56
 		
57
-		compiled = new InterfaceDefinition(pkg, name, modifiers, outerDefinition);
57
+		compiled = new InterfaceDefinition(position, pkg, name, modifiers, outerDefinition);
58 58
 	}
59 59
 
60 60
 	@Override

+ 1
- 1
Parser/src/main/java/org/openzen/zenscript/parser/definitions/ParsedStruct.java Прегледај датотеку

@@ -42,7 +42,7 @@ public class ParsedStruct extends BaseParsedDefinition {
42 42
 		
43 43
 		this.parameters = parameters;
44 44
 		
45
-		compiled = new StructDefinition(pkg, name, modifiers, outerDefinition);
45
+		compiled = new StructDefinition(position, pkg, name, modifiers, outerDefinition);
46 46
 		for (ParsedGenericParameter parameter : parameters)
47 47
 			compiled.addGenericParameter(parameter.compiled);
48 48
 	}

+ 2
- 1
Parser/src/main/java/org/openzen/zenscript/parser/member/ParsedField.java Прегледај датотеку

@@ -6,6 +6,7 @@
6 6
 package org.openzen.zenscript.parser.member;
7 7
 
8 8
 import org.openzen.zenscript.codemodel.HighLevelDefinition;
9
+import org.openzen.zenscript.codemodel.Modifiers;
9 10
 import org.openzen.zenscript.codemodel.expression.Expression;
10 11
 import org.openzen.zenscript.codemodel.member.FieldMember;
11 12
 import org.openzen.zenscript.linker.BaseScope;
@@ -44,7 +45,7 @@ public class ParsedField extends ParsedDefinitionMember {
44 45
 
45 46
 	@Override
46 47
 	public void linkTypes(BaseScope scope) {
47
-		compiled = new FieldMember(position, modifiers, name, type.compile(scope), isFinal);
48
+		compiled = new FieldMember(position, modifiers | (isFinal ? Modifiers.MODIFIER_FINAL : 0), name, type.compile(scope));
48 49
 	}
49 50
 
50 51
 	@Override

+ 24
- 7
ScriptingExample/src/main/java/org/openzen/zenscript/scriptingexample/GlobalRegistry.java Прегледај датотеку

@@ -5,6 +5,7 @@
5 5
  */
6 6
 package org.openzen.zenscript.scriptingexample;
7 7
 
8
+import java.io.PrintStream;
8 9
 import java.util.ArrayList;
9 10
 import java.util.HashMap;
10 11
 import java.util.List;
@@ -14,6 +15,7 @@ import org.openzen.zenscript.codemodel.FunctionParameter;
14 15
 import org.openzen.zenscript.codemodel.Modifiers;
15 16
 import org.openzen.zenscript.codemodel.definition.ClassDefinition;
16 17
 import org.openzen.zenscript.codemodel.definition.ExpansionDefinition;
18
+import org.openzen.zenscript.codemodel.definition.FunctionDefinition;
17 19
 import org.openzen.zenscript.codemodel.definition.ZSPackage;
18 20
 import org.openzen.zenscript.codemodel.expression.GetStaticFieldExpression;
19 21
 import org.openzen.zenscript.codemodel.member.FieldMember;
@@ -25,6 +27,7 @@ import org.openzen.zenscript.codemodel.type.DefinitionTypeID;
25 27
 import org.openzen.zenscript.codemodel.type.FunctionTypeID;
26 28
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
27 29
 import org.openzen.zenscript.codemodel.type.ITypeID;
30
+import org.openzen.zenscript.javabytecode.JavaBytecodeImplementation;
28 31
 import org.openzen.zenscript.javabytecode.JavaClassInfo;
29 32
 import org.openzen.zenscript.javabytecode.JavaFieldInfo;
30 33
 import org.openzen.zenscript.javabytecode.JavaMethodInfo;
@@ -36,16 +39,22 @@ import org.openzen.zenscript.shared.CodePosition;
36 39
  * @author Hoofdgebruiker
37 40
  */
38 41
 public class GlobalRegistry {
42
+	public final ZSPackage globals = new ZSPackage("");
39 43
 	private final ZSPackage rootPackage = new ZSPackage("");
40 44
 	private final ZSPackage javaIo = rootPackage.getOrCreatePackage("java").getOrCreatePackage("io");
41 45
 	private final ZSPackage javaLang = rootPackage.getOrCreatePackage("java").getOrCreatePackage("lang");
42 46
 	
43
-	public GlobalRegistry() {
47
+	public GlobalRegistry(ZSPackage globals) {
44 48
 		JavaClassInfo jPrintStream = new JavaClassInfo("java/io/PrintStream");
45 49
 		PRINTSTREAM_PRINTLN.setTag(JavaMethodInfo.class, new JavaMethodInfo(jPrintStream, "println", "(Ljava/lang/String;)V"));
46 50
 		
47 51
 		JavaClassInfo jSystem = new JavaClassInfo("java/lang/System");
48 52
 		SYSTEM_OUT.setTag(JavaFieldInfo.class, new JavaFieldInfo(jSystem, "out", "Ljava/io/PrintStream;"));
53
+		
54
+		PRINTLN.caller.setTag(JavaBytecodeImplementation.class, writer -> {
55
+			writer.getField(System.class, "out", PrintStream.class);
56
+			writer.invokeVirtual("java/io/PrintStream", "println", "(Ljava/lang/String;)V");
57
+		});
49 58
 	}
50 59
 	
51 60
 	public ZSPackage collectPackages() {
@@ -55,7 +64,7 @@ public class GlobalRegistry {
55 64
 			// eg. package my.package with a class MyClass with a single native method test() returning a string
56 65
 			// the visitors can then during compilation check if a method is an instance of NativeMethodMember and treat it accordingly
57 66
 			ZSPackage packageMyPackage = rootPackage.getOrCreatePackage("my").getOrCreatePackage("package");
58
-			ClassDefinition myClassDefinition = new ClassDefinition(packageMyPackage, "MyClass", Modifiers.MODIFIER_PUBLIC, null);
67
+			ClassDefinition myClassDefinition = new ClassDefinition(CodePosition.NATIVE, packageMyPackage, "MyClass", Modifiers.MODIFIER_PUBLIC, null);
59 68
 			JavaClassInfo myClassInfo = new JavaClassInfo("my/test/MyClass");
60 69
 			
61 70
 			MethodMember member = new MethodMember(CodePosition.NATIVE, Modifiers.MODIFIER_PUBLIC, "test", new FunctionHeader(BasicTypeID.STRING));
@@ -83,8 +92,8 @@ public class GlobalRegistry {
83 92
 		return globals;
84 93
 	}
85 94
 	
86
-	private final ClassDefinition PRINTSTREAM = new ClassDefinition(javaIo, "PrintStream", Modifiers.MODIFIER_EXPORT);
87
-	private final ClassDefinition SYSTEM = new ClassDefinition(javaLang, "System", Modifiers.MODIFIER_EXPORT);
95
+	private final ClassDefinition PRINTSTREAM = new ClassDefinition(CodePosition.NATIVE, javaIo, "PrintStream", Modifiers.MODIFIER_EXPORT);
96
+	private final ClassDefinition SYSTEM = new ClassDefinition(CodePosition.NATIVE, javaLang, "System", Modifiers.MODIFIER_EXPORT);
88 97
 	private final MethodMember PRINTSTREAM_PRINTLN = new MethodMember(
89 98
 			CodePosition.NATIVE,
90 99
 			Modifiers.MODIFIER_EXPORT,
@@ -93,15 +102,23 @@ public class GlobalRegistry {
93 102
 	
94 103
 	private final FieldMember SYSTEM_OUT = new FieldMember(
95 104
 			CodePosition.NATIVE,
96
-			Modifiers.MODIFIER_EXPORT,
105
+			Modifiers.MODIFIER_EXPORT | Modifiers.MODIFIER_FINAL,
97 106
 			"out",
98
-			DefinitionTypeID.forType(SYSTEM),
99
-			true);
107
+			DefinitionTypeID.forType(SYSTEM));
108
+	
109
+	
110
+	private final FunctionDefinition PRINTLN = new FunctionDefinition(
111
+			CodePosition.NATIVE,
112
+			globals,
113
+			"println",
114
+			Modifiers.MODIFIER_EXPORT,
115
+			new FunctionHeader(BasicTypeID.VOID, new FunctionParameter(BasicTypeID.STRING)));
100 116
 	
101 117
 	private class PrintlnSymbol implements ISymbol {
102 118
 
103 119
 		@Override
104 120
 		public IPartialExpression getExpression(CodePosition position, GlobalTypeRegistry types, List<ITypeID> typeArguments) {
121
+			//return new PartialStaticMemberGroupExpression(position, PRINTLN.callerGroup);
105 122
 			return new PartialMemberGroupExpression(
106 123
 					position,
107 124
 					new GetStaticFieldExpression(position, SYSTEM_OUT),

+ 4
- 3
ScriptingExample/src/main/java/org/openzen/zenscript/scriptingexample/Main.java Прегледај датотеку

@@ -34,15 +34,16 @@ public class Main {
34 34
 		ZSPackage pkg = new ZSPackage("");
35 35
 		ParsedFile[] parsedFiles = parse(pkg, inputFiles);
36 36
 		
37
-		GlobalRegistry registry = new GlobalRegistry();
37
+		ZSPackage global = new ZSPackage("");
38
+		GlobalRegistry registry = new GlobalRegistry(global);
38 39
 		SemanticModule module = compileSyntaxToSemantic(parsedFiles, registry);
39 40
 		
40
-		FormattingSettings settings = new FormattingSettings.Builder().build();
41
+		/*FormattingSettings settings = new FormattingSettings.Builder().build();
41 42
 		for (ScriptBlock block : module.scripts) {
42 43
 			FileFormatter formatter = new FileFormatter(settings);
43 44
 			System.out.println("== " + block.getTag(SourceFile.class).filename + " ==");
44 45
 			System.out.println(formatter.format(pkg, block, Collections.emptyList()));
45
-		}
46
+		}*/
46 47
 		
47 48
 		JavaModule javaModule = compileSemanticToJava(module);
48 49
 		javaModule.execute();

Loading…
Откажи
Сачувај