diff --git a/CodeFormatter/src/main/java/org/openzen/zenscript/formatter/TypeFormatter.java b/CodeFormatter/src/main/java/org/openzen/zenscript/formatter/TypeFormatter.java index c28d49006..4627f3f4a 100644 --- a/CodeFormatter/src/main/java/org/openzen/zenscript/formatter/TypeFormatter.java +++ b/CodeFormatter/src/main/java/org/openzen/zenscript/formatter/TypeFormatter.java @@ -23,7 +23,7 @@ public String format(TypeID type) { @Override public String visitBasic(BasicTypeID basic) { - return basic.name; + return basic.getName(); } @Override diff --git a/CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/BasicTypeID.java b/CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/BasicTypeID.java index 652af866c..dd2a342dd 100644 --- a/CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/BasicTypeID.java +++ b/CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/BasicTypeID.java @@ -34,7 +34,7 @@ public enum BasicTypeID implements TypeID, TypeSymbol { UNDETERMINED("undetermined"), INVALID("invalid"); - public final String name; + private final String name; private ResolvingType members; private Expression defaultValue = null; @@ -63,11 +63,6 @@ public R accept(C context, TypeVisitorWithContext typeParameters) { - + // BasicTypeIDs don't have type parameters } private Expression generateDefaultValue() { @@ -183,10 +178,11 @@ public String getName() { @Override public ResolvingType resolve(TypeID[] typeArguments) { - if (members == null) - members = BasicTypeMembers.get(this); + if(typeArguments.length > 0) { + throw new IllegalArgumentException(this + " cannot have type arguments"); + } - return members; + return this.resolve(); } @Override diff --git a/CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/builtin/BasicTypeMembers.java b/CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/builtin/BasicTypeMembers.java index d515b1d74..389baa854 100644 --- a/CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/builtin/BasicTypeMembers.java +++ b/CodeModel/src/main/java/org/openzen/zenscript/codemodel/type/builtin/BasicTypeMembers.java @@ -6,6 +6,7 @@ import org.openzen.zenscript.codemodel.compilation.CastedEval; import org.openzen.zenscript.codemodel.compilation.CastedExpression; import org.openzen.zenscript.codemodel.compilation.CompileErrors; +import org.openzen.zenscript.codemodel.compilation.ResolvingType; import org.openzen.zenscript.codemodel.expression.CompareExpression; import org.openzen.zenscript.codemodel.expression.Expression; import org.openzen.zenscript.codemodel.identifiers.MethodID; @@ -21,7 +22,7 @@ public class BasicTypeMembers { private static final MethodID CONSTRUCTOR = MethodID.staticOperator(OperatorType.CONSTRUCTOR); private static final MethodID COMPARE = MethodID.operator(OperatorType.COMPARE); - public static MemberSet.Resolving get(BasicTypeID type) { + public static ResolvingType get(BasicTypeID type) { switch (type) { case VOID: case NULL: @@ -600,9 +601,7 @@ private static void comparator(MemberSet.Builder builder) { new MethodInstance(getComparator((BasicTypeID) typeID)), type); return new CastedExpression(CastedExpression.Level.EXACT, value); - }).orElseGet(() -> { - return new CastedExpression(CastedExpression.Level.INVALID, compiler.at(position).invalid(CompileErrors.cannotCompare(left.type, rightCompiled.type))); - }); + }).orElseGet(() -> new CastedExpression(CastedExpression.Level.INVALID, compiler.at(position).invalid(CompileErrors.cannotCompare(left.type, rightCompiled.type)))); })); } diff --git a/JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/JavaMangler.java b/JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/JavaMangler.java index f68bbafd9..fe3edbc75 100644 --- a/JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/JavaMangler.java +++ b/JavaBytecodeCompiler/src/main/java/org/openzen/zenscript/javabytecode/JavaMangler.java @@ -171,7 +171,7 @@ private String mangleExpansionTarget(final TypeID target) { return this.oneOf( () -> this.mangleIf(EXP_TAR_MANGLE_ARRAY_ID, target::asArray, it -> Character.toString('D') + it.dimension + 'C' + this.mangleExpansionTarget(it.elementType)), () -> this.mangleIf(EXP_TAR_MANGLE_ASSOC_ID, target::asAssoc, it -> this.mangleKv(this.mangleExpansionTarget(it.keyType), this.mangleExpansionTarget(it.valueType))), - () -> this.mangleIf(EXP_TAR_MANGLE_BASIC_ID, target, BasicTypeID.class, it -> it.name), + () -> this.mangleIf(EXP_TAR_MANGLE_BASIC_ID, target, BasicTypeID.class, BasicTypeID::getName), () -> this.mangleIf(EXP_TAR_MANGLE_DEFINITION_ID, target::asDefinition, it -> { final String name = it.definition.getName(); final int simpleNameBegin = name.lastIndexOf('.');