Browse Source

WIP on memory tags

Stan Hebben 6 years ago
parent
commit
d9a78c015b
32 changed files with 501 additions and 103 deletions
  1. 2
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/NativeAnnotationDefinition.java
  2. 2
    1
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/PreconditionAnnotationDefinition.java
  3. 2
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstantStringExpression.java
  4. 1
    2
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/BasicTypeID.java
  5. 5
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/ITypeID.java
  6. 79
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/StringTypeID.java
  7. 5
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/TypeParameterCollector.java
  8. 2
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/TypeVisitor.java
  9. 2
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/TypeVisitorWithContext.java
  10. 64
    64
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/member/TypeMemberBuilder.java
  11. 21
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/AnyStorageTag.java
  12. 16
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/AnyStorageType.java
  13. 21
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/BorrowStorageTag.java
  14. 16
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/BorrowStorageType.java
  15. 21
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/SharedStorageTag.java
  16. 16
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/SharedStorageType.java
  17. 21
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/StaticStorageTag.java
  18. 16
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/StaticStorageType.java
  19. 14
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/StorageTag.java
  20. 14
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/StorageType.java
  21. 21
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/UniqueStorageTag.java
  22. 16
    0
      CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/UniqueStorageType.java
  23. 1
    0
      Parser/src/main/java/org/openzen/zenscript/lexer/ZSTokenType.java
  24. 14
    8
      Parser/src/main/java/org/openzen/zenscript/parser/type/IParsedType.java
  25. 7
    5
      Parser/src/main/java/org/openzen/zenscript/parser/type/ParsedFunctionType.java
  26. 7
    4
      Parser/src/main/java/org/openzen/zenscript/parser/type/ParsedNamedType.java
  27. 36
    0
      Parser/src/main/java/org/openzen/zenscript/parser/type/ParsedStorageTag.java
  28. 40
    0
      Parser/src/main/java/org/openzen/zenscript/parser/type/ParsedString.java
  29. 7
    5
      Parser/src/main/java/org/openzen/zenscript/parser/type/ParsedTypeArray.java
  30. 7
    6
      Parser/src/main/java/org/openzen/zenscript/parser/type/ParsedTypeAssociative.java
  31. 0
    1
      Parser/src/main/java/org/openzen/zenscript/parser/type/ParsedTypeBasic.java
  32. 5
    4
      Parser/src/main/java/org/openzen/zenscript/parser/type/ParsedTypeGenericMap.java

+ 2
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/NativeAnnotationDefinition.java View File

22
 import org.openzen.zenscript.codemodel.serialization.CodeSerializationInput;
22
 import org.openzen.zenscript.codemodel.serialization.CodeSerializationInput;
23
 import org.openzen.zenscript.codemodel.statement.Statement;
23
 import org.openzen.zenscript.codemodel.statement.Statement;
24
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
24
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
25
+import org.openzen.zenscript.codemodel.type.StringTypeID;
25
 
26
 
26
 /**
27
 /**
27
  *
28
  *
31
 	public static final NativeAnnotationDefinition INSTANCE = new NativeAnnotationDefinition();
32
 	public static final NativeAnnotationDefinition INSTANCE = new NativeAnnotationDefinition();
32
 	
33
 	
33
 	private static final List<FunctionHeader> INITIALIZERS = Collections.singletonList(
34
 	private static final List<FunctionHeader> INITIALIZERS = Collections.singletonList(
34
-			new FunctionHeader(BasicTypeID.VOID, BasicTypeID.STRING));
35
+			new FunctionHeader(BasicTypeID.VOID, StringTypeID.UNIQUE));
35
 	
36
 	
36
 	private NativeAnnotationDefinition() {}
37
 	private NativeAnnotationDefinition() {}
37
 
38
 

+ 2
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/PreconditionAnnotationDefinition.java View File

27
 import org.openzen.zenscript.codemodel.statement.Statement;
27
 import org.openzen.zenscript.codemodel.statement.Statement;
28
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
28
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
29
 import org.openzen.zenscript.codemodel.type.GenericName;
29
 import org.openzen.zenscript.codemodel.type.GenericName;
30
+import org.openzen.zenscript.codemodel.type.StringTypeID;
30
 
31
 
31
 /**
32
 /**
32
  *
33
  *
52
 				BasicTypeID.VOID,
53
 				BasicTypeID.VOID,
53
 				scope.getType(CodePosition.BUILTIN, enforcementLevelName),
54
 				scope.getType(CodePosition.BUILTIN, enforcementLevelName),
54
 				BasicTypeID.BOOL,
55
 				BasicTypeID.BOOL,
55
-				BasicTypeID.STRING));
56
+				StringTypeID.UNIQUE));
56
 	}
57
 	}
57
 
58
 
58
 	@Override
59
 	@Override

+ 2
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstantStringExpression.java View File

7
 
7
 
8
 import org.openzen.zencode.shared.CodePosition;
8
 import org.openzen.zencode.shared.CodePosition;
9
 import org.openzen.zenscript.codemodel.scope.TypeScope;
9
 import org.openzen.zenscript.codemodel.scope.TypeScope;
10
-import org.openzen.zenscript.codemodel.type.BasicTypeID;
10
+import org.openzen.zenscript.codemodel.type.StringTypeID;
11
 
11
 
12
 /**
12
 /**
13
  *
13
  *
17
 	public final String value;
17
 	public final String value;
18
 	
18
 	
19
 	public ConstantStringExpression(CodePosition position, String value) {
19
 	public ConstantStringExpression(CodePosition position, String value) {
20
-		super(position, BasicTypeID.STRING, null);
20
+		super(position, StringTypeID.STATIC, null);
21
 		
21
 		
22
 		this.value = value;
22
 		this.value = value;
23
 	}
23
 	}

+ 1
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/BasicTypeID.java View File

30
 	FLOAT("float"),
30
 	FLOAT("float"),
31
 	DOUBLE("double"),
31
 	DOUBLE("double"),
32
 	CHAR("char"),
32
 	CHAR("char"),
33
-	STRING("string"),
34
 	
33
 	
35
 	UNDETERMINED("undetermined");
34
 	UNDETERMINED("undetermined");
36
 	
35
 	
84
 	
83
 	
85
 	@Override
84
 	@Override
86
 	public boolean isObjectType() {
85
 	public boolean isObjectType() {
87
-		return this == STRING;
86
+		return false;
88
 	}
87
 	}
89
 
88
 
90
 	@Override
89
 	@Override

+ 5
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/ITypeID.java View File

102
 		public Boolean visitBasic(BasicTypeID basic) {
102
 		public Boolean visitBasic(BasicTypeID basic) {
103
 			return basic == type;
103
 			return basic == type;
104
 		}
104
 		}
105
+		
106
+		@Override
107
+		public Boolean visitString(StringTypeID string) {
108
+			return string == type || (type instanceof StringTypeID && ((StringTypeID)type).storage == null);
109
+		}
105
 
110
 
106
 		@Override
111
 		@Override
107
 		public Boolean visitArray(ArrayTypeID array) {
112
 		public Boolean visitArray(ArrayTypeID array) {

+ 79
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/StringTypeID.java View File

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.type;
7
+
8
+import java.util.List;
9
+import org.openzen.zenscript.codemodel.GenericMapper;
10
+import org.openzen.zenscript.codemodel.generic.TypeParameter;
11
+import org.openzen.zenscript.codemodel.type.storage.AnyStorageTag;
12
+import org.openzen.zenscript.codemodel.type.storage.BorrowStorageTag;
13
+import org.openzen.zenscript.codemodel.type.storage.SharedStorageTag;
14
+import org.openzen.zenscript.codemodel.type.storage.StaticStorageTag;
15
+import org.openzen.zenscript.codemodel.type.storage.StorageTag;
16
+import org.openzen.zenscript.codemodel.type.storage.UniqueStorageTag;
17
+
18
+/**
19
+ *
20
+ * @author Hoofdgebruiker
21
+ */
22
+public class StringTypeID implements ITypeID {
23
+	public static final StringTypeID ANY = new StringTypeID(AnyStorageTag.INSTANCE);
24
+	public static final StringTypeID STATIC = new StringTypeID(StaticStorageTag.INSTANCE);
25
+	public static final StringTypeID UNIQUE = new StringTypeID(UniqueStorageTag.INSTANCE);
26
+	public static final StringTypeID BORROW = new StringTypeID(BorrowStorageTag.INVOCATION);
27
+	public static final StringTypeID SHARED = new StringTypeID(SharedStorageTag.INSTANCE);
28
+	
29
+	public final StorageTag storage;
30
+	
31
+	public StringTypeID(StorageTag storage) {
32
+		this.storage = storage;
33
+	}
34
+
35
+	@Override
36
+	public ITypeID getUnmodified() {
37
+		return this;
38
+	}
39
+
40
+	@Override
41
+	public ITypeID getNormalized() {
42
+		return this;
43
+	}
44
+
45
+	@Override
46
+	public <T> T accept(TypeVisitor<T> visitor) {
47
+		return visitor.visitString(this);
48
+	}
49
+
50
+	@Override
51
+	public <C, R> R accept(C context, TypeVisitorWithContext<C, R> visitor) {
52
+		return visitor.visitString(context, this);
53
+	}
54
+
55
+	@Override
56
+	public boolean hasDefaultValue() {
57
+		return true;
58
+	}
59
+
60
+	@Override
61
+	public boolean isObjectType() {
62
+		return true;
63
+	}
64
+
65
+	@Override
66
+	public ITypeID instance(GenericMapper mapper) {
67
+		throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
68
+	}
69
+
70
+	@Override
71
+	public boolean hasInferenceBlockingTypeParameters(TypeParameter[] parameters) {
72
+		throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
73
+	}
74
+
75
+	@Override
76
+	public void extractTypeParameters(List<TypeParameter> typeParameters) {
77
+		throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
78
+	}
79
+}

+ 5
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/TypeParameterCollector.java View File

24
 	public Void visitBasic(BasicTypeID basic) {
24
 	public Void visitBasic(BasicTypeID basic) {
25
 		return null;
25
 		return null;
26
 	}
26
 	}
27
+	
28
+	@Override
29
+	public Void visitString(StringTypeID string) {
30
+		return null;
31
+	}
27
 
32
 
28
 	@Override
33
 	@Override
29
 	public Void visitArray(ArrayTypeID array) {
34
 	public Void visitArray(ArrayTypeID array) {

+ 2
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/TypeVisitor.java View File

12
 public interface TypeVisitor<T> {
12
 public interface TypeVisitor<T> {
13
 	public T visitBasic(BasicTypeID basic);
13
 	public T visitBasic(BasicTypeID basic);
14
 	
14
 	
15
+	public T visitString(StringTypeID string);
16
+	
15
 	public T visitArray(ArrayTypeID array);
17
 	public T visitArray(ArrayTypeID array);
16
 	
18
 	
17
 	public T visitAssoc(AssocTypeID assoc);
19
 	public T visitAssoc(AssocTypeID assoc);

+ 2
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/TypeVisitorWithContext.java View File

12
 public interface TypeVisitorWithContext<C, R> {
12
 public interface TypeVisitorWithContext<C, R> {
13
 	R visitBasic(C context, BasicTypeID basic);
13
 	R visitBasic(C context, BasicTypeID basic);
14
 	
14
 	
15
+	R visitString(C context, StringTypeID string);
16
+	
15
 	R visitArray(C context, ArrayTypeID array);
17
 	R visitArray(C context, ArrayTypeID array);
16
 	
18
 	
17
 	R visitAssoc(C context, AssocTypeID assoc);
19
 	R visitAssoc(C context, AssocTypeID assoc);

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

71
 import org.openzen.zenscript.codemodel.definition.InterfaceDefinition;
71
 import org.openzen.zenscript.codemodel.definition.InterfaceDefinition;
72
 import org.openzen.zenscript.codemodel.expression.ConstantUSizeExpression;
72
 import org.openzen.zenscript.codemodel.expression.ConstantUSizeExpression;
73
 import org.openzen.zenscript.codemodel.member.IteratorMember;
73
 import org.openzen.zenscript.codemodel.member.IteratorMember;
74
+import org.openzen.zenscript.codemodel.type.StringTypeID;
74
 import org.openzen.zenscript.codemodel.type.TypeVisitor;
75
 import org.openzen.zenscript.codemodel.type.TypeVisitor;
75
 
76
 
76
 /**
77
 /**
163
 			case CHAR:
164
 			case CHAR:
164
 				visitChar();
165
 				visitChar();
165
 				break;
166
 				break;
166
-			case STRING:
167
-				visitString();
168
-				break;
169
 		}
167
 		}
170
 		
168
 		
171
 		return null;
169
 		return null;
172
 	}
170
 	}
171
+	
172
+	@Override
173
+	public Void visitString(StringTypeID string) {
174
+		ClassDefinition builtin = new ClassDefinition(BUILTIN, Module.BUILTIN, null, "string", Modifiers.EXPORT, null);
175
+		
176
+		constructor(builtin, STRING_CONSTRUCTOR_CHARACTERS, registry.getArray(CHAR, 1));
177
+		
178
+		add(builtin, STRING_ADD_STRING, StringTypeID.BORROW, StringTypeID.UNIQUE);
179
+		indexGet(builtin, STRING_INDEXGET, USIZE, CHAR);
180
+		indexGet(builtin, STRING_RANGEGET, RangeTypeID.USIZE, StringTypeID.UNIQUE);
181
+		compare(builtin, STRING_COMPARE, StringTypeID.BORROW);
182
+		
183
+		getter(builtin, STRING_LENGTH, "length", USIZE);
184
+		getter(builtin, STRING_CHARACTERS, "characters", registry.getArray(CHAR, 1));
185
+		getter(builtin, STRING_ISEMPTY, "isEmpty", BOOL);
186
+
187
+		method(builtin, STRING_REMOVE_DIACRITICS, "removeDiacritics", StringTypeID.BORROW);
188
+		method(builtin, STRING_TRIM, "trim", StringTypeID.BORROW, StringTypeID.UNIQUE);
189
+		method(builtin, STRING_TO_LOWER_CASE, "toLowerCase", StringTypeID.UNIQUE);
190
+		method(builtin, STRING_TO_UPPER_CASE, "toUpperCase", StringTypeID.UNIQUE);
191
+		
192
+		iterator(builtin, ITERATOR_STRING_CHARS, CHAR);
193
+		
194
+		processType(builtin, string);
195
+		return null;
196
+	}
173
 
197
 
174
 	@Override
198
 	@Override
175
 	public Void visitArray(ArrayTypeID array) {
199
 	public Void visitArray(ArrayTypeID array) {
464
 		}
488
 		}
465
 		
489
 		
466
 		if (definition instanceof EnumDefinition) {
490
 		if (definition instanceof EnumDefinition) {
467
-			getter(definition, ENUM_NAME, "name", STRING);
491
+			getter(definition, ENUM_NAME, "name", StringTypeID.STATIC);
468
 			getter(definition, ENUM_ORDINAL, "ordinal", USIZE);
492
 			getter(definition, ENUM_ORDINAL, "ordinal", USIZE);
469
 			
493
 			
470
 			List<EnumConstantMember> enumConstants = ((EnumDefinition) definition).enumConstants;
494
 			List<EnumConstantMember> enumConstants = ((EnumDefinition) definition).enumConstants;
475
 			constant(definition, ENUM_VALUES, "values", new ArrayExpression(BUILTIN, constValues, registry.getArray(type, 1)));
499
 			constant(definition, ENUM_VALUES, "values", new ArrayExpression(BUILTIN, constValues, registry.getArray(type, 1)));
476
 			compare(definition, ENUM_COMPARE, type);
500
 			compare(definition, ENUM_COMPARE, type);
477
 			
501
 			
478
-			if (!members.canCast(BasicTypeID.STRING)) {
479
-				castImplicit(definition, ENUM_TO_STRING, STRING);
502
+			if (!members.canCast(StringTypeID.STATIC)) {
503
+				castImplicit(definition, ENUM_TO_STRING, StringTypeID.STATIC);
480
 			}
504
 			}
481
 		}
505
 		}
482
 		
506
 		
556
 		equals(builtin, BOOL_EQUALS, BOOL);
580
 		equals(builtin, BOOL_EQUALS, BOOL);
557
 		notequals(builtin, BOOL_NOTEQUALS, BOOL);
581
 		notequals(builtin, BOOL_NOTEQUALS, BOOL);
558
 		
582
 		
559
-		castExplicit(builtin, BOOL_TO_STRING, STRING);
560
-		staticMethod(builtin, BOOL_PARSE, "parse", BOOL, STRING);
583
+		castExplicit(builtin, BOOL_TO_STRING, StringTypeID.STATIC);
584
+		staticMethod(builtin, BOOL_PARSE, "parse", BOOL, StringTypeID.BORROW);
561
 		
585
 		
562
 		processType(builtin, BOOL);
586
 		processType(builtin, BOOL);
563
 	}
587
 	}
591
 		castImplicit(builtin, BYTE_TO_FLOAT, FLOAT);
615
 		castImplicit(builtin, BYTE_TO_FLOAT, FLOAT);
592
 		castImplicit(builtin, BYTE_TO_DOUBLE, DOUBLE);
616
 		castImplicit(builtin, BYTE_TO_DOUBLE, DOUBLE);
593
 		castExplicit(builtin, BYTE_TO_CHAR, CHAR);
617
 		castExplicit(builtin, BYTE_TO_CHAR, CHAR);
594
-		castImplicit(builtin, BYTE_TO_STRING, STRING);
618
+		castImplicit(builtin, BYTE_TO_STRING, StringTypeID.UNIQUE);
595
 		
619
 		
596
-		staticMethod(builtin, BYTE_PARSE, "parse", BYTE, STRING);
597
-		staticMethod(builtin, BYTE_PARSE_WITH_BASE, "parse", BYTE, STRING, INT);
620
+		staticMethod(builtin, BYTE_PARSE, "parse", BYTE, StringTypeID.BORROW);
621
+		staticMethod(builtin, BYTE_PARSE_WITH_BASE, "parse", BYTE, StringTypeID.BORROW, INT);
598
 		
622
 		
599
 		constant(builtin, BYTE_GET_MIN_VALUE, "MIN_VALUE", new ConstantByteExpression(BUILTIN, 0));
623
 		constant(builtin, BYTE_GET_MIN_VALUE, "MIN_VALUE", new ConstantByteExpression(BUILTIN, 0));
600
 		constant(builtin, BYTE_GET_MAX_VALUE, "MAX_VALUE", new ConstantByteExpression(BUILTIN, 255));
624
 		constant(builtin, BYTE_GET_MAX_VALUE, "MAX_VALUE", new ConstantByteExpression(BUILTIN, 255));
633
 		castImplicit(builtin, SBYTE_TO_FLOAT, FLOAT);
657
 		castImplicit(builtin, SBYTE_TO_FLOAT, FLOAT);
634
 		castImplicit(builtin, SBYTE_TO_DOUBLE, DOUBLE);
658
 		castImplicit(builtin, SBYTE_TO_DOUBLE, DOUBLE);
635
 		castExplicit(builtin, SBYTE_TO_CHAR, CHAR);
659
 		castExplicit(builtin, SBYTE_TO_CHAR, CHAR);
636
-		castImplicit(builtin, SBYTE_TO_STRING, STRING);
660
+		castImplicit(builtin, SBYTE_TO_STRING, StringTypeID.UNIQUE);
637
 		
661
 		
638
-		staticMethod(builtin, SBYTE_PARSE, "parse", SBYTE, STRING);
639
-		staticMethod(builtin, SBYTE_PARSE_WITH_BASE, "parse", SBYTE, STRING, INT);
662
+		staticMethod(builtin, SBYTE_PARSE, "parse", SBYTE, StringTypeID.BORROW);
663
+		staticMethod(builtin, SBYTE_PARSE_WITH_BASE, "parse", SBYTE, StringTypeID.BORROW, INT);
640
 		
664
 		
641
 		constant(builtin, SBYTE_GET_MIN_VALUE, "MIN_VALUE", new ConstantSByteExpression(BUILTIN, Byte.MIN_VALUE));
665
 		constant(builtin, SBYTE_GET_MIN_VALUE, "MIN_VALUE", new ConstantSByteExpression(BUILTIN, Byte.MIN_VALUE));
642
 		constant(builtin, SBYTE_GET_MAX_VALUE, "MAX_VALUE", new ConstantSByteExpression(BUILTIN, Byte.MAX_VALUE));
666
 		constant(builtin, SBYTE_GET_MAX_VALUE, "MAX_VALUE", new ConstantSByteExpression(BUILTIN, Byte.MAX_VALUE));
675
 		castImplicit(builtin, SHORT_TO_FLOAT, FLOAT);
699
 		castImplicit(builtin, SHORT_TO_FLOAT, FLOAT);
676
 		castImplicit(builtin, SHORT_TO_DOUBLE, DOUBLE);
700
 		castImplicit(builtin, SHORT_TO_DOUBLE, DOUBLE);
677
 		castExplicit(builtin, SHORT_TO_CHAR, CHAR);
701
 		castExplicit(builtin, SHORT_TO_CHAR, CHAR);
678
-		castImplicit(builtin, SHORT_TO_STRING, STRING);
702
+		castImplicit(builtin, SHORT_TO_STRING, StringTypeID.UNIQUE);
679
 		
703
 		
680
-		staticMethod(builtin, SHORT_PARSE, "parse", SHORT, STRING);
681
-		staticMethod(builtin, SHORT_PARSE_WITH_BASE, "parse", SHORT, STRING, INT);
704
+		staticMethod(builtin, SHORT_PARSE, "parse", SHORT, StringTypeID.BORROW);
705
+		staticMethod(builtin, SHORT_PARSE_WITH_BASE, "parse", SHORT, StringTypeID.BORROW, INT);
682
 		
706
 		
683
 		constant(builtin, SHORT_GET_MIN_VALUE, "MIN_VALUE", new ConstantShortExpression(BUILTIN, Short.MIN_VALUE));
707
 		constant(builtin, SHORT_GET_MIN_VALUE, "MIN_VALUE", new ConstantShortExpression(BUILTIN, Short.MIN_VALUE));
684
 		constant(builtin, SHORT_GET_MAX_VALUE, "MAX_VALUE", new ConstantShortExpression(BUILTIN, Short.MAX_VALUE));
708
 		constant(builtin, SHORT_GET_MAX_VALUE, "MAX_VALUE", new ConstantShortExpression(BUILTIN, Short.MAX_VALUE));
715
 		castImplicit(builtin, USHORT_TO_FLOAT, FLOAT);
739
 		castImplicit(builtin, USHORT_TO_FLOAT, FLOAT);
716
 		castImplicit(builtin, USHORT_TO_DOUBLE, DOUBLE);
740
 		castImplicit(builtin, USHORT_TO_DOUBLE, DOUBLE);
717
 		castExplicit(builtin, USHORT_TO_CHAR, CHAR);
741
 		castExplicit(builtin, USHORT_TO_CHAR, CHAR);
718
-		castImplicit(builtin, USHORT_TO_STRING, STRING);
742
+		castImplicit(builtin, USHORT_TO_STRING, StringTypeID.UNIQUE);
719
 		
743
 		
720
-		staticMethod(builtin, USHORT_PARSE, "parse", USHORT, STRING);
721
-		staticMethod(builtin, USHORT_PARSE_WITH_BASE, "parse", USHORT, STRING, INT);
744
+		staticMethod(builtin, USHORT_PARSE, "parse", USHORT, StringTypeID.BORROW);
745
+		staticMethod(builtin, USHORT_PARSE_WITH_BASE, "parse", USHORT, StringTypeID.BORROW, INT);
722
 		
746
 		
723
 		constant(builtin, USHORT_GET_MIN_VALUE, "MIN_VALUE", new ConstantUShortExpression(BUILTIN, 0));
747
 		constant(builtin, USHORT_GET_MIN_VALUE, "MIN_VALUE", new ConstantUShortExpression(BUILTIN, 0));
724
 		constant(builtin, USHORT_GET_MAX_VALUE, "MAX_VALUE", new ConstantUShortExpression(BUILTIN, 65535));
748
 		constant(builtin, USHORT_GET_MAX_VALUE, "MAX_VALUE", new ConstantUShortExpression(BUILTIN, 65535));
787
 		castImplicit(builtin, INT_TO_FLOAT, FLOAT);
811
 		castImplicit(builtin, INT_TO_FLOAT, FLOAT);
788
 		castImplicit(builtin, INT_TO_DOUBLE, DOUBLE);
812
 		castImplicit(builtin, INT_TO_DOUBLE, DOUBLE);
789
 		castExplicit(builtin, INT_TO_CHAR, CHAR);
813
 		castExplicit(builtin, INT_TO_CHAR, CHAR);
790
-		castImplicit(builtin, INT_TO_STRING, STRING);
814
+		castImplicit(builtin, INT_TO_STRING, StringTypeID.UNIQUE);
791
 		
815
 		
792
-		staticMethod(builtin, INT_PARSE, "parse", INT, STRING);
793
-		staticMethod(builtin, INT_PARSE_WITH_BASE, "parse", INT, STRING, INT);
816
+		staticMethod(builtin, INT_PARSE, "parse", INT, StringTypeID.BORROW);
817
+		staticMethod(builtin, INT_PARSE_WITH_BASE, "parse", INT, StringTypeID.BORROW, INT);
794
 		
818
 		
795
 		method(builtin, INT_COUNT_LOW_ZEROES, "countLowZeroes", INT);
819
 		method(builtin, INT_COUNT_LOW_ZEROES, "countLowZeroes", INT);
796
 		method(builtin, INT_COUNT_HIGH_ZEROES, "countHighZeroes", INT);
820
 		method(builtin, INT_COUNT_HIGH_ZEROES, "countHighZeroes", INT);
866
 		castImplicit(builtin, UINT_TO_FLOAT, FLOAT);
890
 		castImplicit(builtin, UINT_TO_FLOAT, FLOAT);
867
 		castImplicit(builtin, UINT_TO_DOUBLE, DOUBLE);
891
 		castImplicit(builtin, UINT_TO_DOUBLE, DOUBLE);
868
 		castExplicit(builtin, UINT_TO_CHAR, CHAR);
892
 		castExplicit(builtin, UINT_TO_CHAR, CHAR);
869
-		castImplicit(builtin, UINT_TO_STRING, STRING);
893
+		castImplicit(builtin, UINT_TO_STRING, StringTypeID.UNIQUE);
870
 		
894
 		
871
-		staticMethod(builtin, UINT_PARSE, "parse", UINT, STRING);
872
-		staticMethod(builtin, UINT_PARSE_WITH_BASE, "parse", UINT, STRING, INT);
895
+		staticMethod(builtin, UINT_PARSE, "parse", UINT, StringTypeID.BORROW);
896
+		staticMethod(builtin, UINT_PARSE_WITH_BASE, "parse", UINT, StringTypeID.BORROW, INT);
873
 		
897
 		
874
 		method(builtin, UINT_COUNT_LOW_ZEROES, "countLowZeroes", UINT);
898
 		method(builtin, UINT_COUNT_LOW_ZEROES, "countLowZeroes", UINT);
875
 		method(builtin, UINT_COUNT_HIGH_ZEROES, "countHighZeroes", UINT);
899
 		method(builtin, UINT_COUNT_HIGH_ZEROES, "countHighZeroes", UINT);
939
 		castImplicit(builtin, LONG_TO_FLOAT, FLOAT);
963
 		castImplicit(builtin, LONG_TO_FLOAT, FLOAT);
940
 		castImplicit(builtin, LONG_TO_DOUBLE, DOUBLE);
964
 		castImplicit(builtin, LONG_TO_DOUBLE, DOUBLE);
941
 		castExplicit(builtin, LONG_TO_CHAR, CHAR);
965
 		castExplicit(builtin, LONG_TO_CHAR, CHAR);
942
-		castImplicit(builtin, LONG_TO_STRING, STRING);
966
+		castImplicit(builtin, LONG_TO_STRING, StringTypeID.UNIQUE);
943
 		
967
 		
944
-		staticMethod(builtin, LONG_PARSE, "parse", LONG, STRING);
945
-		staticMethod(builtin, LONG_PARSE_WITH_BASE, "parse", LONG, STRING, INT);
968
+		staticMethod(builtin, LONG_PARSE, "parse", LONG, StringTypeID.BORROW);
969
+		staticMethod(builtin, LONG_PARSE_WITH_BASE, "parse", LONG, StringTypeID.BORROW, INT);
946
 		
970
 		
947
 		method(builtin, LONG_COUNT_LOW_ZEROES, "countLowZeroes", INT);
971
 		method(builtin, LONG_COUNT_LOW_ZEROES, "countLowZeroes", INT);
948
 		method(builtin, LONG_COUNT_HIGH_ZEROES, "countHighZeroes", INT);
972
 		method(builtin, LONG_COUNT_HIGH_ZEROES, "countHighZeroes", INT);
1011
 		castImplicit(builtin, ULONG_TO_FLOAT, FLOAT);
1035
 		castImplicit(builtin, ULONG_TO_FLOAT, FLOAT);
1012
 		castImplicit(builtin, ULONG_TO_DOUBLE, DOUBLE);
1036
 		castImplicit(builtin, ULONG_TO_DOUBLE, DOUBLE);
1013
 		castExplicit(builtin, ULONG_TO_CHAR, CHAR);
1037
 		castExplicit(builtin, ULONG_TO_CHAR, CHAR);
1014
-		castImplicit(builtin, ULONG_TO_STRING, STRING);
1038
+		castImplicit(builtin, ULONG_TO_STRING, StringTypeID.UNIQUE);
1015
 		
1039
 		
1016
-		staticMethod(builtin, ULONG_PARSE, "parse", ULONG, STRING);
1017
-		staticMethod(builtin, ULONG_PARSE_WITH_BASE, "parse", ULONG, STRING, INT);
1040
+		staticMethod(builtin, ULONG_PARSE, "parse", ULONG, StringTypeID.BORROW);
1041
+		staticMethod(builtin, ULONG_PARSE_WITH_BASE, "parse", ULONG, StringTypeID.BORROW, INT);
1018
 		
1042
 		
1019
 		method(builtin, ULONG_COUNT_LOW_ZEROES, "countLowZeroes", INT);
1043
 		method(builtin, ULONG_COUNT_LOW_ZEROES, "countLowZeroes", INT);
1020
 		method(builtin, ULONG_COUNT_HIGH_ZEROES, "countHighZeroes", INT);
1044
 		method(builtin, ULONG_COUNT_HIGH_ZEROES, "countHighZeroes", INT);
1088
 		castImplicit(builtin, USIZE_TO_FLOAT, FLOAT);
1112
 		castImplicit(builtin, USIZE_TO_FLOAT, FLOAT);
1089
 		castImplicit(builtin, USIZE_TO_DOUBLE, DOUBLE);
1113
 		castImplicit(builtin, USIZE_TO_DOUBLE, DOUBLE);
1090
 		castExplicit(builtin, USIZE_TO_CHAR, CHAR);
1114
 		castExplicit(builtin, USIZE_TO_CHAR, CHAR);
1091
-		castImplicit(builtin, USIZE_TO_STRING, STRING);
1115
+		castImplicit(builtin, USIZE_TO_STRING, StringTypeID.UNIQUE);
1092
 		
1116
 		
1093
-		staticMethod(builtin, USIZE_PARSE, "parse", USIZE, STRING);
1094
-		staticMethod(builtin, USIZE_PARSE_WITH_BASE, "parse", USIZE, STRING, INT);
1117
+		staticMethod(builtin, USIZE_PARSE, "parse", USIZE, StringTypeID.BORROW);
1118
+		staticMethod(builtin, USIZE_PARSE_WITH_BASE, "parse", USIZE, StringTypeID.BORROW, INT);
1095
 		
1119
 		
1096
 		method(builtin, USIZE_COUNT_LOW_ZEROES, "countLowZeroes", INT);
1120
 		method(builtin, USIZE_COUNT_LOW_ZEROES, "countLowZeroes", INT);
1097
 		method(builtin, USIZE_COUNT_HIGH_ZEROES, "countHighZeroes", INT);
1121
 		method(builtin, USIZE_COUNT_HIGH_ZEROES, "countHighZeroes", INT);
1143
 		castExplicit(builtin, FLOAT_TO_ULONG, ULONG);
1167
 		castExplicit(builtin, FLOAT_TO_ULONG, ULONG);
1144
 		castExplicit(builtin, FLOAT_TO_USIZE, USIZE);
1168
 		castExplicit(builtin, FLOAT_TO_USIZE, USIZE);
1145
 		castImplicit(builtin, FLOAT_TO_DOUBLE, DOUBLE);
1169
 		castImplicit(builtin, FLOAT_TO_DOUBLE, DOUBLE);
1146
-		castImplicit(builtin, FLOAT_TO_STRING, STRING);
1170
+		castImplicit(builtin, FLOAT_TO_STRING, StringTypeID.UNIQUE);
1147
 		
1171
 		
1148
-		staticMethod(builtin, FLOAT_PARSE, "parse", FLOAT, STRING);
1172
+		staticMethod(builtin, FLOAT_PARSE, "parse", FLOAT, StringTypeID.BORROW);
1149
 		staticMethod(builtin, FLOAT_FROM_BITS, "fromBits", FLOAT, UINT);
1173
 		staticMethod(builtin, FLOAT_FROM_BITS, "fromBits", FLOAT, UINT);
1150
 		
1174
 		
1151
 		getter(builtin, FLOAT_BITS, "bits", UINT);
1175
 		getter(builtin, FLOAT_BITS, "bits", UINT);
1179
 		castExplicit(builtin, DOUBLE_TO_ULONG, ULONG);
1203
 		castExplicit(builtin, DOUBLE_TO_ULONG, ULONG);
1180
 		castExplicit(builtin, DOUBLE_TO_USIZE, USIZE);
1204
 		castExplicit(builtin, DOUBLE_TO_USIZE, USIZE);
1181
 		castImplicit(builtin, DOUBLE_TO_FLOAT, FLOAT);
1205
 		castImplicit(builtin, DOUBLE_TO_FLOAT, FLOAT);
1182
-		castImplicit(builtin, DOUBLE_TO_STRING, STRING);
1206
+		castImplicit(builtin, DOUBLE_TO_STRING, StringTypeID.UNIQUE);
1183
 		
1207
 		
1184
-		staticMethod(builtin, DOUBLE_PARSE, "parse", DOUBLE, STRING);
1208
+		staticMethod(builtin, DOUBLE_PARSE, "parse", DOUBLE, StringTypeID.BORROW);
1185
 		staticMethod(builtin, DOUBLE_FROM_BITS, "fromBits", DOUBLE, ULONG);
1209
 		staticMethod(builtin, DOUBLE_FROM_BITS, "fromBits", DOUBLE, ULONG);
1186
 		
1210
 		
1187
 		getter(builtin, DOUBLE_BITS, "bits", ULONG);
1211
 		getter(builtin, DOUBLE_BITS, "bits", ULONG);
1206
 		castImplicit(builtin, CHAR_TO_LONG, LONG);
1230
 		castImplicit(builtin, CHAR_TO_LONG, LONG);
1207
 		castImplicit(builtin, CHAR_TO_ULONG, ULONG);
1231
 		castImplicit(builtin, CHAR_TO_ULONG, ULONG);
1208
 		castImplicit(builtin, CHAR_TO_USIZE, USIZE);
1232
 		castImplicit(builtin, CHAR_TO_USIZE, USIZE);
1209
-		castImplicit(builtin, CHAR_TO_STRING, STRING);
1233
+		castImplicit(builtin, CHAR_TO_STRING, StringTypeID.UNIQUE);
1210
 		
1234
 		
1211
 		getter(builtin, CHAR_GET_MIN_VALUE, "MIN_VALUE", CHAR);
1235
 		getter(builtin, CHAR_GET_MIN_VALUE, "MIN_VALUE", CHAR);
1212
 		getter(builtin, CHAR_GET_MAX_VALUE, "MAX_VALUE", CHAR);
1236
 		getter(builtin, CHAR_GET_MAX_VALUE, "MAX_VALUE", CHAR);
1217
 		
1241
 		
1218
 		processType(builtin, CHAR);
1242
 		processType(builtin, CHAR);
1219
 	}
1243
 	}
1220
-
1221
-	private void visitString() {
1222
-		ClassDefinition builtin = new ClassDefinition(BUILTIN, Module.BUILTIN, null, "string", Modifiers.EXPORT, null);
1223
-		
1224
-		constructor(builtin, STRING_CONSTRUCTOR_CHARACTERS, registry.getArray(CHAR, 1));
1225
-		
1226
-		add(builtin, STRING_ADD_STRING, STRING, STRING);
1227
-		indexGet(builtin, STRING_INDEXGET, USIZE, CHAR);
1228
-		indexGet(builtin, STRING_RANGEGET, RangeTypeID.USIZE, STRING);
1229
-		compare(builtin, STRING_COMPARE, STRING);
1230
-		
1231
-		getter(builtin, STRING_LENGTH, "length", USIZE);
1232
-		getter(builtin, STRING_CHARACTERS, "characters", registry.getArray(CHAR, 1));
1233
-		getter(builtin, STRING_ISEMPTY, "isEmpty", BOOL);
1234
-
1235
-		method(builtin, STRING_REMOVE_DIACRITICS, "removeDiacritics", STRING);
1236
-		method(builtin, STRING_TRIM, "trim", STRING, STRING);
1237
-		method(builtin, STRING_TO_LOWER_CASE, "toLowerCase", STRING);
1238
-		method(builtin, STRING_TO_UPPER_CASE, "toUpperCase", STRING);
1239
-		
1240
-		iterator(builtin, ITERATOR_STRING_CHARS, CHAR);
1241
-		
1242
-		processType(builtin, STRING);
1243
-	}
1244
 	
1244
 	
1245
 	private void castedTargetCall(OperatorMember member, ITypeID toType, BuiltinID casterBuiltin) {
1245
 	private void castedTargetCall(OperatorMember member, ITypeID toType, BuiltinID casterBuiltin) {
1246
 		CasterMemberRef caster = castImplicitRef(member.definition, casterBuiltin, toType);
1246
 		CasterMemberRef caster = castImplicitRef(member.definition, casterBuiltin, toType);

+ 21
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/AnyStorageTag.java View File

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.type.storage;
7
+
8
+/**
9
+ *
10
+ * @author Hoofdgebruiker
11
+ */
12
+public class AnyStorageTag implements StorageTag {
13
+	public static final AnyStorageTag INSTANCE = new AnyStorageTag();
14
+	
15
+	private AnyStorageTag() {}
16
+
17
+	@Override
18
+	public StorageType getType() {
19
+		return AnyStorageType.INSTANCE;
20
+	}
21
+}

+ 16
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/AnyStorageType.java View File

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.type.storage;
7
+
8
+/**
9
+ *
10
+ * @author Hoofdgebruiker
11
+ */
12
+public class AnyStorageType implements StorageType {
13
+	public static final AnyStorageType INSTANCE = new AnyStorageType();
14
+	
15
+	private AnyStorageType() {}
16
+}

+ 21
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/BorrowStorageTag.java View File

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.type.storage;
7
+
8
+/**
9
+ *
10
+ * @author Hoofdgebruiker
11
+ */
12
+public class BorrowStorageTag implements StorageTag {
13
+	public static final BorrowStorageTag INVOCATION = new BorrowStorageTag();
14
+	
15
+	private BorrowStorageTag() {} // TODO: scoped borrow
16
+
17
+	@Override
18
+	public StorageType getType() {
19
+		return BorrowStorageType.INSTANCE;
20
+	}
21
+}

+ 16
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/BorrowStorageType.java View File

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.type.storage;
7
+
8
+/**
9
+ *
10
+ * @author Hoofdgebruiker
11
+ */
12
+public class BorrowStorageType implements StorageType {
13
+	public static final BorrowStorageType INSTANCE = new BorrowStorageType();
14
+
15
+	private BorrowStorageType() {}
16
+}

+ 21
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/SharedStorageTag.java View File

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.type.storage;
7
+
8
+/**
9
+ *
10
+ * @author Hoofdgebruiker
11
+ */
12
+public class SharedStorageTag implements StorageTag {
13
+	public static final SharedStorageTag INSTANCE = new SharedStorageTag();
14
+	
15
+	private SharedStorageTag() {}
16
+
17
+	@Override
18
+	public StorageType getType() {
19
+		return SharedStorageType.INSTANCE;
20
+	}
21
+}

+ 16
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/SharedStorageType.java View File

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.type.storage;
7
+
8
+/**
9
+ *
10
+ * @author Hoofdgebruiker
11
+ */
12
+public class SharedStorageType implements StorageType {
13
+	public static final SharedStorageType INSTANCE = new SharedStorageType();
14
+	
15
+	private SharedStorageType() {}
16
+}

+ 21
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/StaticStorageTag.java View File

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.type.storage;
7
+
8
+/**
9
+ *
10
+ * @author Hoofdgebruiker
11
+ */
12
+public class StaticStorageTag implements StorageTag {
13
+	public static final StaticStorageTag INSTANCE = new StaticStorageTag();
14
+	
15
+	private StaticStorageTag() {}
16
+
17
+	@Override
18
+	public StorageType getType() {
19
+		return StaticStorageType.INSTANCE;
20
+	}
21
+}

+ 16
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/StaticStorageType.java View File

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.type.storage;
7
+
8
+/**
9
+ *
10
+ * @author Hoofdgebruiker
11
+ */
12
+public class StaticStorageType implements StorageType {
13
+	public static final StaticStorageType INSTANCE = new StaticStorageType();
14
+	
15
+	private StaticStorageType() {}
16
+}

+ 14
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/StorageTag.java View File

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.type.storage;
7
+
8
+/**
9
+ *
10
+ * @author Hoofdgebruiker
11
+ */
12
+public interface StorageTag {
13
+	StorageType getType();
14
+}

+ 14
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/StorageType.java View File

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.type.storage;
7
+
8
+/**
9
+ *
10
+ * @author Hoofdgebruiker
11
+ */
12
+public interface StorageType {
13
+	
14
+}

+ 21
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/UniqueStorageTag.java View File

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.type.storage;
7
+
8
+/**
9
+ *
10
+ * @author Hoofdgebruiker
11
+ */
12
+public class UniqueStorageTag implements StorageTag {
13
+	public static final UniqueStorageTag INSTANCE = new UniqueStorageTag() {};
14
+			
15
+	private UniqueStorageTag() {}
16
+
17
+	@Override
18
+	public StorageType getType() {
19
+		return UniqueStorageType.INSTANCE;
20
+	}
21
+}

+ 16
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/UniqueStorageType.java View File

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.type.storage;
7
+
8
+/**
9
+ *
10
+ * @author Hoofdgebruiker
11
+ */
12
+public class UniqueStorageType implements StorageType {
13
+	public static final UniqueStorageType INSTANCE = new UniqueStorageType();
14
+	
15
+	private UniqueStorageType() {}
16
+}

+ 1
- 0
Parser/src/main/java/org/openzen/zenscript/lexer/ZSTokenType.java View File

78
 	T_NOTEQUAL("!=", "!="),
78
 	T_NOTEQUAL("!=", "!="),
79
 	T_NOT("!", "!"),
79
 	T_NOT("!", "!"),
80
 	T_DOLLAR("$", "$"),
80
 	T_DOLLAR("$", "$"),
81
+	T_BACKTICK("`", "`"),
81
 	
82
 	
82
 	K_IMPORT(true, "import"),
83
 	K_IMPORT(true, "import"),
83
 	K_ALIAS(true, "alias"),
84
 	K_ALIAS(true, "alias"),

+ 14
- 8
Parser/src/main/java/org/openzen/zenscript/parser/type/IParsedType.java View File

105
 				tokens.next();
105
 				tokens.next();
106
 				result = ParsedTypeBasic.CHAR;
106
 				result = ParsedTypeBasic.CHAR;
107
 				break;
107
 				break;
108
-			case K_STRING:
108
+			case K_STRING: {
109
 				tokens.next();
109
 				tokens.next();
110
-				result = ParsedTypeBasic.STRING;
110
+				ParsedStorageTag storage = ParsedStorageTag.parse(tokens);
111
+				result = new ParsedString(modifiers, storage);
111
 				break;
112
 				break;
113
+			}
112
 			case K_FUNCTION: {
114
 			case K_FUNCTION: {
113
 				tokens.next();
115
 				tokens.next();
114
 				ParsedFunctionHeader header = ParsedFunctionHeader.parse(tokens);
116
 				ParsedFunctionHeader header = ParsedFunctionHeader.parse(tokens);
115
-				result = new ParsedFunctionType(position, header);
117
+				ParsedStorageTag storage = ParsedStorageTag.parse(tokens);
118
+				result = new ParsedFunctionType(position, header, storage);
116
 				break;
119
 				break;
117
 			}
120
 			}
118
 			case T_IDENTIFIER: {
121
 			case T_IDENTIFIER: {
122
 					List<IParsedType> generic = parseGenericParameters(tokens);
125
 					List<IParsedType> generic = parseGenericParameters(tokens);
123
 					name.add(new ParsedNamedType.ParsedNamePart(namePart, generic));
126
 					name.add(new ParsedNamedType.ParsedNamePart(namePart, generic));
124
 				} while (tokens.optional(ZSTokenType.T_DOT) != null);
127
 				} while (tokens.optional(ZSTokenType.T_DOT) != null);
125
-				
126
-				result = new ParsedNamedType(position, name);
128
+				ParsedStorageTag storage = ParsedStorageTag.parse(tokens);
129
+				result = new ParsedNamedType(position, name, storage);
127
 				break;
130
 				break;
128
 			}
131
 			}
129
 			default:
132
 			default:
145
 						dimension++;
148
 						dimension++;
146
 					
149
 					
147
 					if (tokens.optional(ZSTokenType.T_SQCLOSE) != null) {
150
 					if (tokens.optional(ZSTokenType.T_SQCLOSE) != null) {
148
-						result = new ParsedTypeArray(result, dimension);
151
+						ParsedStorageTag storage = ParsedStorageTag.parse(tokens);
152
+						result = new ParsedTypeArray(result, dimension, storage);
149
 					} else if (tokens.isNext(T_LESS)) {
153
 					} else if (tokens.isNext(T_LESS)) {
150
 						tokens.next();
154
 						tokens.next();
151
 						ParsedTypeParameter parameter = ParsedTypeParameter.parse(tokens);
155
 						ParsedTypeParameter parameter = ParsedTypeParameter.parse(tokens);
152
 						tokens.required(T_GREATER, "> expected");
156
 						tokens.required(T_GREATER, "> expected");
153
-						result = new ParsedTypeGenericMap(parameter, result, modifiers);
154
 						tokens.required(ZSTokenType.T_SQCLOSE, "] expected");
157
 						tokens.required(ZSTokenType.T_SQCLOSE, "] expected");
158
+						ParsedStorageTag storage = ParsedStorageTag.parse(tokens);
159
+						result = new ParsedTypeGenericMap(parameter, result, modifiers, storage);
155
 					} else {
160
 					} else {
156
 						IParsedType keyType = parse(tokens);
161
 						IParsedType keyType = parse(tokens);
157
-						result = new ParsedTypeAssociative(keyType, result);
158
 						tokens.required(ZSTokenType.T_SQCLOSE, "] expected");
162
 						tokens.required(ZSTokenType.T_SQCLOSE, "] expected");
163
+						ParsedStorageTag storage = ParsedStorageTag.parse(tokens);
164
+						result = new ParsedTypeAssociative(keyType, result, storage);
159
 					}
165
 					}
160
 					break;
166
 					break;
161
 				case T_QUEST:
167
 				case T_QUEST:

+ 7
- 5
Parser/src/main/java/org/openzen/zenscript/parser/type/ParsedFunctionType.java View File

9
 import org.openzen.zenscript.codemodel.context.TypeResolutionContext;
9
 import org.openzen.zenscript.codemodel.context.TypeResolutionContext;
10
 import org.openzen.zenscript.codemodel.type.ITypeID;
10
 import org.openzen.zenscript.codemodel.type.ITypeID;
11
 import org.openzen.zenscript.codemodel.type.ModifiedTypeID;
11
 import org.openzen.zenscript.codemodel.type.ModifiedTypeID;
12
-import org.openzen.zenscript.codemodel.type.member.TypeMembers;
13
 import org.openzen.zenscript.parser.definitions.ParsedFunctionHeader;
12
 import org.openzen.zenscript.parser.definitions.ParsedFunctionHeader;
14
 
13
 
15
 /**
14
 /**
20
 	private final CodePosition position;
19
 	private final CodePosition position;
21
 	private final int modifiers;
20
 	private final int modifiers;
22
 	private final ParsedFunctionHeader header;
21
 	private final ParsedFunctionHeader header;
22
+	private final ParsedStorageTag storageTag;
23
 	
23
 	
24
-	public ParsedFunctionType(CodePosition position, ParsedFunctionHeader header) {
24
+	public ParsedFunctionType(CodePosition position, ParsedFunctionHeader header, ParsedStorageTag storageTag) {
25
 		this.position = position;
25
 		this.position = position;
26
 		this.header = header;
26
 		this.header = header;
27
 		this.modifiers = 0;
27
 		this.modifiers = 0;
28
+		this.storageTag = storageTag;
28
 	}
29
 	}
29
 	
30
 	
30
-	private ParsedFunctionType(CodePosition position, ParsedFunctionHeader header, int modifiers) {
31
+	private ParsedFunctionType(CodePosition position, ParsedFunctionHeader header, int modifiers, ParsedStorageTag storageTag) {
31
 		this.position = position;
32
 		this.position = position;
32
 		this.header = header;
33
 		this.header = header;
33
 		this.modifiers = modifiers;
34
 		this.modifiers = modifiers;
35
+		this.storageTag = storageTag;
34
 	}
36
 	}
35
 	
37
 	
36
 	@Override
38
 	@Override
37
 	public IParsedType withOptional() {
39
 	public IParsedType withOptional() {
38
-		return new ParsedFunctionType(position, header, modifiers | ModifiedTypeID.MODIFIER_OPTIONAL);
40
+		return new ParsedFunctionType(position, header, modifiers | ModifiedTypeID.MODIFIER_OPTIONAL, storageTag);
39
 	}
41
 	}
40
 
42
 
41
 	@Override
43
 	@Override
42
 	public IParsedType withModifiers(int modifiers) {
44
 	public IParsedType withModifiers(int modifiers) {
43
-		return new ParsedFunctionType(position, header, modifiers | this.modifiers);
45
+		return new ParsedFunctionType(position, header, modifiers | this.modifiers, storageTag);
44
 	}
46
 	}
45
 
47
 
46
 	@Override
48
 	@Override

+ 7
- 4
Parser/src/main/java/org/openzen/zenscript/parser/type/ParsedNamedType.java View File

25
 	private final CodePosition position;
25
 	private final CodePosition position;
26
 	private final int modifiers;
26
 	private final int modifiers;
27
 	public final List<ParsedNamePart> name;
27
 	public final List<ParsedNamePart> name;
28
+	private final ParsedStorageTag storage;
28
 	
29
 	
29
-	public ParsedNamedType(CodePosition position, List<ParsedNamePart> name) {
30
+	public ParsedNamedType(CodePosition position, List<ParsedNamePart> name, ParsedStorageTag storage) {
30
 		this.position = position;
31
 		this.position = position;
31
 		this.modifiers = 0;
32
 		this.modifiers = 0;
32
 		this.name = name;
33
 		this.name = name;
34
+		this.storage = storage;
33
 	}
35
 	}
34
 	
36
 	
35
-	private ParsedNamedType(CodePosition position, int modifiers, List<ParsedNamePart> name) {
37
+	private ParsedNamedType(CodePosition position, int modifiers, List<ParsedNamePart> name, ParsedStorageTag storage) {
36
 		this.position = position;
38
 		this.position = position;
37
 		this.modifiers = modifiers;
39
 		this.modifiers = modifiers;
38
 		this.name = name;
40
 		this.name = name;
41
+		this.storage = storage;
39
 	}
42
 	}
40
 	
43
 	
41
 	@Override
44
 	@Override
60
 	
63
 	
61
 	@Override
64
 	@Override
62
 	public IParsedType withOptional() {
65
 	public IParsedType withOptional() {
63
-		return new ParsedNamedType(position, modifiers | ModifiedTypeID.MODIFIER_OPTIONAL, name);
66
+		return new ParsedNamedType(position, modifiers | ModifiedTypeID.MODIFIER_OPTIONAL, name, storage);
64
 	}
67
 	}
65
 	
68
 	
66
 	@Override
69
 	@Override
67
 	public IParsedType withModifiers(int modifiers) {
70
 	public IParsedType withModifiers(int modifiers) {
68
-		return new ParsedNamedType(position, this.modifiers | modifiers, name);
71
+		return new ParsedNamedType(position, this.modifiers | modifiers, name, storage);
69
 	}
72
 	}
70
 	
73
 	
71
 	@Override
74
 	@Override

+ 36
- 0
Parser/src/main/java/org/openzen/zenscript/parser/type/ParsedStorageTag.java View File

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.parser.type;
7
+
8
+import org.openzen.zenscript.lexer.ZSTokenParser;
9
+import org.openzen.zenscript.lexer.ZSTokenType;
10
+import org.openzen.zenscript.parser.expression.ParsedCallArguments;
11
+
12
+/**
13
+ *
14
+ * @author Hoofdgebruiker
15
+ */
16
+public class ParsedStorageTag {
17
+	public static ParsedStorageTag parse(ZSTokenParser parser) {
18
+		if (parser.optional(ZSTokenType.T_BACKTICK) == null)
19
+			return null;
20
+		
21
+		String name = parser.required(ZSTokenType.T_IDENTIFIER, "identifier expected").content;
22
+		ParsedCallArguments arguments = null;
23
+		if (parser.peek().type == ZSTokenType.T_BROPEN)
24
+			arguments = ParsedCallArguments.parse(parser);
25
+		
26
+		return new ParsedStorageTag(name, arguments);
27
+	}
28
+	
29
+	public String name;
30
+	public ParsedCallArguments arguments;
31
+	
32
+	public ParsedStorageTag(String name, ParsedCallArguments arguments) {
33
+		this.name = name;
34
+		this.arguments = arguments;
35
+	}
36
+}

+ 40
- 0
Parser/src/main/java/org/openzen/zenscript/parser/type/ParsedString.java View File

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.parser.type;
7
+
8
+import org.openzen.zenscript.codemodel.context.TypeResolutionContext;
9
+import org.openzen.zenscript.codemodel.type.ITypeID;
10
+import org.openzen.zenscript.codemodel.type.ModifiedTypeID;
11
+import org.openzen.zenscript.codemodel.type.StringTypeID;
12
+
13
+/**
14
+ *
15
+ * @author Hoofdgebruiker
16
+ */
17
+public class ParsedString implements IParsedType {
18
+	private final int modifiers;
19
+	private final ParsedStorageTag storageTag;
20
+	
21
+	public ParsedString(int modifiers, ParsedStorageTag storageTag) {
22
+		this.modifiers = modifiers;
23
+		this.storageTag = storageTag;
24
+	}
25
+
26
+	@Override
27
+	public IParsedType withOptional() {
28
+		return new ParsedString(modifiers | ModifiedTypeID.MODIFIER_OPTIONAL, storageTag);
29
+	}
30
+
31
+	@Override
32
+	public IParsedType withModifiers(int modifiers) {
33
+		return new ParsedString(this.modifiers | modifiers, storageTag);
34
+	}
35
+
36
+	@Override
37
+	public ITypeID compile(TypeResolutionContext context) {
38
+		return StringTypeID.UNIQUE; // TODO
39
+	}
40
+}

+ 7
- 5
Parser/src/main/java/org/openzen/zenscript/parser/type/ParsedTypeArray.java View File

9
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
9
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
10
 import org.openzen.zenscript.codemodel.type.ITypeID;
10
 import org.openzen.zenscript.codemodel.type.ITypeID;
11
 import org.openzen.zenscript.codemodel.type.ModifiedTypeID;
11
 import org.openzen.zenscript.codemodel.type.ModifiedTypeID;
12
-import org.openzen.zenscript.codemodel.type.member.TypeMembers;
13
 
12
 
14
 /**
13
 /**
15
  *
14
  *
19
 	public final IParsedType baseType;
18
 	public final IParsedType baseType;
20
 	public final int dimension;
19
 	public final int dimension;
21
 	public final int modifiers;
20
 	public final int modifiers;
21
+	public final ParsedStorageTag storageTag;
22
 	
22
 	
23
-	public ParsedTypeArray(IParsedType baseType, int dimension) {
23
+	public ParsedTypeArray(IParsedType baseType, int dimension, ParsedStorageTag storageTag) {
24
 		this.baseType = baseType;
24
 		this.baseType = baseType;
25
 		this.dimension = dimension;
25
 		this.dimension = dimension;
26
 		this.modifiers = 0;
26
 		this.modifiers = 0;
27
+		this.storageTag = storageTag;
27
 	}
28
 	}
28
 
29
 
29
-	private ParsedTypeArray(IParsedType baseType, int dimension, int modifiers) {
30
+	private ParsedTypeArray(IParsedType baseType, int dimension, int modifiers, ParsedStorageTag storageTag) {
30
 		this.baseType = baseType;
31
 		this.baseType = baseType;
31
 		this.dimension = dimension;
32
 		this.dimension = dimension;
32
 		this.modifiers = modifiers;
33
 		this.modifiers = modifiers;
34
+		this.storageTag = storageTag;
33
 	}
35
 	}
34
 	
36
 	
35
 	@Override
37
 	@Override
36
 	public IParsedType withOptional() {
38
 	public IParsedType withOptional() {
37
-		return new ParsedTypeArray(baseType, dimension, modifiers | ModifiedTypeID.MODIFIER_OPTIONAL);
39
+		return new ParsedTypeArray(baseType, dimension, modifiers | ModifiedTypeID.MODIFIER_OPTIONAL, storageTag);
38
 	}
40
 	}
39
 
41
 
40
 	@Override
42
 	@Override
41
 	public IParsedType withModifiers(int modifiers) {
43
 	public IParsedType withModifiers(int modifiers) {
42
-		return new ParsedTypeArray(baseType, dimension, this.modifiers | modifiers);
44
+		return new ParsedTypeArray(baseType, dimension, this.modifiers | modifiers, storageTag);
43
 	}
45
 	}
44
 
46
 
45
 	@Override
47
 	@Override

+ 7
- 6
Parser/src/main/java/org/openzen/zenscript/parser/type/ParsedTypeAssociative.java View File

8
 import org.openzen.zenscript.codemodel.context.TypeResolutionContext;
8
 import org.openzen.zenscript.codemodel.context.TypeResolutionContext;
9
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
9
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
10
 import org.openzen.zenscript.codemodel.type.ITypeID;
10
 import org.openzen.zenscript.codemodel.type.ITypeID;
11
-import org.openzen.zenscript.codemodel.type.member.TypeMembers;
12
-import org.openzen.zenscript.codemodel.scope.BaseScope;
13
 import org.openzen.zenscript.codemodel.type.ModifiedTypeID;
11
 import org.openzen.zenscript.codemodel.type.ModifiedTypeID;
14
 
12
 
15
 /**
13
 /**
20
 	public final IParsedType key;
18
 	public final IParsedType key;
21
 	public final IParsedType value;
19
 	public final IParsedType value;
22
 	public final int modifiers;
20
 	public final int modifiers;
21
+	private final ParsedStorageTag storage;
23
 	
22
 	
24
-	public ParsedTypeAssociative(IParsedType key, IParsedType value) {
23
+	public ParsedTypeAssociative(IParsedType key, IParsedType value, ParsedStorageTag storage) {
25
 		this.key = key;
24
 		this.key = key;
26
 		this.value = value;
25
 		this.value = value;
27
 		this.modifiers = 0;
26
 		this.modifiers = 0;
27
+		this.storage = storage;
28
 	}
28
 	}
29
 
29
 
30
-	private ParsedTypeAssociative(IParsedType key, IParsedType value, int modifiers) {
30
+	private ParsedTypeAssociative(IParsedType key, IParsedType value, int modifiers, ParsedStorageTag storage) {
31
 		this.key = key;
31
 		this.key = key;
32
 		this.value = value;
32
 		this.value = value;
33
 		this.modifiers = modifiers;
33
 		this.modifiers = modifiers;
34
+		this.storage = storage;
34
 	}
35
 	}
35
 	
36
 	
36
 	@Override
37
 	@Override
37
 	public IParsedType withOptional() {
38
 	public IParsedType withOptional() {
38
-		return new ParsedTypeAssociative(key, value, modifiers | ModifiedTypeID.MODIFIER_OPTIONAL);
39
+		return new ParsedTypeAssociative(key, value, modifiers | ModifiedTypeID.MODIFIER_OPTIONAL, storage);
39
 	}
40
 	}
40
 
41
 
41
 	@Override
42
 	@Override
42
 	public IParsedType withModifiers(int modifiers) {
43
 	public IParsedType withModifiers(int modifiers) {
43
-		return new ParsedTypeAssociative(key, value, this.modifiers | modifiers);
44
+		return new ParsedTypeAssociative(key, value, this.modifiers | modifiers, storage);
44
 	}
45
 	}
45
 
46
 
46
 	@Override
47
 	@Override

+ 0
- 1
Parser/src/main/java/org/openzen/zenscript/parser/type/ParsedTypeBasic.java View File

28
 	FLOAT(BasicTypeID.FLOAT),
28
 	FLOAT(BasicTypeID.FLOAT),
29
 	DOUBLE(BasicTypeID.DOUBLE),
29
 	DOUBLE(BasicTypeID.DOUBLE),
30
 	CHAR(BasicTypeID.CHAR),
30
 	CHAR(BasicTypeID.CHAR),
31
-	STRING(BasicTypeID.STRING),
32
 	
31
 	
33
 	UNDETERMINED(BasicTypeID.UNDETERMINED);
32
 	UNDETERMINED(BasicTypeID.UNDETERMINED);
34
 	
33
 	

+ 5
- 4
Parser/src/main/java/org/openzen/zenscript/parser/type/ParsedTypeGenericMap.java View File

14
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
14
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
15
 import org.openzen.zenscript.codemodel.type.ITypeID;
15
 import org.openzen.zenscript.codemodel.type.ITypeID;
16
 import org.openzen.zenscript.codemodel.type.ModifiedTypeID;
16
 import org.openzen.zenscript.codemodel.type.ModifiedTypeID;
17
-import org.openzen.zenscript.codemodel.type.member.TypeMembers;
18
 import org.openzen.zenscript.parser.definitions.ParsedTypeParameter;
17
 import org.openzen.zenscript.parser.definitions.ParsedTypeParameter;
19
 
18
 
20
 /**
19
 /**
25
 	private final ParsedTypeParameter key;
24
 	private final ParsedTypeParameter key;
26
 	private final IParsedType value;
25
 	private final IParsedType value;
27
 	private final int modifiers;
26
 	private final int modifiers;
27
+	private final ParsedStorageTag storage;
28
 	
28
 	
29
-	public ParsedTypeGenericMap(ParsedTypeParameter key, IParsedType value, int modifiers) {
29
+	public ParsedTypeGenericMap(ParsedTypeParameter key, IParsedType value, int modifiers, ParsedStorageTag storage) {
30
 		this.key = key;
30
 		this.key = key;
31
 		this.value = value;
31
 		this.value = value;
32
 		this.modifiers = modifiers;
32
 		this.modifiers = modifiers;
33
+		this.storage = storage;
33
 	}
34
 	}
34
 
35
 
35
 	@Override
36
 	@Override
36
 	public IParsedType withOptional() {
37
 	public IParsedType withOptional() {
37
-		return new ParsedTypeGenericMap(key, value, modifiers | ModifiedTypeID.MODIFIER_OPTIONAL);
38
+		return new ParsedTypeGenericMap(key, value, modifiers | ModifiedTypeID.MODIFIER_OPTIONAL, storage);
38
 	}
39
 	}
39
 
40
 
40
 	@Override
41
 	@Override
41
 	public IParsedType withModifiers(int modifiers) {
42
 	public IParsedType withModifiers(int modifiers) {
42
-		return new ParsedTypeGenericMap(key, value, modifiers | this.modifiers);
43
+		return new ParsedTypeGenericMap(key, value, modifiers | this.modifiers, storage);
43
 	}
44
 	}
44
 
45
 
45
 	@Override
46
 	@Override

Loading…
Cancel
Save