Explorar el Código

Moved Array default value to default value expression

kindlich hace 5 años
padre
commit
e614149c8c
No se encontró ninguna clave conocida en la base de datos para esta firma

+ 1
- 1
JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/compiler/JavaExpressionVisitor.java Ver fichero

@@ -3325,7 +3325,7 @@ public class JavaExpressionVisitor implements ExpressionVisitor<Void>, JavaNativ
3325 3325
 
3326 3326
 
3327 3327
 				if (builtin == BuiltinID.ARRAY_CONSTRUCTOR_SIZED) {
3328
-					type.elementType.type.accept(JavaDefaultExpressionTypeVisitor.INSTANCE).accept(this);
3328
+					type.elementType.type.getDefaultValue().accept(this);
3329 3329
 				} else {
3330 3330
 					expression.arguments.arguments[expression.arguments.arguments.length - 1].accept(this);
3331 3331
 				}

+ 0
- 113
JavaShared/src/main/java/org/openzen/zenscript/javashared/JavaDefaultExpressionTypeVisitor.java Ver fichero

@@ -1,113 +0,0 @@
1
-package org.openzen.zenscript.javashared;
2
-
3
-import org.openzen.zencode.shared.CodePosition;
4
-import org.openzen.zenscript.codemodel.expression.*;
5
-import org.openzen.zenscript.codemodel.type.*;
6
-
7
-public class JavaDefaultExpressionTypeVisitor implements TypeVisitor<Expression> {
8
-
9
-	public static final JavaDefaultExpressionTypeVisitor INSTANCE = new JavaDefaultExpressionTypeVisitor();
10
-
11
-	private JavaDefaultExpressionTypeVisitor(){}
12
-
13
-	@Override
14
-	public Expression visitBasic(BasicTypeID basic) {
15
-
16
-
17
-		if (basic == null)
18
-			throw new IllegalStateException("Null basic type!");
19
-
20
-		switch (basic) {
21
-			case UNDETERMINED:
22
-			case VOID:
23
-				throw new IllegalStateException("Void and Undetermined have no default type");
24
-			case NULL:
25
-				return new NullExpression(CodePosition.UNKNOWN);
26
-			case BOOL:
27
-				return new ConstantBoolExpression(CodePosition.UNKNOWN, false);
28
-			case BYTE:
29
-				return new ConstantByteExpression(CodePosition.UNKNOWN, 0);
30
-			case SBYTE:
31
-				return new ConstantSByteExpression(CodePosition.UNKNOWN, (byte) 0);
32
-			case SHORT:
33
-				return new ConstantShortExpression(CodePosition.UNKNOWN, (short) 0);
34
-			case USHORT:
35
-				return new ConstantUShortExpression(CodePosition.UNKNOWN, 0);
36
-			case INT:
37
-				return new ConstantIntExpression(CodePosition.UNKNOWN, 0);
38
-			case UINT:
39
-				return new ConstantUIntExpression(CodePosition.UNKNOWN, 0);
40
-			case LONG:
41
-				return new ConstantLongExpression(CodePosition.UNKNOWN, 0L);
42
-			case ULONG:
43
-				return new ConstantULongExpression(CodePosition.UNKNOWN, 0L);
44
-			case USIZE:
45
-				return new ConstantUSizeExpression(CodePosition.UNKNOWN, 0L);
46
-			case FLOAT:
47
-				return new ConstantFloatExpression(CodePosition.UNKNOWN, 0.0f);
48
-			case DOUBLE:
49
-				return new ConstantDoubleExpression(CodePosition.UNKNOWN, 0.0d);
50
-			case CHAR:
51
-				return new ConstantCharExpression(CodePosition.UNKNOWN, '\0');
52
-			default:
53
-				throw new IllegalStateException("Unknown basic type!");
54
-		}
55
-
56
-
57
-	}
58
-
59
-	@Override
60
-	public Expression visitString(StringTypeID string) {
61
-		return new NullExpression(CodePosition.UNKNOWN);
62
-	}
63
-
64
-	@Override
65
-	public Expression visitArray(ArrayTypeID array) {
66
-		return new NullExpression(CodePosition.UNKNOWN);
67
-	}
68
-
69
-	@Override
70
-	public Expression visitAssoc(AssocTypeID assoc) {
71
-		return new NullExpression(CodePosition.UNKNOWN);
72
-	}
73
-
74
-	@Override
75
-	public Expression visitGenericMap(GenericMapTypeID map) {
76
-		return new NullExpression(CodePosition.UNKNOWN);
77
-	}
78
-
79
-	@Override
80
-	public Expression visitIterator(IteratorTypeID iterator) {
81
-		return new NullExpression(CodePosition.UNKNOWN);
82
-	}
83
-
84
-	@Override
85
-	public Expression visitFunction(FunctionTypeID function) {
86
-		return new NullExpression(CodePosition.UNKNOWN);
87
-	}
88
-
89
-	@Override
90
-	public Expression visitDefinition(DefinitionTypeID definition) {
91
-		return new NullExpression(CodePosition.UNKNOWN);
92
-	}
93
-
94
-	@Override
95
-	public Expression visitGeneric(GenericTypeID generic) {
96
-		return new NullExpression(CodePosition.UNKNOWN);
97
-	}
98
-
99
-	@Override
100
-	public Expression visitRange(RangeTypeID range) {
101
-		return new NullExpression(CodePosition.UNKNOWN);
102
-	}
103
-
104
-	@Override
105
-	public Expression visitOptional(OptionalTypeID type) {
106
-		return new NullExpression(CodePosition.UNKNOWN);
107
-	}
108
-
109
-	@Override
110
-	public Expression visitInvalid(InvalidTypeID type) {
111
-		return new NullExpression(CodePosition.UNKNOWN);
112
-	}
113
-}

Loading…
Cancelar
Guardar