Browse Source

Renamed values in Modifiers

Stan Hebben 6 years ago
parent
commit
e8bc10b5ba

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/HighLevelDefinition.java View File

65
 	}
65
 	}
66
 	
66
 	
67
 	public boolean isStatic() {
67
 	public boolean isStatic() {
68
-		return (modifiers & Modifiers.MODIFIER_STATIC) > 0;
68
+		return (modifiers & Modifiers.STATIC) > 0;
69
 	}
69
 	}
70
 	
70
 	
71
 	public abstract <T> T accept(DefinitionVisitor<T> visitor);
71
 	public abstract <T> T accept(DefinitionVisitor<T> visitor);

+ 17
- 15
CodeModel/src/main/java/org/openzen/zenscript/codemodel/Modifiers.java View File

10
  * @author Hoofdgebruiker
10
  * @author Hoofdgebruiker
11
  */
11
  */
12
 public class Modifiers {
12
 public class Modifiers {
13
-	public static final int MODIFIER_PUBLIC = 1;
14
-	public static final int MODIFIER_EXPORT = 2;
15
-	public static final int MODIFIER_PRIVATE = 4;
16
-	public static final int MODIFIER_ABSTRACT = 8;
17
-	public static final int MODIFIER_FINAL = 16;
18
-	public static final int MODIFIER_CONST = 32;
19
-	public static final int MODIFIER_CONST_OPTIONAL = 64;
20
-	public static final int MODIFIER_STATIC = 128;
21
-	public static final int MODIFIER_PROTECTED = 256;
22
-	public static final int MODIFIER_IMPLICIT = 512;
13
+	private Modifiers() {}
14
+	
15
+	public static final int PUBLIC = 1;
16
+	public static final int EXPORT = 2;
17
+	public static final int PRIVATE = 4;
18
+	public static final int ABSTRACT = 8;
19
+	public static final int FINAL = 16;
20
+	public static final int CONST = 32;
21
+	public static final int CONST_OPTIONAL = 64;
22
+	public static final int STATIC = 128;
23
+	public static final int PROTECTED = 256;
24
+	public static final int IMPLICIT = 512;
23
 	
25
 	
24
 	public static boolean isAbstract(int modifiers) {
26
 	public static boolean isAbstract(int modifiers) {
25
-		return (modifiers & MODIFIER_ABSTRACT) > 0;
27
+		return (modifiers & ABSTRACT) > 0;
26
 	}
28
 	}
27
 	
29
 	
28
 	public static boolean isFinal(int modifiers) {
30
 	public static boolean isFinal(int modifiers) {
29
-		return (modifiers & MODIFIER_FINAL) > 0;
31
+		return (modifiers & FINAL) > 0;
30
 	}
32
 	}
31
 	
33
 	
32
 	public static boolean isConst(int modifiers) {
34
 	public static boolean isConst(int modifiers) {
33
-		return (modifiers & MODIFIER_CONST) > 0;
35
+		return (modifiers & CONST) > 0;
34
 	}
36
 	}
35
 	
37
 	
36
 	public static boolean isStatic(int modifiers) {
38
 	public static boolean isStatic(int modifiers) {
37
-		return (modifiers & MODIFIER_STATIC) > 0;
39
+		return (modifiers & STATIC) > 0;
38
 	}
40
 	}
39
 	
41
 	
40
 	public static boolean isImplicit(int modifiers) {
42
 	public static boolean isImplicit(int modifiers) {
41
-		return (modifiers & MODIFIER_IMPLICIT) > 0;
43
+		return (modifiers & IMPLICIT) > 0;
42
 	}
44
 	}
43
 }
45
 }

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/definition/FunctionDefinition.java View File

37
 	
37
 	
38
 	public void setHeader(FunctionHeader header) {
38
 	public void setHeader(FunctionHeader header) {
39
 		this.header = header;
39
 		this.header = header;
40
-		addMember(caller = new OperatorMember(position, modifiers | Modifiers.MODIFIER_STATIC, OperatorType.CALL, header));
40
+		addMember(caller = new OperatorMember(position, modifiers | Modifiers.STATIC, OperatorType.CALL, header));
41
 		callerGroup.addMethod(caller, TypeMemberPriority.SPECIFIED);
41
 		callerGroup.addMethod(caller, TypeMemberPriority.SPECIFIED);
42
 	}
42
 	}
43
 	
43
 	

+ 1
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/member/EnumConstantMember.java View File

27
 	public NewExpression constructor;
27
 	public NewExpression constructor;
28
 	
28
 	
29
 	public EnumConstantMember(CodePosition position, String name, int value) {
29
 	public EnumConstantMember(CodePosition position, String name, int value) {
30
-		super(position, Modifiers.MODIFIER_STATIC);
30
+		super(position, Modifiers.STATIC);
31
 		
31
 		
32
 		this.name = name;
32
 		this.name = name;
33
 		this.value = value;
33
 		this.value = value;

+ 3
- 3
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/member/BuiltinTypeMembers.java View File

136
 	
136
 	
137
 	public static final GetterMember FLOAT_BITS = new GetterMember(BUILTIN, 0, "bits", UINT);
137
 	public static final GetterMember FLOAT_BITS = new GetterMember(BUILTIN, 0, "bits", UINT);
138
 	public static final GetterMember DOUBLE_BITS = new GetterMember(BUILTIN, 0, "bits", ULONG);
138
 	public static final GetterMember DOUBLE_BITS = new GetterMember(BUILTIN, 0, "bits", ULONG);
139
-	public static final MethodMember FLOAT_FROMBITS = new MethodMember(BUILTIN, Modifiers.MODIFIER_STATIC, "fromBits", new FunctionHeader(FLOAT, new FunctionParameter(UINT)));
140
-	public static final MethodMember DOUBLE_FROMBITS = new MethodMember(BUILTIN, Modifiers.MODIFIER_STATIC, "fromBits", new FunctionHeader(DOUBLE, new FunctionParameter(ULONG)));
139
+	public static final MethodMember FLOAT_FROMBITS = new MethodMember(BUILTIN, Modifiers.STATIC, "fromBits", new FunctionHeader(FLOAT, new FunctionParameter(UINT)));
140
+	public static final MethodMember DOUBLE_FROMBITS = new MethodMember(BUILTIN, Modifiers.STATIC, "fromBits", new FunctionHeader(DOUBLE, new FunctionParameter(ULONG)));
141
 	
141
 	
142
 	private static OperatorMember not(ITypeID result) {
142
 	private static OperatorMember not(ITypeID result) {
143
 		return new OperatorMember(BUILTIN, 0, OperatorType.NOT, new FunctionHeader(result));
143
 		return new OperatorMember(BUILTIN, 0, OperatorType.NOT, new FunctionHeader(result));
172
 	}
172
 	}
173
 	
173
 	
174
 	private static CasterMember castImplicit(ITypeID result) {
174
 	private static CasterMember castImplicit(ITypeID result) {
175
-		return new CasterMember(CodePosition.BUILTIN, Modifiers.MODIFIER_IMPLICIT, result);
175
+		return new CasterMember(CodePosition.BUILTIN, Modifiers.IMPLICIT, result);
176
 	}
176
 	}
177
 }
177
 }

+ 16
- 16
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/member/TypeMemberBuilder.java View File

143
 			FunctionHeader addHeader = new FunctionHeader(VOID, new FunctionParameter(baseType, "value"));
143
 			FunctionHeader addHeader = new FunctionHeader(VOID, new FunctionParameter(baseType, "value"));
144
 			members.addMethod(new MethodMember(CodePosition.BUILTIN, 0, "add", addHeader), TypeMemberPriority.SPECIFIED);
144
 			members.addMethod(new MethodMember(CodePosition.BUILTIN, 0, "add", addHeader), TypeMemberPriority.SPECIFIED);
145
 
145
 
146
-			members.addField(new FieldMember(CodePosition.BUILTIN, Modifiers.MODIFIER_FINAL, "length", INT), TypeMemberPriority.SPECIFIED);
146
+			members.addField(new FieldMember(CodePosition.BUILTIN, Modifiers.FINAL, "length", INT), TypeMemberPriority.SPECIFIED);
147
 		}
147
 		}
148
 
148
 
149
 		members.addGetter(new GetterMember(CodePosition.BUILTIN, 0, "empty", BOOL), TypeMemberPriority.SPECIFIED);
149
 		members.addGetter(new GetterMember(CodePosition.BUILTIN, 0, "empty", BOOL), TypeMemberPriority.SPECIFIED);
171
 		
171
 		
172
 		members.addOperator(new OperatorMember(BUILTIN, 0, OperatorType.CONTAINS, new FunctionHeader(BOOL, new FunctionParameter(keyType, "key"))), TypeMemberPriority.SPECIFIED);
172
 		members.addOperator(new OperatorMember(BUILTIN, 0, OperatorType.CONTAINS, new FunctionHeader(BOOL, new FunctionParameter(keyType, "key"))), TypeMemberPriority.SPECIFIED);
173
 
173
 
174
-		members.addField(new FieldMember(BUILTIN, Modifiers.MODIFIER_FINAL, "length", INT), TypeMemberPriority.SPECIFIED);
174
+		members.addField(new FieldMember(BUILTIN, Modifiers.FINAL, "length", INT), TypeMemberPriority.SPECIFIED);
175
 		members.addGetter(new GetterMember(BUILTIN, 0, "empty", BOOL), TypeMemberPriority.SPECIFIED);
175
 		members.addGetter(new GetterMember(BUILTIN, 0, "empty", BOOL), TypeMemberPriority.SPECIFIED);
176
 		members.addGetter(new GetterMember(BUILTIN, 0, "keys", cache.getRegistry().getArray(keyType, 1)), TypeMemberPriority.SPECIFIED);
176
 		members.addGetter(new GetterMember(BUILTIN, 0, "keys", cache.getRegistry().getArray(keyType, 1)), TypeMemberPriority.SPECIFIED);
177
 		return null;
177
 		return null;
211
 		if (constructors.getMethodMembers().isEmpty()) {
211
 		if (constructors.getMethodMembers().isEmpty()) {
212
 			if (definition instanceof ClassDefinition) {
212
 			if (definition instanceof ClassDefinition) {
213
 				// add default constructor
213
 				// add default constructor
214
-				constructors.addMethod(new ConstructorMember(BUILTIN, Modifiers.MODIFIER_PUBLIC, new FunctionHeader(VOID)), TypeMemberPriority.SPECIFIED);
214
+				constructors.addMethod(new ConstructorMember(BUILTIN, Modifiers.PUBLIC, new FunctionHeader(VOID)), TypeMemberPriority.SPECIFIED);
215
 			} else if (definition instanceof StructDefinition) {
215
 			} else if (definition instanceof StructDefinition) {
216
 				// add default struct constructors
216
 				// add default struct constructors
217
-				constructors.addMethod(new ConstructorMember(BUILTIN, Modifiers.MODIFIER_PUBLIC, new FunctionHeader(VOID)), TypeMemberPriority.SPECIFIED);
217
+				constructors.addMethod(new ConstructorMember(BUILTIN, Modifiers.PUBLIC, new FunctionHeader(VOID)), TypeMemberPriority.SPECIFIED);
218
 				
218
 				
219
 				List<FieldMember> fields = ((StructDefinition)definition).getFields();
219
 				List<FieldMember> fields = ((StructDefinition)definition).getFields();
220
 				if (!fields.isEmpty()) {
220
 				if (!fields.isEmpty()) {
227
 				}
227
 				}
228
 			} else if (definition instanceof EnumDefinition) {
228
 			} else if (definition instanceof EnumDefinition) {
229
 				// add default constructor
229
 				// add default constructor
230
-				constructors.addMethod(new ConstructorMember(BUILTIN, Modifiers.MODIFIER_PRIVATE, new FunctionHeader(VOID)), TypeMemberPriority.SPECIFIED);
230
+				constructors.addMethod(new ConstructorMember(BUILTIN, Modifiers.PRIVATE, new FunctionHeader(VOID)), TypeMemberPriority.SPECIFIED);
231
 			}
231
 			}
232
 		}
232
 		}
233
 		
233
 		
254
 		ITypeID fromType = range.from;
254
 		ITypeID fromType = range.from;
255
 		ITypeID toType = range.to;
255
 		ITypeID toType = range.to;
256
 
256
 
257
-		members.addField(new FieldMember(BUILTIN, Modifiers.MODIFIER_FINAL, "from", fromType), TypeMemberPriority.SPECIFIED);
258
-		members.addField(new FieldMember(BUILTIN, Modifiers.MODIFIER_FINAL, "to", toType), TypeMemberPriority.SPECIFIED);
257
+		members.addField(new FieldMember(BUILTIN, Modifiers.FINAL, "from", fromType), TypeMemberPriority.SPECIFIED);
258
+		members.addField(new FieldMember(BUILTIN, Modifiers.FINAL, "to", toType), TypeMemberPriority.SPECIFIED);
259
 		members.addIterator(new RangeIterator(range), TypeMemberPriority.SPECIFIED);
259
 		members.addIterator(new RangeIterator(range), TypeMemberPriority.SPECIFIED);
260
 		return null;
260
 		return null;
261
 	}
261
 	}
395
 		
395
 		
396
 		members.addCaster(new CasterMember(CodePosition.BUILTIN, 0, BasicTypeID.BYTE), TypeMemberPriority.SPECIFIED);
396
 		members.addCaster(new CasterMember(CodePosition.BUILTIN, 0, BasicTypeID.BYTE), TypeMemberPriority.SPECIFIED);
397
 		members.addCaster(new CasterMember(CodePosition.BUILTIN, 0, BasicTypeID.SBYTE), TypeMemberPriority.SPECIFIED);
397
 		members.addCaster(new CasterMember(CodePosition.BUILTIN, 0, BasicTypeID.SBYTE), TypeMemberPriority.SPECIFIED);
398
-		members.addCaster(new CasterMember(CodePosition.BUILTIN, Modifiers.MODIFIER_IMPLICIT, BasicTypeID.SHORT), TypeMemberPriority.SPECIFIED);
399
-		members.addCaster(new CasterMember(CodePosition.BUILTIN, Modifiers.MODIFIER_IMPLICIT, BasicTypeID.USHORT), TypeMemberPriority.SPECIFIED);
400
-		members.addCaster(new CasterMember(CodePosition.BUILTIN, Modifiers.MODIFIER_IMPLICIT, BasicTypeID.INT), TypeMemberPriority.SPECIFIED);
401
-		members.addCaster(new CasterMember(CodePosition.BUILTIN, Modifiers.MODIFIER_IMPLICIT, BasicTypeID.UINT), TypeMemberPriority.SPECIFIED);
402
-		members.addCaster(new CasterMember(CodePosition.BUILTIN, Modifiers.MODIFIER_IMPLICIT, BasicTypeID.LONG), TypeMemberPriority.SPECIFIED);
403
-		members.addCaster(new CasterMember(CodePosition.BUILTIN, Modifiers.MODIFIER_IMPLICIT, BasicTypeID.ULONG), TypeMemberPriority.SPECIFIED);
404
-		members.addCaster(new CasterMember(CodePosition.BUILTIN, Modifiers.MODIFIER_IMPLICIT, BasicTypeID.FLOAT), TypeMemberPriority.SPECIFIED);
405
-		members.addCaster(new CasterMember(CodePosition.BUILTIN, Modifiers.MODIFIER_IMPLICIT, BasicTypeID.DOUBLE), TypeMemberPriority.SPECIFIED);
406
-		members.addCaster(new CasterMember(CodePosition.BUILTIN, Modifiers.MODIFIER_IMPLICIT, BasicTypeID.STRING), TypeMemberPriority.SPECIFIED);
398
+		members.addCaster(new CasterMember(CodePosition.BUILTIN, Modifiers.IMPLICIT, BasicTypeID.SHORT), TypeMemberPriority.SPECIFIED);
399
+		members.addCaster(new CasterMember(CodePosition.BUILTIN, Modifiers.IMPLICIT, BasicTypeID.USHORT), TypeMemberPriority.SPECIFIED);
400
+		members.addCaster(new CasterMember(CodePosition.BUILTIN, Modifiers.IMPLICIT, BasicTypeID.INT), TypeMemberPriority.SPECIFIED);
401
+		members.addCaster(new CasterMember(CodePosition.BUILTIN, Modifiers.IMPLICIT, BasicTypeID.UINT), TypeMemberPriority.SPECIFIED);
402
+		members.addCaster(new CasterMember(CodePosition.BUILTIN, Modifiers.IMPLICIT, BasicTypeID.LONG), TypeMemberPriority.SPECIFIED);
403
+		members.addCaster(new CasterMember(CodePosition.BUILTIN, Modifiers.IMPLICIT, BasicTypeID.ULONG), TypeMemberPriority.SPECIFIED);
404
+		members.addCaster(new CasterMember(CodePosition.BUILTIN, Modifiers.IMPLICIT, BasicTypeID.FLOAT), TypeMemberPriority.SPECIFIED);
405
+		members.addCaster(new CasterMember(CodePosition.BUILTIN, Modifiers.IMPLICIT, BasicTypeID.DOUBLE), TypeMemberPriority.SPECIFIED);
406
+		members.addCaster(new CasterMember(CodePosition.BUILTIN, Modifiers.IMPLICIT, BasicTypeID.STRING), TypeMemberPriority.SPECIFIED);
407
 	}
407
 	}
408
 
408
 
409
 	private void visitString() {
409
 	private void visitString() {

+ 0
- 2
JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/JavaCompiler.java View File

69
 		implement(ULONG_ADD_ULONG, JavaWriter::lAdd);
69
 		implement(ULONG_ADD_ULONG, JavaWriter::lAdd);
70
 		implement(FLOAT_ADD_FLOAT, JavaWriter::fAdd);
70
 		implement(FLOAT_ADD_FLOAT, JavaWriter::fAdd);
71
 		implement(DOUBLE_ADD_DOUBLE, JavaWriter::dAdd);
71
 		implement(DOUBLE_ADD_DOUBLE, JavaWriter::dAdd);
72
-		// TODO: STRING_ADD_STRING
73
-
74
 		implement(STRING_ADD_STRING, JavaWriter::stringAdd);
72
 		implement(STRING_ADD_STRING, JavaWriter::stringAdd);
75
 		
73
 		
76
 		implement(BYTE_SUB_BYTE, JavaWriter::iSub);
74
 		implement(BYTE_SUB_BYTE, JavaWriter::iSub);

+ 7
- 7
Parser/src/main/java/org/openzen/zenscript/parser/ParsedFile.java View File

64
 			int modifiers = 0;
64
 			int modifiers = 0;
65
 			while (true) {
65
 			while (true) {
66
 				if (tokens.optional(K_PUBLIC) != null) {
66
 				if (tokens.optional(K_PUBLIC) != null) {
67
-					modifiers |= Modifiers.MODIFIER_PUBLIC;
67
+					modifiers |= Modifiers.PUBLIC;
68
 				} else if (tokens.optional(K_PRIVATE) != null) {
68
 				} else if (tokens.optional(K_PRIVATE) != null) {
69
-					modifiers |= Modifiers.MODIFIER_PRIVATE;
69
+					modifiers |= Modifiers.PRIVATE;
70
 				} else if (tokens.optional(K_EXPORT) != null) {
70
 				} else if (tokens.optional(K_EXPORT) != null) {
71
-					modifiers |= Modifiers.MODIFIER_EXPORT;
71
+					modifiers |= Modifiers.EXPORT;
72
 				} else if (tokens.optional(K_ABSTRACT) != null) {
72
 				} else if (tokens.optional(K_ABSTRACT) != null) {
73
-					modifiers |= Modifiers.MODIFIER_ABSTRACT;
73
+					modifiers |= Modifiers.ABSTRACT;
74
 				} else if (tokens.optional(K_FINAL) != null) {
74
 				} else if (tokens.optional(K_FINAL) != null) {
75
-					modifiers |= Modifiers.MODIFIER_FINAL;
75
+					modifiers |= Modifiers.FINAL;
76
 				} else if (tokens.optional(K_PROTECTED) != null) {
76
 				} else if (tokens.optional(K_PROTECTED) != null) {
77
-					modifiers |= Modifiers.MODIFIER_PROTECTED;
77
+					modifiers |= Modifiers.PROTECTED;
78
 				} else if (tokens.optional(K_IMPLICIT) != null) {
78
 				} else if (tokens.optional(K_IMPLICIT) != null) {
79
-					modifiers |= Modifiers.MODIFIER_IMPLICIT;
79
+					modifiers |= Modifiers.IMPLICIT;
80
 				} else {
80
 				} else {
81
 					break;
81
 					break;
82
 				}
82
 				}

+ 10
- 10
Parser/src/main/java/org/openzen/zenscript/parser/member/ParsedDefinitionMember.java View File

37
 		int modifiers = 0;
37
 		int modifiers = 0;
38
 		while (true) {
38
 		while (true) {
39
 			if (tokens.optional(ZSTokenType.K_EXPORT) != null) {
39
 			if (tokens.optional(ZSTokenType.K_EXPORT) != null) {
40
-				modifiers |= Modifiers.MODIFIER_EXPORT;
40
+				modifiers |= Modifiers.EXPORT;
41
 			} else if (tokens.optional(ZSTokenType.K_PUBLIC) != null) {
41
 			} else if (tokens.optional(ZSTokenType.K_PUBLIC) != null) {
42
-				modifiers |= Modifiers.MODIFIER_PUBLIC;
42
+				modifiers |= Modifiers.PUBLIC;
43
 			} else if (tokens.optional(ZSTokenType.K_PRIVATE) != null) {
43
 			} else if (tokens.optional(ZSTokenType.K_PRIVATE) != null) {
44
-				modifiers |= Modifiers.MODIFIER_PRIVATE;
44
+				modifiers |= Modifiers.PRIVATE;
45
 			} else if (tokens.optional(ZSTokenType.K_CONST) != null) {
45
 			} else if (tokens.optional(ZSTokenType.K_CONST) != null) {
46
 				if (tokens.optional(ZSTokenType.T_QUEST) != null) {
46
 				if (tokens.optional(ZSTokenType.T_QUEST) != null) {
47
-					modifiers |= Modifiers.MODIFIER_CONST_OPTIONAL;
47
+					modifiers |= Modifiers.CONST_OPTIONAL;
48
 				} else {
48
 				} else {
49
-					modifiers |= Modifiers.MODIFIER_CONST;
49
+					modifiers |= Modifiers.CONST;
50
 				}
50
 				}
51
 			} else if (tokens.optional(ZSTokenType.K_ABSTRACT) != null) {
51
 			} else if (tokens.optional(ZSTokenType.K_ABSTRACT) != null) {
52
-				modifiers |= Modifiers.MODIFIER_ABSTRACT;
52
+				modifiers |= Modifiers.ABSTRACT;
53
 			} else if (tokens.optional(ZSTokenType.K_FINAL) != null) {
53
 			} else if (tokens.optional(ZSTokenType.K_FINAL) != null) {
54
-				modifiers |= Modifiers.MODIFIER_FINAL;
54
+				modifiers |= Modifiers.FINAL;
55
 			} else if (tokens.optional(ZSTokenType.K_STATIC) != null) {
55
 			} else if (tokens.optional(ZSTokenType.K_STATIC) != null) {
56
-				modifiers |= Modifiers.MODIFIER_STATIC;
56
+				modifiers |= Modifiers.STATIC;
57
 			} else if (tokens.optional(ZSTokenType.K_PROTECTED) != null) {
57
 			} else if (tokens.optional(ZSTokenType.K_PROTECTED) != null) {
58
-				modifiers |= Modifiers.MODIFIER_PROTECTED;
58
+				modifiers |= Modifiers.PROTECTED;
59
 			} else if (tokens.optional(ZSTokenType.K_IMPLICIT) != null) {
59
 			} else if (tokens.optional(ZSTokenType.K_IMPLICIT) != null) {
60
-				modifiers |= Modifiers.MODIFIER_IMPLICIT;
60
+				modifiers |= Modifiers.IMPLICIT;
61
 			} else {
61
 			} else {
62
 				break;
62
 				break;
63
 			}
63
 			}

+ 1
- 1
Parser/src/main/java/org/openzen/zenscript/parser/member/ParsedField.java View File

45
 
45
 
46
 	@Override
46
 	@Override
47
 	public void linkTypes(BaseScope scope) {
47
 	public void linkTypes(BaseScope scope) {
48
-		compiled = new FieldMember(position, modifiers | (isFinal ? Modifiers.MODIFIER_FINAL : 0), name, type.compile(scope));
48
+		compiled = new FieldMember(position, modifiers | (isFinal ? Modifiers.FINAL : 0), name, type.compile(scope));
49
 	}
49
 	}
50
 
50
 
51
 	@Override
51
 	@Override

+ 7
- 7
ScriptingExample/src/main/java/org/openzen/zenscript/scriptingexample/GlobalRegistry.java View File

64
 			// eg. package my.package with a class MyClass with a single native method test() returning a string
64
 			// eg. package my.package with a class MyClass with a single native method test() returning a string
65
 			// the visitors can then during compilation check if a method is an instance of NativeMethodMember and treat it accordingly
65
 			// the visitors can then during compilation check if a method is an instance of NativeMethodMember and treat it accordingly
66
 			ZSPackage packageMyPackage = rootPackage.getOrCreatePackage("my").getOrCreatePackage("package");
66
 			ZSPackage packageMyPackage = rootPackage.getOrCreatePackage("my").getOrCreatePackage("package");
67
-			ClassDefinition myClassDefinition = new ClassDefinition(CodePosition.NATIVE, packageMyPackage, "MyClass", Modifiers.MODIFIER_PUBLIC, null);
67
+			ClassDefinition myClassDefinition = new ClassDefinition(CodePosition.NATIVE, packageMyPackage, "MyClass", Modifiers.PUBLIC, null);
68
 			JavaClassInfo myClassInfo = new JavaClassInfo("my/test/MyClass");
68
 			JavaClassInfo myClassInfo = new JavaClassInfo("my/test/MyClass");
69
 			
69
 			
70
-			MethodMember member = new MethodMember(CodePosition.NATIVE, Modifiers.MODIFIER_PUBLIC, "test", new FunctionHeader(BasicTypeID.STRING));
70
+			MethodMember member = new MethodMember(CodePosition.NATIVE, Modifiers.PUBLIC, "test", new FunctionHeader(BasicTypeID.STRING));
71
 			member.setTag(JavaMethodInfo.class, new JavaMethodInfo(myClassInfo, "test", "()Ljava/lang/String;"));
71
 			member.setTag(JavaMethodInfo.class, new JavaMethodInfo(myClassInfo, "test", "()Ljava/lang/String;"));
72
 			myClassDefinition.addMember(member);
72
 			myClassDefinition.addMember(member);
73
 			
73
 			
92
 		return globals;
92
 		return globals;
93
 	}
93
 	}
94
 	
94
 	
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);
95
+	private final ClassDefinition PRINTSTREAM = new ClassDefinition(CodePosition.NATIVE, javaIo, "PrintStream", Modifiers.EXPORT);
96
+	private final ClassDefinition SYSTEM = new ClassDefinition(CodePosition.NATIVE, javaLang, "System", Modifiers.EXPORT);
97
 	private final MethodMember PRINTSTREAM_PRINTLN = new MethodMember(
97
 	private final MethodMember PRINTSTREAM_PRINTLN = new MethodMember(
98
 			CodePosition.NATIVE,
98
 			CodePosition.NATIVE,
99
-			Modifiers.MODIFIER_EXPORT,
99
+			Modifiers.EXPORT,
100
 			"println",
100
 			"println",
101
 			new FunctionHeader(BasicTypeID.VOID, new FunctionParameter(BasicTypeID.STRING)));
101
 			new FunctionHeader(BasicTypeID.VOID, new FunctionParameter(BasicTypeID.STRING)));
102
 	
102
 	
103
 	private final FieldMember SYSTEM_OUT = new FieldMember(
103
 	private final FieldMember SYSTEM_OUT = new FieldMember(
104
 			CodePosition.NATIVE,
104
 			CodePosition.NATIVE,
105
-			Modifiers.MODIFIER_EXPORT | Modifiers.MODIFIER_FINAL,
105
+			Modifiers.EXPORT | Modifiers.FINAL,
106
 			"out",
106
 			"out",
107
 			DefinitionTypeID.forType(SYSTEM));
107
 			DefinitionTypeID.forType(SYSTEM));
108
 	
108
 	
111
 			CodePosition.NATIVE,
111
 			CodePosition.NATIVE,
112
 			globals,
112
 			globals,
113
 			"println",
113
 			"println",
114
-			Modifiers.MODIFIER_EXPORT,
114
+			Modifiers.EXPORT,
115
 			new FunctionHeader(BasicTypeID.VOID, new FunctionParameter(BasicTypeID.STRING)));
115
 			new FunctionHeader(BasicTypeID.VOID, new FunctionParameter(BasicTypeID.STRING)));
116
 	
116
 	
117
 	private class PrintlnSymbol implements ISymbol {
117
 	private class PrintlnSymbol implements ISymbol {

Loading…
Cancel
Save