|
@@ -58,8 +58,8 @@ import org.openzen.zenscript.codemodel.statement.SwitchCase;
|
58
|
58
|
import org.openzen.zenscript.codemodel.statement.SwitchStatement;
|
59
|
59
|
import org.openzen.zenscript.codemodel.statement.ThrowStatement;
|
60
|
60
|
import org.openzen.zenscript.codemodel.statement.VarStatement;
|
|
61
|
+import org.openzen.zenscript.codemodel.statement.VariableID;
|
61
|
62
|
import org.openzen.zenscript.codemodel.statement.WhileStatement;
|
62
|
|
-import org.openzen.zenscript.codemodel.type.ArrayTypeID;
|
63
|
63
|
import org.openzen.zenscript.codemodel.type.BasicTypeID;
|
64
|
64
|
import org.openzen.zenscript.codemodel.type.DefinitionTypeID;
|
65
|
65
|
import org.openzen.zenscript.codemodel.type.GlobalTypeRegistry;
|
|
@@ -70,6 +70,7 @@ import org.openzen.zenscript.codemodel.type.TypeID;
|
70
|
70
|
import org.openzen.zenscript.codemodel.type.member.BuiltinID;
|
71
|
71
|
import org.openzen.zenscript.codemodel.type.member.TypeMembers;
|
72
|
72
|
import org.openzen.zenscript.codemodel.type.storage.StaticExpressionStorageTag;
|
|
73
|
+import org.openzen.zenscript.codemodel.type.storage.StorageTag;
|
73
|
74
|
import org.openzen.zenscript.codemodel.type.storage.UniqueStorageTag;
|
74
|
75
|
import org.openzen.zenscript.moduleserialization.CodePositionEncoding;
|
75
|
76
|
import org.openzen.zenscript.moduleserialization.ExpressionEncoding;
|
|
@@ -249,7 +250,7 @@ public class CodeReader implements CodeSerializationInput {
|
249
|
250
|
public AnnotationDefinition readAnnotationType() {
|
250
|
251
|
return annotations[readUInt()];
|
251
|
252
|
}
|
252
|
|
-
|
|
253
|
+
|
253
|
254
|
@Override
|
254
|
255
|
public TypeID deserializeTypeID(TypeContext context) {
|
255
|
256
|
int type = input.readVarUInt();
|
|
@@ -290,17 +291,17 @@ public class CodeReader implements CodeSerializationInput {
|
290
|
291
|
return BasicTypeID.UNDETERMINED;
|
291
|
292
|
case TypeEncoding.TYPE_DEFINITION: {
|
292
|
293
|
HighLevelDefinition definition = readDefinition();
|
293
|
|
- TypeID[] arguments = new TypeID[definition.typeParameters.length];
|
|
294
|
+ StoredType[] arguments = new StoredType[definition.typeParameters.length];
|
294
|
295
|
for (int i = 0; i < arguments.length; i++)
|
295
|
|
- arguments[i] = deserializeTypeID(context);
|
|
296
|
+ arguments[i] = deserializeType(context);
|
296
|
297
|
return registry.getForDefinition(definition, arguments);
|
297
|
298
|
}
|
298
|
299
|
case TypeEncoding.TYPE_DEFINITION_INNER: {
|
299
|
300
|
DefinitionTypeID outer = (DefinitionTypeID)deserializeTypeID(context);
|
300
|
301
|
HighLevelDefinition definition = readDefinition();
|
301
|
|
- TypeID[] arguments = new TypeID[definition.typeParameters.length];
|
|
302
|
+ StoredType[] arguments = new StoredType[definition.typeParameters.length];
|
302
|
303
|
for (int i = 0; i < arguments.length; i++)
|
303
|
|
- arguments[i] = deserializeTypeID(context);
|
|
304
|
+ arguments[i] = deserializeStoredType(context);
|
304
|
305
|
return registry.getForDefinition(definition, arguments, outer);
|
305
|
306
|
}
|
306
|
307
|
case TypeEncoding.TYPE_GENERIC:
|
|
@@ -335,10 +336,6 @@ public class CodeReader implements CodeSerializationInput {
|
335
|
336
|
}
|
336
|
337
|
case TypeEncoding.TYPE_OPTIONAL:
|
337
|
338
|
return registry.getOptional(deserializeTypeID(context));
|
338
|
|
- case TypeEncoding.TYPE_CONST:
|
339
|
|
- return registry.getModified(OptionalTypeID.MODIFIER_CONST, deserializeTypeID(context));
|
340
|
|
- case TypeEncoding.TYPE_IMMUTABLE:
|
341
|
|
- return registry.getModified(OptionalTypeID.MODIFIER_IMMUTABLE, deserializeTypeID(context));
|
342
|
339
|
default:
|
343
|
340
|
throw new IllegalArgumentException("Unknown type: " + type);
|
344
|
341
|
}
|
|
@@ -396,6 +393,10 @@ public class CodeReader implements CodeSerializationInput {
|
396
|
393
|
if ((flags & FunctionHeaderEncoding.FLAG_THROWS) > 0)
|
397
|
394
|
thrownType = deserializeType(inner);
|
398
|
395
|
|
|
396
|
+ StorageTag storage = null;
|
|
397
|
+ if ((flags & FunctionHeaderEncoding.FLAG_STORAGE) > 0)
|
|
398
|
+ storage = deserializeStorage();
|
|
399
|
+
|
399
|
400
|
FunctionParameter[] parameters = FunctionParameter.NONE;
|
400
|
401
|
if ((flags & FunctionHeaderEncoding.FLAG_PARAMETERS) > 0) {
|
401
|
402
|
parameters = new FunctionParameter[readUInt()];
|
|
@@ -415,7 +416,7 @@ public class CodeReader implements CodeSerializationInput {
|
415
|
416
|
}
|
416
|
417
|
}
|
417
|
418
|
}
|
418
|
|
- return new FunctionHeader(typeParameters, returnType, thrownType, parameters);
|
|
419
|
+ return new FunctionHeader(typeParameters, returnType, thrownType, storage, parameters);
|
419
|
420
|
}
|
420
|
421
|
|
421
|
422
|
@Override
|
|
@@ -480,9 +481,9 @@ public class CodeReader implements CodeSerializationInput {
|
480
|
481
|
|
481
|
482
|
@Override
|
482
|
483
|
public CallArguments deserializeArguments(StatementContext context) {
|
483
|
|
- TypeID[] typeArguments = new TypeID[readUInt()];
|
|
484
|
+ StoredType[] typeArguments = new StoredType[readUInt()];
|
484
|
485
|
for (int i = 0; i < typeArguments.length; i++)
|
485
|
|
- typeArguments[i] = deserializeTypeID(context);
|
|
486
|
+ typeArguments[i] = deserializeType(context);
|
486
|
487
|
|
487
|
488
|
Expression[] arguments = new Expression[readUInt()];
|
488
|
489
|
for (int i = 0; i < arguments.length; i++)
|
|
@@ -536,7 +537,7 @@ public class CodeReader implements CodeSerializationInput {
|
536
|
537
|
VarStatement[] loopVariables = new VarStatement[iterator.getLoopVariableCount()];
|
537
|
538
|
for (int i = 0; i < loopVariables.length; i++) {
|
538
|
539
|
String name = ((flags & StatementEncoding.FLAG_NAME) > 0) ? readString() : null;
|
539
|
|
- loopVariables[i] = new VarStatement(position, name, iterator.types[i], null, true);
|
|
540
|
+ loopVariables[i] = new VarStatement(position, new VariableID(), name, iterator.types[i], null, true);
|
540
|
541
|
}
|
541
|
542
|
ForeachStatement loop = new ForeachStatement(position, loopVariables, iterator, list);
|
542
|
543
|
StatementContext inner = new StatementContext(context, loop);
|
|
@@ -591,7 +592,7 @@ public class CodeReader implements CodeSerializationInput {
|
591
|
592
|
StoredType varType = deserializeType(context);
|
592
|
593
|
String name = (flags & StatementEncoding.FLAG_NAME) > 0 ? readString() : null;
|
593
|
594
|
Expression initializer = deserializeExpression(context);
|
594
|
|
- VarStatement result = new VarStatement(position, name, varType, initializer, (flags & StatementEncoding.FLAG_FINAL) > 0);
|
|
595
|
+ VarStatement result = new VarStatement(position, new VariableID(), name, varType, initializer, (flags & StatementEncoding.FLAG_FINAL) > 0);
|
595
|
596
|
context.add(result);
|
596
|
597
|
return result;
|
597
|
598
|
}
|
|
@@ -637,14 +638,14 @@ public class CodeReader implements CodeSerializationInput {
|
637
|
638
|
Expression target = deserializeExpression(context);
|
638
|
639
|
FunctionalMemberRef member = (FunctionalMemberRef)readMember(context, target.type);
|
639
|
640
|
CallArguments arguments = deserializeArguments(context);
|
640
|
|
- FunctionHeader instancedHeader = member.getHeader().instanceForCall(registry, arguments);
|
|
641
|
+ FunctionHeader instancedHeader = member.getHeader().instanceForCall(position, registry, arguments);
|
641
|
642
|
return new CallExpression(position, target, member, instancedHeader, arguments);
|
642
|
643
|
}
|
643
|
644
|
case ExpressionEncoding.TYPE_CALL_STATIC: {
|
644
|
645
|
TypeID type = deserializeTypeID(context);
|
645
|
646
|
FunctionalMemberRef member = (FunctionalMemberRef)readMember(context, type.stored(StaticExpressionStorageTag.INSTANCE));
|
646
|
647
|
CallArguments arguments = deserializeArguments(context);
|
647
|
|
- FunctionHeader instancedHeader = member.getHeader().instanceForCall(registry, arguments);
|
|
648
|
+ FunctionHeader instancedHeader = member.getHeader().instanceForCall(position, registry, arguments);
|
648
|
649
|
return new CallStaticExpression(position, type, member, instancedHeader, arguments);
|
649
|
650
|
}
|
650
|
651
|
case ExpressionEncoding.TYPE_CAPTURED_CLOSURE: {
|
|
@@ -792,11 +793,11 @@ public class CodeReader implements CodeSerializationInput {
|
792
|
793
|
TypeID type = deserializeTypeID(context);
|
793
|
794
|
return new IsExpression(position, value, type);
|
794
|
795
|
}
|
795
|
|
- case ExpressionEncoding.TYPE_MAKE_CONST: {
|
|
796
|
+ /*case ExpressionEncoding.TYPE_MAKE_CONST: {
|
796
|
797
|
Expression value = deserializeExpression(context);
|
797
|
|
- StoredType constType = registry.getModified(OptionalTypeID.MODIFIER_CONST, value.type.type).stored(value.type.getActualStorage());
|
|
798
|
+ StoredType constType = registry.get(OptionalTypeID.MODIFIER_CONST, value.type.type).stored(value.type.getActualStorage());
|
798
|
799
|
return new MakeConstExpression(position, value, constType);
|
799
|
|
- }
|
|
800
|
+ }*/
|
800
|
801
|
case ExpressionEncoding.TYPE_MAP: {
|
801
|
802
|
StoredType type = deserializeType(context);
|
802
|
803
|
Expression[] keys = new Expression[readUInt()];
|