Class Type
java.lang.Object
simula.compiler.syntaxClass.SyntaxClass
simula.compiler.syntaxClass.Type
- Direct Known Subclasses:
OverLoad
Utility class Type.
Syntax: type = value-type | reference-type value-type = arithmetic-type | boolean | character arithmetic-type = integer-type | real-type integer-type = [ short ] integer real-type = [ long ] real reference-type = object-reference-type | text object-reference-type = ref "(" qualification ")" qualification = class-identifier
Link to GitHub: Source File.
- Author:
- Øystein Myhre Andersen
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Type
Simula's Boolean typestatic final Type
Simula's Character typeThe Class Identifier in case of ref(classIdent)Qual's scope in case of ref(Qual) type.static final Type
Simula's Integer typeint
The keyWord attributestatic final Type
Simula's Label typestatic final Type
Simula's Long Real typestatic final Type
Simula's Procedure typeprotected ClassDeclaration
Qual in case of ref(Qual) type.static final Type
Simula's Real typestatic final Type
Simula's Ref() typestatic final int
Simula's Boolean typestatic final int
Simula's Character typestatic final int
Simula's Integer typestatic final int
Simula's Label typestatic final int
Simula's Long Real typestatic final int
Simula's Procedure typestatic final int
Simula's Real typestatic final int
Simula's Ref() typestatic final int
Simula's Text typestatic final int
Simula's No typestatic final Type
Simula's Text typestatic final Type
Simula's Undefined typeFields inherited from class simula.compiler.syntaxClass.SyntaxClass
CHECKED, lineNumber, OBJECT_SEQU
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
Type
(int keyWord) Create a new simple Type with the given keyWordCreate a new simple Type with the given keyWord and classIdentCreate a new ref(classIdent) type.Type
(Type tp, ConnectionBlock declaredIn) Create a new Type based on the given Type and ConnectionBlock. -
Method Summary
Modifier and TypeMethodDescriptionstatic Type
arithmeticTypeConversion
(Type type1, Type type2) Returns the most dominant type.void
buildObjectValueOf
(CodeBuilder codeBuilder) ClassFile coding utility: buildObjectValueOfvoid
checkCast
(CodeBuilder codeBuilder) ClassFile coding utility: code instruction checkcast acording to type.static Type
commonRefType
(Type type1, Type type2) Returns the type to which both types can be converted.static Type
commonTypeConversion
(Type type1, Type type2) Returns the type to which both types can be converted.void
doChecking
(DeclarationScope scope) Perform semantic checking in the given scope.void
dup
(CodeBuilder codeBuilder) ClassFile coding utility: code instruction dup acording to type.void
dup_x1
(CodeBuilder codeBuilder) ClassFile coding utility: code instruction dup_x1 acording to type.Returns an edited default value of this Type.boolean
static boolean
equalsOrSubordinate
(Type t1, Type t2) Check if types are equals or subordinate.Return RTS Array type String.Returns the Java ref-identifier or null.getQual()
Returns the qualifying ClassDeclaration or null.Returns the ref-identifier or null.boolean
Returns true if this type is an arithmetic type.isConvertableTo
(Type to) Checks if a type-conversion is legal.boolean
Returns true if this type is ref type.boolean
Returns true if this type is ref or text type.boolean
isSubReferenceOf
(Type other) Utility method isSubReferenceOf.boolean
Returns true if this type is a value type.void
pop
(CodeBuilder codeBuilder) ClassFile coding utility: code instruction pop acording to type.static final Type
Simula's Ref(classIdent) typeClassFile coding utility: toArrayClassSignature.ClassFile coding utility: toClassDesc.toClassDesc
(int kind, int mode) ClassFile coding utility: toClassDesc.toClassDesc
(Declaration declaredIn) ClassFile coding utility: toClassDesc.ClassFile coding utility: toJavaType.ClassFile coding utility: toJavaTypeClass.ClassFile coding utility: toJavaArrayType.static String
toJVMClassType
(Type type, int kind) ClassFile coding utility: toJVMType.ClassFile coding utility: toJVMType.toJVMType
(int kind, int mode) ClassFile coding utility: toJVMType.ClassFile coding utility: toNameClassSignature.ClassFile coding utility: toClassDesc.toString()
void
valueToPrimitiveType
(CodeBuilder codeBuilder) Convert JVM Object value to primitive type value.Methods inherited from class simula.compiler.syntaxClass.SyntaxClass
ASSERT_SEMANTICS_CHECKED, buildByteCode, doChecking, doDeclarationCoding, doJavaCoding, edIndent, edTreeIndent, IS_SEMANTICS_CHECKED, print, printTree, readObject, SET_SEMANTICS_CHECKED, setLineNumber, toJavaCode, writeObject
-
Field Details
-
keyWord
public int keyWordThe keyWord attribute -
classIdent
The Class Identifier in case of ref(classIdent) -
qual
Qual in case of ref(Qual) type. Set by doChecking -
declaredIn
Qual's scope in case of ref(Qual) type. Set by doChecking -
T_UNDEF
public static final int T_UNDEFSimula's No type- See Also:
-
T_INTEGER
public static final int T_INTEGERSimula's Integer type- See Also:
-
T_REAL
public static final int T_REALSimula's Real type- See Also:
-
T_LONG_REAL
public static final int T_LONG_REALSimula's Long Real type- See Also:
-
T_BOOLEAN
public static final int T_BOOLEANSimula's Boolean type- See Also:
-
T_CHARACTER
public static final int T_CHARACTERSimula's Character type- See Also:
-
T_TEXT
public static final int T_TEXTSimula's Text type- See Also:
-
T_REF
public static final int T_REFSimula's Ref() type- See Also:
-
T_PROCEDURE
public static final int T_PROCEDURESimula's Procedure type- See Also:
-
T_LABEL
public static final int T_LABELSimula's Label type- See Also:
-
Undef
Simula's Undefined type -
Integer
Simula's Integer type -
Real
Simula's Real type -
LongReal
Simula's Long Real type -
Boolean
Simula's Boolean type -
Character
Simula's Character type -
Text
Simula's Text type -
Ref
Simula's Ref() type -
Procedure
Simula's Procedure type -
Label
Simula's Label type
-
-
Constructor Details
-
Type
private Type(int keyWord) Create a new simple Type with the given keyWord- Parameters:
keyWord
- the given keyWord
-
Type
Create a new simple Type with the given keyWord and classIdent- Parameters:
keyWord
- the given keyWordclassIdent
- the given class identifier
-
Type
Create a new ref(classIdent) type.- Parameters:
classIdent
- the class name
-
Type
Create a new Type based on the given Type and ConnectionBlock.- Parameters:
tp
- the given TypedeclaredIn
- the ConnectionBlock
-
-
Method Details
-
Ref
-
getQual
Returns the qualifying ClassDeclaration or null.- Returns:
- the qualifying ClassDeclaration or null
-
equalsOrSubordinate
-
equals
-
getRefIdent
-
getJavaRefIdent
Returns the Java ref-identifier or null.- Returns:
- the Java ref-identifier or null
-
doChecking
Perform semantic checking in the given scope.- Parameters:
scope
- the given scope
-
isArithmeticType
public boolean isArithmeticType()Returns true if this type is an arithmetic type. Integer, real or long real.- Returns:
- true if this type is an arithmetic type.
-
isValueType
public boolean isValueType()Returns true if this type is a value type. Integer, real or long real.- Returns:
- true if this type is a value type.
-
isReferenceType
public boolean isReferenceType()Returns true if this type is ref or text type.- Returns:
- true if this type is ref or text type
-
isRefClassType
public boolean isRefClassType()Returns true if this type is ref type.- Returns:
- true if this type is ref type
-
isConvertableTo
Checks if a type-conversion is legal.
The possible return values are:
- DirectAssignable - No type-conversion is necessary. E.g. integer to integer
- ConvertValue - Type-conversion with possible Runtime check is necessary. E.g. real to integer.
- ConvertRef - Type-conversion with Runtime check is necessary. E.g. ref(A) to ref(B) where B is a subclass of A.
- Illegal - Conversion is illegal
- Parameters:
to
- the to type-- Returns:
- the resulting ConversionKind
-
isSubReferenceOf
Utility method isSubReferenceOf.
ref(B) is a sub-reference of ref(A) iff B is a subclass of A.
Any ref is a sub-reference of NONE
- Parameters:
other
- the other type- Returns:
- true if the condition holds
-
commonRefType
-
commonTypeConversion
-
arithmeticTypeConversion
-
edDefaultValue
Returns an edited default value of this Type.- Returns:
- an edited default value of this Type
-
toJavaType
ClassFile coding utility: toJavaType.- Returns:
- the resulting code string.
-
toJavaTypeClass
ClassFile coding utility: toJavaTypeClass.- Returns:
- the resulting code string.
-
toJavaArrayType
ClassFile coding utility: toJavaArrayType.- Returns:
- the resulting code string.
-
getArrayType
-
toJVMType
ClassFile coding utility: toJVMType.- Parameters:
kind
- kind code.mode
- mode code.- Returns:
- the resulting code string.
-
toJVMType
-
toJVMClassType
-
toClassDesc
ClassFile coding utility: toClassDesc.- Parameters:
declaredIn
- the owner.- Returns:
- the resulting Class Descriptor.
-
toClassDesc
ClassFile coding utility: toClassDesc.- Returns:
- the resulting Class Descriptor.
-
toClassDesc
ClassFile coding utility: toClassDesc.- Parameters:
kind
- a kind codemode
- a mode code- Returns:
- the resulting Class Descriptor.
-
toObjectClassDesc
ClassFile coding utility: toClassDesc.- Returns:
- the resulting Class Descriptor.
-
toNameClassSignature
ClassFile coding utility: toNameClassSignature.- Returns:
- the resulting Class Signature.
-
toArrayClassSignature
ClassFile coding utility: toArrayClassSignature.- Returns:
- the resulting Array Class Signature.
-
dup
ClassFile coding utility: code instruction dup acording to type.- Parameters:
codeBuilder
- the codeBuilder
-
dup_x1
ClassFile coding utility: code instruction dup_x1 acording to type.- Parameters:
codeBuilder
- the codeBuilder
-
pop
ClassFile coding utility: code instruction pop acording to type.- Parameters:
codeBuilder
- the codeBuilder
-
checkCast
ClassFile coding utility: code instruction checkcast acording to type.- Parameters:
codeBuilder
- the codeBuilder
-
valueToPrimitiveType
Convert JVM Object value to primitive type value.- Parameters:
codeBuilder
- the CodeBuilder to use
-
buildObjectValueOf
ClassFile coding utility: buildObjectValueOf- Parameters:
codeBuilder
- the CodeBuilder to use
-
toString
-