ソースを参照

WIP on memory tags

Stan Hebben 6年前
コミット
d9a78c015b
32個のファイルの変更501行の追加103行の削除
  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 ファイルの表示

@@ -22,6 +22,7 @@ import org.openzen.zenscript.codemodel.scope.StatementScope;
22 22
 import org.openzen.zenscript.codemodel.serialization.CodeSerializationInput;
23 23
 import org.openzen.zenscript.codemodel.statement.Statement;
24 24
 import org.openzen.zenscript.codemodel.type.BasicTypeID;
25
+import org.openzen.zenscript.codemodel.type.StringTypeID;
25 26
 
26 27
 /**
27 28
  *
@@ -31,7 +32,7 @@ public class NativeAnnotationDefinition implements AnnotationDefinition {
31 32
 	public static final NativeAnnotationDefinition INSTANCE = new NativeAnnotationDefinition();
32 33
 	
33 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 37
 	private NativeAnnotationDefinition() {}
37 38
 

+ 2
- 1
CodeModel/src/main/java/org/openzen/zenscript/codemodel/annotations/PreconditionAnnotationDefinition.java ファイルの表示

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

+ 2
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/expression/ConstantStringExpression.java ファイルの表示

@@ -7,7 +7,7 @@ package org.openzen.zenscript.codemodel.expression;
7 7
 
8 8
 import org.openzen.zencode.shared.CodePosition;
9 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,7 +17,7 @@ public class ConstantStringExpression extends Expression {
17 17
 	public final String value;
18 18
 	
19 19
 	public ConstantStringExpression(CodePosition position, String value) {
20
-		super(position, BasicTypeID.STRING, null);
20
+		super(position, StringTypeID.STATIC, null);
21 21
 		
22 22
 		this.value = value;
23 23
 	}

+ 1
- 2
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/BasicTypeID.java ファイルの表示

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

+ 5
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/ITypeID.java ファイルの表示

@@ -102,6 +102,11 @@ public interface ITypeID {
102 102
 		public Boolean visitBasic(BasicTypeID basic) {
103 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 111
 		@Override
107 112
 		public Boolean visitArray(ArrayTypeID array) {

+ 79
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/StringTypeID.java ファイルの表示

@@ -0,0 +1,79 @@
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 ファイルの表示

@@ -24,6 +24,11 @@ public class TypeParameterCollector implements TypeVisitor<Void> {
24 24
 	public Void visitBasic(BasicTypeID basic) {
25 25
 		return null;
26 26
 	}
27
+	
28
+	@Override
29
+	public Void visitString(StringTypeID string) {
30
+		return null;
31
+	}
27 32
 
28 33
 	@Override
29 34
 	public Void visitArray(ArrayTypeID array) {

+ 2
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/TypeVisitor.java ファイルの表示

@@ -12,6 +12,8 @@ package org.openzen.zenscript.codemodel.type;
12 12
 public interface TypeVisitor<T> {
13 13
 	public T visitBasic(BasicTypeID basic);
14 14
 	
15
+	public T visitString(StringTypeID string);
16
+	
15 17
 	public T visitArray(ArrayTypeID array);
16 18
 	
17 19
 	public T visitAssoc(AssocTypeID assoc);

+ 2
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/TypeVisitorWithContext.java ファイルの表示

@@ -12,6 +12,8 @@ package org.openzen.zenscript.codemodel.type;
12 12
 public interface TypeVisitorWithContext<C, R> {
13 13
 	R visitBasic(C context, BasicTypeID basic);
14 14
 	
15
+	R visitString(C context, StringTypeID string);
16
+	
15 17
 	R visitArray(C context, ArrayTypeID array);
16 18
 	
17 19
 	R visitAssoc(C context, AssocTypeID assoc);

+ 64
- 64
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/member/TypeMemberBuilder.java ファイルの表示

@@ -71,6 +71,7 @@ import org.openzen.zenscript.codemodel.Module;
71 71
 import org.openzen.zenscript.codemodel.definition.InterfaceDefinition;
72 72
 import org.openzen.zenscript.codemodel.expression.ConstantUSizeExpression;
73 73
 import org.openzen.zenscript.codemodel.member.IteratorMember;
74
+import org.openzen.zenscript.codemodel.type.StringTypeID;
74 75
 import org.openzen.zenscript.codemodel.type.TypeVisitor;
75 76
 
76 77
 /**
@@ -163,13 +164,36 @@ public class TypeMemberBuilder implements TypeVisitor<Void> {
163 164
 			case CHAR:
164 165
 				visitChar();
165 166
 				break;
166
-			case STRING:
167
-				visitString();
168
-				break;
169 167
 		}
170 168
 		
171 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 198
 	@Override
175 199
 	public Void visitArray(ArrayTypeID array) {
@@ -464,7 +488,7 @@ public class TypeMemberBuilder implements TypeVisitor<Void> {
464 488
 		}
465 489
 		
466 490
 		if (definition instanceof EnumDefinition) {
467
-			getter(definition, ENUM_NAME, "name", STRING);
491
+			getter(definition, ENUM_NAME, "name", StringTypeID.STATIC);
468 492
 			getter(definition, ENUM_ORDINAL, "ordinal", USIZE);
469 493
 			
470 494
 			List<EnumConstantMember> enumConstants = ((EnumDefinition) definition).enumConstants;
@@ -475,8 +499,8 @@ public class TypeMemberBuilder implements TypeVisitor<Void> {
475 499
 			constant(definition, ENUM_VALUES, "values", new ArrayExpression(BUILTIN, constValues, registry.getArray(type, 1)));
476 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,8 +580,8 @@ public class TypeMemberBuilder implements TypeVisitor<Void> {
556 580
 		equals(builtin, BOOL_EQUALS, BOOL);
557 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 586
 		processType(builtin, BOOL);
563 587
 	}
@@ -591,10 +615,10 @@ public class TypeMemberBuilder implements TypeVisitor<Void> {
591 615
 		castImplicit(builtin, BYTE_TO_FLOAT, FLOAT);
592 616
 		castImplicit(builtin, BYTE_TO_DOUBLE, DOUBLE);
593 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 623
 		constant(builtin, BYTE_GET_MIN_VALUE, "MIN_VALUE", new ConstantByteExpression(BUILTIN, 0));
600 624
 		constant(builtin, BYTE_GET_MAX_VALUE, "MAX_VALUE", new ConstantByteExpression(BUILTIN, 255));
@@ -633,10 +657,10 @@ public class TypeMemberBuilder implements TypeVisitor<Void> {
633 657
 		castImplicit(builtin, SBYTE_TO_FLOAT, FLOAT);
634 658
 		castImplicit(builtin, SBYTE_TO_DOUBLE, DOUBLE);
635 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 665
 		constant(builtin, SBYTE_GET_MIN_VALUE, "MIN_VALUE", new ConstantSByteExpression(BUILTIN, Byte.MIN_VALUE));
642 666
 		constant(builtin, SBYTE_GET_MAX_VALUE, "MAX_VALUE", new ConstantSByteExpression(BUILTIN, Byte.MAX_VALUE));
@@ -675,10 +699,10 @@ public class TypeMemberBuilder implements TypeVisitor<Void> {
675 699
 		castImplicit(builtin, SHORT_TO_FLOAT, FLOAT);
676 700
 		castImplicit(builtin, SHORT_TO_DOUBLE, DOUBLE);
677 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 707
 		constant(builtin, SHORT_GET_MIN_VALUE, "MIN_VALUE", new ConstantShortExpression(BUILTIN, Short.MIN_VALUE));
684 708
 		constant(builtin, SHORT_GET_MAX_VALUE, "MAX_VALUE", new ConstantShortExpression(BUILTIN, Short.MAX_VALUE));
@@ -715,10 +739,10 @@ public class TypeMemberBuilder implements TypeVisitor<Void> {
715 739
 		castImplicit(builtin, USHORT_TO_FLOAT, FLOAT);
716 740
 		castImplicit(builtin, USHORT_TO_DOUBLE, DOUBLE);
717 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 747
 		constant(builtin, USHORT_GET_MIN_VALUE, "MIN_VALUE", new ConstantUShortExpression(BUILTIN, 0));
724 748
 		constant(builtin, USHORT_GET_MAX_VALUE, "MAX_VALUE", new ConstantUShortExpression(BUILTIN, 65535));
@@ -787,10 +811,10 @@ public class TypeMemberBuilder implements TypeVisitor<Void> {
787 811
 		castImplicit(builtin, INT_TO_FLOAT, FLOAT);
788 812
 		castImplicit(builtin, INT_TO_DOUBLE, DOUBLE);
789 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 819
 		method(builtin, INT_COUNT_LOW_ZEROES, "countLowZeroes", INT);
796 820
 		method(builtin, INT_COUNT_HIGH_ZEROES, "countHighZeroes", INT);
@@ -866,10 +890,10 @@ public class TypeMemberBuilder implements TypeVisitor<Void> {
866 890
 		castImplicit(builtin, UINT_TO_FLOAT, FLOAT);
867 891
 		castImplicit(builtin, UINT_TO_DOUBLE, DOUBLE);
868 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 898
 		method(builtin, UINT_COUNT_LOW_ZEROES, "countLowZeroes", UINT);
875 899
 		method(builtin, UINT_COUNT_HIGH_ZEROES, "countHighZeroes", UINT);
@@ -939,10 +963,10 @@ public class TypeMemberBuilder implements TypeVisitor<Void> {
939 963
 		castImplicit(builtin, LONG_TO_FLOAT, FLOAT);
940 964
 		castImplicit(builtin, LONG_TO_DOUBLE, DOUBLE);
941 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 971
 		method(builtin, LONG_COUNT_LOW_ZEROES, "countLowZeroes", INT);
948 972
 		method(builtin, LONG_COUNT_HIGH_ZEROES, "countHighZeroes", INT);
@@ -1011,10 +1035,10 @@ public class TypeMemberBuilder implements TypeVisitor<Void> {
1011 1035
 		castImplicit(builtin, ULONG_TO_FLOAT, FLOAT);
1012 1036
 		castImplicit(builtin, ULONG_TO_DOUBLE, DOUBLE);
1013 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 1043
 		method(builtin, ULONG_COUNT_LOW_ZEROES, "countLowZeroes", INT);
1020 1044
 		method(builtin, ULONG_COUNT_HIGH_ZEROES, "countHighZeroes", INT);
@@ -1088,10 +1112,10 @@ public class TypeMemberBuilder implements TypeVisitor<Void> {
1088 1112
 		castImplicit(builtin, USIZE_TO_FLOAT, FLOAT);
1089 1113
 		castImplicit(builtin, USIZE_TO_DOUBLE, DOUBLE);
1090 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 1120
 		method(builtin, USIZE_COUNT_LOW_ZEROES, "countLowZeroes", INT);
1097 1121
 		method(builtin, USIZE_COUNT_HIGH_ZEROES, "countHighZeroes", INT);
@@ -1143,9 +1167,9 @@ public class TypeMemberBuilder implements TypeVisitor<Void> {
1143 1167
 		castExplicit(builtin, FLOAT_TO_ULONG, ULONG);
1144 1168
 		castExplicit(builtin, FLOAT_TO_USIZE, USIZE);
1145 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 1173
 		staticMethod(builtin, FLOAT_FROM_BITS, "fromBits", FLOAT, UINT);
1150 1174
 		
1151 1175
 		getter(builtin, FLOAT_BITS, "bits", UINT);
@@ -1179,9 +1203,9 @@ public class TypeMemberBuilder implements TypeVisitor<Void> {
1179 1203
 		castExplicit(builtin, DOUBLE_TO_ULONG, ULONG);
1180 1204
 		castExplicit(builtin, DOUBLE_TO_USIZE, USIZE);
1181 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 1209
 		staticMethod(builtin, DOUBLE_FROM_BITS, "fromBits", DOUBLE, ULONG);
1186 1210
 		
1187 1211
 		getter(builtin, DOUBLE_BITS, "bits", ULONG);
@@ -1206,7 +1230,7 @@ public class TypeMemberBuilder implements TypeVisitor<Void> {
1206 1230
 		castImplicit(builtin, CHAR_TO_LONG, LONG);
1207 1231
 		castImplicit(builtin, CHAR_TO_ULONG, ULONG);
1208 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 1235
 		getter(builtin, CHAR_GET_MIN_VALUE, "MIN_VALUE", CHAR);
1212 1236
 		getter(builtin, CHAR_GET_MAX_VALUE, "MAX_VALUE", CHAR);
@@ -1217,30 +1241,6 @@ public class TypeMemberBuilder implements TypeVisitor<Void> {
1217 1241
 		
1218 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 1245
 	private void castedTargetCall(OperatorMember member, ITypeID toType, BuiltinID casterBuiltin) {
1246 1246
 		CasterMemberRef caster = castImplicitRef(member.definition, casterBuiltin, toType);

+ 21
- 0
CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/storage/AnyStorageTag.java ファイルの表示

@@ -0,0 +1,21 @@
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 ファイルの表示

@@ -0,0 +1,16 @@
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 ファイルの表示

@@ -0,0 +1,21 @@
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 ファイルの表示

@@ -0,0 +1,16 @@
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 ファイルの表示

@@ -0,0 +1,21 @@
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 ファイルの表示

@@ -0,0 +1,16 @@
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 ファイルの表示

@@ -0,0 +1,21 @@
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 ファイルの表示

@@ -0,0 +1,16 @@
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 ファイルの表示

@@ -0,0 +1,14 @@
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 ファイルの表示

@@ -0,0 +1,14 @@
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 ファイルの表示

@@ -0,0 +1,21 @@
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 ファイルの表示

@@ -0,0 +1,16 @@
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 ファイルの表示

@@ -78,6 +78,7 @@ public enum ZSTokenType implements TokenType {
78 78
 	T_NOTEQUAL("!=", "!="),
79 79
 	T_NOT("!", "!"),
80 80
 	T_DOLLAR("$", "$"),
81
+	T_BACKTICK("`", "`"),
81 82
 	
82 83
 	K_IMPORT(true, "import"),
83 84
 	K_ALIAS(true, "alias"),

+ 14
- 8
Parser/src/main/java/org/openzen/zenscript/parser/type/IParsedType.java ファイルの表示

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

+ 7
- 5
Parser/src/main/java/org/openzen/zenscript/parser/type/ParsedFunctionType.java ファイルの表示

@@ -9,7 +9,6 @@ import org.openzen.zencode.shared.CodePosition;
9 9
 import org.openzen.zenscript.codemodel.context.TypeResolutionContext;
10 10
 import org.openzen.zenscript.codemodel.type.ITypeID;
11 11
 import org.openzen.zenscript.codemodel.type.ModifiedTypeID;
12
-import org.openzen.zenscript.codemodel.type.member.TypeMembers;
13 12
 import org.openzen.zenscript.parser.definitions.ParsedFunctionHeader;
14 13
 
15 14
 /**
@@ -20,27 +19,30 @@ public class ParsedFunctionType implements IParsedType {
20 19
 	private final CodePosition position;
21 20
 	private final int modifiers;
22 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 25
 		this.position = position;
26 26
 		this.header = header;
27 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 32
 		this.position = position;
32 33
 		this.header = header;
33 34
 		this.modifiers = modifiers;
35
+		this.storageTag = storageTag;
34 36
 	}
35 37
 	
36 38
 	@Override
37 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 43
 	@Override
42 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 48
 	@Override

+ 7
- 4
Parser/src/main/java/org/openzen/zenscript/parser/type/ParsedNamedType.java ファイルの表示

@@ -25,17 +25,20 @@ public class ParsedNamedType implements IParsedType {
25 25
 	private final CodePosition position;
26 26
 	private final int modifiers;
27 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 31
 		this.position = position;
31 32
 		this.modifiers = 0;
32 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 38
 		this.position = position;
37 39
 		this.modifiers = modifiers;
38 40
 		this.name = name;
41
+		this.storage = storage;
39 42
 	}
40 43
 	
41 44
 	@Override
@@ -60,12 +63,12 @@ public class ParsedNamedType implements IParsedType {
60 63
 	
61 64
 	@Override
62 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 69
 	@Override
67 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 74
 	@Override

+ 36
- 0
Parser/src/main/java/org/openzen/zenscript/parser/type/ParsedStorageTag.java ファイルの表示

@@ -0,0 +1,36 @@
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 ファイルの表示

@@ -0,0 +1,40 @@
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 ファイルの表示

@@ -9,7 +9,6 @@ import org.openzen.zenscript.codemodel.context.TypeResolutionContext;
9 9
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
10 10
 import org.openzen.zenscript.codemodel.type.ITypeID;
11 11
 import org.openzen.zenscript.codemodel.type.ModifiedTypeID;
12
-import org.openzen.zenscript.codemodel.type.member.TypeMembers;
13 12
 
14 13
 /**
15 14
  *
@@ -19,27 +18,30 @@ public class ParsedTypeArray implements IParsedType {
19 18
 	public final IParsedType baseType;
20 19
 	public final int dimension;
21 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 24
 		this.baseType = baseType;
25 25
 		this.dimension = dimension;
26 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 31
 		this.baseType = baseType;
31 32
 		this.dimension = dimension;
32 33
 		this.modifiers = modifiers;
34
+		this.storageTag = storageTag;
33 35
 	}
34 36
 	
35 37
 	@Override
36 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 42
 	@Override
41 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 47
 	@Override

+ 7
- 6
Parser/src/main/java/org/openzen/zenscript/parser/type/ParsedTypeAssociative.java ファイルの表示

@@ -8,8 +8,6 @@ package org.openzen.zenscript.parser.type;
8 8
 import org.openzen.zenscript.codemodel.context.TypeResolutionContext;
9 9
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
10 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 11
 import org.openzen.zenscript.codemodel.type.ModifiedTypeID;
14 12
 
15 13
 /**
@@ -20,27 +18,30 @@ public class ParsedTypeAssociative implements IParsedType {
20 18
 	public final IParsedType key;
21 19
 	public final IParsedType value;
22 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 24
 		this.key = key;
26 25
 		this.value = value;
27 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 31
 		this.key = key;
32 32
 		this.value = value;
33 33
 		this.modifiers = modifiers;
34
+		this.storage = storage;
34 35
 	}
35 36
 	
36 37
 	@Override
37 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 42
 	@Override
42 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 47
 	@Override

+ 0
- 1
Parser/src/main/java/org/openzen/zenscript/parser/type/ParsedTypeBasic.java ファイルの表示

@@ -28,7 +28,6 @@ public enum ParsedTypeBasic implements IParsedType {
28 28
 	FLOAT(BasicTypeID.FLOAT),
29 29
 	DOUBLE(BasicTypeID.DOUBLE),
30 30
 	CHAR(BasicTypeID.CHAR),
31
-	STRING(BasicTypeID.STRING),
32 31
 	
33 32
 	UNDETERMINED(BasicTypeID.UNDETERMINED);
34 33
 	

+ 5
- 4
Parser/src/main/java/org/openzen/zenscript/parser/type/ParsedTypeGenericMap.java ファイルの表示

@@ -14,7 +14,6 @@ import org.openzen.zenscript.codemodel.type.GenericName;
14 14
 import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
15 15
 import org.openzen.zenscript.codemodel.type.ITypeID;
16 16
 import org.openzen.zenscript.codemodel.type.ModifiedTypeID;
17
-import org.openzen.zenscript.codemodel.type.member.TypeMembers;
18 17
 import org.openzen.zenscript.parser.definitions.ParsedTypeParameter;
19 18
 
20 19
 /**
@@ -25,21 +24,23 @@ public class ParsedTypeGenericMap implements IParsedType {
25 24
 	private final ParsedTypeParameter key;
26 25
 	private final IParsedType value;
27 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 30
 		this.key = key;
31 31
 		this.value = value;
32 32
 		this.modifiers = modifiers;
33
+		this.storage = storage;
33 34
 	}
34 35
 
35 36
 	@Override
36 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 41
 	@Override
41 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 46
 	@Override

読み込み中…
キャンセル
保存