slcom/slangc/api/TypeOption.sauce

94 lines
2.1 KiB
Plaintext
Raw Normal View History

package slangc.api;
import slangc.bytecode.TypeSignature;
public class TypeOption {
/** Note the first 16 must match up to BytecodeInstructionWriter.StackType. */
public static enum Kind {
/* #0-#3 are used for special types (these are not valid in all scenarios). */
UNINITIALISED,
INVALID,
DUCK,
VOID,
/* #4 is the object type. */
OBJECT,
/* #5-#7 are the basic non-integer primitives. */
BIT,
FLOAT32,
FLOAT64,
/* #8-#15 are the basic integer primitives. */
INT8,
INT16,
INT32,
INT64,
UINT8,
UINT16,
UINT32,
UINT64,
/* #16-#31 are the other standard runtime types. */
MAGIC,
TYPE,
STRING,
ENUMBASE,
ARRAYBASE,
INSTANCECONSTRUCTOR,
STATICCONSTRUCTOR,
INSTANCEFIELD,
INSTANCEMETHOD,
STATICFIELD,
STATICMETHOD,
INTERFACEMETHOD,
BYTECODEFILE,
LOADER,
THREAD,
DEVICEHANDLE
}
public final Kind kind;
public final String typeName;
public final String formatopt;
public final boolean isBuiltin;
public final boolean isDuck;
public final boolean isNumber;
public final boolean isFloat;
public final boolean isSigned;
public final int nbits;
public TypeSignature getTypeSignature() {
if (kind == Kind.VOID) {
return TypeSignature.VOID;
} else {
return new TypeSignature(CompilerWorld.pkgname(typeName), CompilerWorld.typname(typeName));
}
}
public TypeOption(Kind kind, String value, String formatopt) {
super();
this.kind = kind;
this.typeName = value;
this.formatopt = formatopt;
this.isBuiltin = false;
this.isDuck = false;
this.isNumber = false;
this.isFloat = false;
this.isSigned = false;
this.nbits = -1;
}
public TypeOption(Kind kind, String value, String formatopt, boolean isBuiltin, boolean isDuck, boolean isNumber, boolean isFloat, boolean isSigned, int nbits) {
this.kind = kind;
this.typeName = value;
this.formatopt = formatopt;
this.isBuiltin = isBuiltin;
this.isDuck = isDuck;
this.isNumber = isNumber;
this.isFloat = isFloat;
this.isSigned = isSigned;
this.nbits = -1;
}
}