java.lang.Object
simula.compiler.syntaxClass.SyntaxClass
simula.compiler.syntaxClass.Type
- All Implemented Interfaces:
Externalizable
,Serializable
- 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-identifierLink to GitHub: Source File.
- Author:
- Øystein Myhre Andersen
- See Also:
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Type
Simula's Boolean typestatic final Type
Simula's Character typeQual's scope in case of ref(Qual) type.static final Type
Simula's Integer type(package private) Token
KeyWord or ref(classIdentifier)static 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 Type
Simula's Text typeFields inherited from class simula.compiler.syntaxClass.SyntaxClass
lineNumber
-
Constructor Summary
ConstructorDescriptionType()
Default constructor used by Externalization.Create a new ref(className) type.Type
(Type tp, ConnectionBlock declaredIn) Create a new Type based on the given Type and ConnectionBlock.Create a new simple Type with the given key Token -
Method Summary
Modifier and TypeMethodDescriptionstatic Type
arithmeticTypeConversion
(Type type1, Type type2) Returns the most dominant 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.Returns an edited default value of this Type.boolean
Returns the Java ref-identifier or null.Returns the keyWord or the ref-identifier.getQual()
Returns the qualifying ClassDeclaration or null.Returns the ref-identifier or null.static Type
inType
(ObjectInput inpt) Read a type from an ObjectInput file.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
isSubReferenceOf
(Type other) Utility method isSubReferenceOf.void
readExternal
(ObjectInput inpt) static final Type
Simula's Ref(className) typeCodeing utility: toJavaType.Codeing utility: toJavaTypeClass.Codeing utility: toJavaArrayType.toString()
void
writeExternal
(ObjectOutput oupt) Methods inherited from class simula.compiler.syntaxClass.SyntaxClass
ASSERT_SEMANTICS_CHECKED, doChecking, doDeclarationCoding, doJavaCoding, edIndent, edTreeIndent, IS_SEMANTICS_CHECKED, print, printTree, SET_SEMANTICS_CHECKED, toJavaCode
-
Field Details
-
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 -
qual
Qual in case of ref(Qual) type. Set by doChecking -
declaredIn
Qual's scope in case of ref(Qual) type. Set by doChecking -
key
Token keyKeyWord or ref(classIdentifier)
-
-
Constructor Details
-
Type
public Type()Default constructor used by Externalization. -
Type
Create a new simple Type with the given key Token- Parameters:
key
- the given key Token
-
Type
Create a new ref(className) type.- Parameters:
className
- 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
Simula's Ref(className) type- Parameters:
className
- the class name- Returns:
- a new ref(className) type.
-
getQual
Returns the qualifying ClassDeclaration or null.- Returns:
- the qualifying ClassDeclaration or null
-
getKeyWord
Returns the keyWord or the ref-identifier.- Returns:
- the keyWord or the ref-identifier
-
getRefIdent
Returns the ref-identifier or null.- Returns:
- the ref-identifier or null
-
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.
-
isReferenceType
public boolean isReferenceType()Returns true if this type is ref() type.- Returns:
- true if this type is ref() type
-
equals
-
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
Returns the type to which both types can be converted.- Parameters:
type1
- argumenttype2
- argument- Returns:
- the resulting Type
-
commonTypeConversion
Returns the type to which both types can be converted.- Parameters:
type1
- argumenttype2
- argument- Returns:
- the resulting Type
-
arithmeticTypeConversion
Returns the most dominant type.- Parameters:
type1
- argumenttype2
- argument- Returns:
- the most dominant type
-
edDefaultValue
Returns an edited default value of this Type.- Returns:
- an edited default value of this Type
-
toJavaType
Codeing utility: toJavaType.- Returns:
- the resulting code string.
-
toJavaTypeClass
Codeing utility: toJavaTypeClass.- Returns:
- the resulting code string.
-
toJavaArrayType
Codeing utility: toJavaArrayType.- Returns:
- the resulting code string.
-
toString
-
inType
Read a type from an ObjectInput file.- Parameters:
inpt
- the ObjectInput- Returns:
- the resulting Type
- Throws:
IOException
- if an IOException occurClassNotFoundException
- if the operation failed
-
writeExternal
- Specified by:
writeExternal
in interfaceExternalizable
- Throws:
IOException
-
readExternal
- Specified by:
readExternal
in interfaceExternalizable
- Throws:
IOException
ClassNotFoundException
-