Class ClassDeclaration
- Direct Known Subclasses:
PrefixedBlockDeclaration, StandardClass
Simula Class Declaration.
Simula Standard: 5.5 Class declaration class-declaration = [ prefix ] main-part prefix = class-identifier main-part = CLASS class-identifier [ formal-parameter-part ; [ value-part ] specification-part ] ; [ protection-part ; ] [ virtual-part ; ] class-body class-identifier = identifier formal-parameter-part = "(" FormalParameter { , FormalParameter } ")" FormalParameter = identifier value-part = VALUE identifier-list specification-part = class-parameter-specifier identifier-list ; { class-parameter-specifier identifier-list ; } class-parameter-specifier = Type | [Type] ARRAY protection-part = protection-specification { ; protection-specification } protection-specification = HIDDEN identifier-list | HIDDEN PROTECTED identifier-list | PROTECTED identifier-list | PROTECTED HIDDEN identifier-list virtual-part = VIRTUAL: virtual-spec ; { virtual-spec ; } virtual-spec = virtual-specifier identifier-list | PROCEDURE procedure-identifier procedure-specification virtual-Specifier = [ type ] PROCEDURE | LABEL | SWITCH procedure-specification = IS procedure-declaration class-body = statement | split-body split-body = initial-operations inner-part final-operations initial-operations = ( BEGIN | block-head ; ) { statement ; } inner-part = [ label : ] INNER ; final-operations = END | ; statement { ; statement } END
This class is prefix to StandardClass and PrefixedBlockDeclaration.
Link to GitHub: Source File.
- Author:
- SIMULA Standards Group, Øystein Myhre Andersen
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionfinal class
Utility: ClassParameterIterator - Iterates through prefix-chain. -
Field Summary
FieldsModifier and TypeFieldDescriptionboolean
Set true when attribute procedure 'detach' is used in/on this class.The hidden list.private boolean
Indicates if this class is loaded.(package private) ObjectList
<Parameter> The parameter list.Class Prefix in case of a SubClass or Prefixed Block.Class Prefix in case of a SubClass or Prefixed Block.(package private) ObjectList
<ProtectedSpecification> The protected list.Possible statements before inner.protected Vector
<VirtualMatch> The virtual match list.protected ObjectList
<VirtualSpecification> The virtual spec list.Fields inherited from class BlockDeclaration
currentBlock, isContextFree, isMainModule, labelcodeList, labelContext, labelContextStack, lastLineNumber, nLocalVariables, prevBlock, statements
Fields inherited from class DeclarationScope
CLASSFILE_ALREADY_GENERATED, declarationList, hasLocalClasses, isPreCompiledFromFile, labelList, sourceBlockLevel, sourceFileName
Fields inherited from class Declaration
declarationKind, declaredIn, externalIdent, identifier, isProtected, type
Fields inherited from class SyntaxClass
CHECKED, lineNumber, OBJECT_SEQU
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
ClassDeclaration
(String identifier) Create a new ClassDeclaration. -
Method Summary
Modifier and TypeMethodDescriptionprivate static void
Parse Utility: Accept Class Parameter specification-part updating Parameter's type and kind.private static void
Parse Utility: Accept protection-part updating Hidden and Protected lists.private static void
acceptValuePart
(Vector<Parameter> pList) Parse utility: Accept value part and set matching parameter's mode.protected void
build_STM_BODY
(CodeBuilder codeBuilder, Label begScope, Label endScope) Generate byteCode for the '_STM' method.protected void
Defined in DeclarationScope - Redefined in ClassDeclarationbyte[]
Build Class Fileprotected void
buildConstructor
(CodeBuilder codeBuilder) Generate byteCode for the Constructor.void
buildDeclaration
(ClassBuilder classBuilder, BlockDeclaration encloser) Output Java ByteCode.void
buildInitAttribute
(CodeBuilder codeBuilder) Output Java ByteCode.private void
buildMethod_CatchingErrors_TRY_CATCH
(CodeBuilder codeBuilder, Label begScope, Label endScope) Generate byteCode for the 'CatchingErrors_TRY_CATCH' method.private void
buildStatementsAfterInner
(CodeBuilder codeBuilder) ClassFile coding utility: buildStatementsAfterInnerprivate void
buildStatementsBeforeInner
(CodeBuilder codeBuilder) ClassFile coding utility: buildStatementsBeforeInnerprivate void
Perform sematic checking of the Hidden list.private void
Perform sematic checking of the Protected list.private void
Clear the LabelList.protected void
Java coding utility: Code class statements.void
ClassFile coding utility: Code statementsprivate void
Java coding utility: codeStatementsAfterInnerprivate void
Java coding utility: codeStatementsBeforeInnervoid
Perform semantic checking.private void
Java Coding Utility: Code the constructor.void
Output Java code.protected String
Coding Utility: Edit the complete parameter list including all prefixes.Edit the constructor signature.protected String
Edit the formal parameter listprivate static void
Parse Utility: Expect class-body.static ClassDeclaration
expectClassDeclaration
(String prefix) Parse Class Declaration.private static void
expectHiddenProtectedList
(ClassDeclaration cls, boolean hidden, boolean prtected) Parse Utility: Expect Hidden Protected list.findLocalAttribute
(String ident) Utility: Search for an attribute named 'ident'(package private) ProcedureDeclaration
findLocalProcedure
(String ident) Utility: Search Declaration-list for a procedure named 'ident'findRemoteAttributeMeaning
(String ident) Find Remote Attribute's Meaning.Find visible attribute's MeaningReturns the prefix ClassDeclaration or null.(package private) boolean
Check if this class has a real prefix.boolean
Returns true if detach is called in/on this class.boolean
isSubClassOf
(ClassDeclaration other) Checks if this class is a subclass of the 'other' class.Iterates through all class parameters.int
Returns the prefix level.void
print
(int indent) Utility print method.void
Utility print syntax tree method.static ClassDeclaration
Read and return a ClassDeclaration object.(package private) HiddenSpecification
searchHiddenList
(String ident) Utility: Search Hidden-list for 'ident'searchProtectedList
(String ident) Utility: Search Protected-list for 'ident'searchVirtualSpecList
(String ident) Utility: Search VirtualSpec-list for 'ident'Get super class ClassDesc.toString()
private byte[]
tryBuildClassFile
(ClassDesc CD_ThisClass, ClassDesc CD_SuperClass) Try to build classFile for this ClassDeclarationprivate static boolean
withinScope
(DeclarationScope otherScope) Checks if the other scope is this scope or any of the prefixes.void
Write a SyntaxClass object to a AttributeOutputStream.Methods inherited from class BlockDeclaration
addLeadingLabel, allocateLocalVariable, build_TRY_CATCH, buildIsMethodDetachUsed, buildIsQPSystemBlock, buildMethod_STM, buildMethodMain, codeMethodMain, codeSTMBody, currentClassDesc, expectFormalParameterPart, getConstructorMethodTypeDesc, hasAccumLabel, hasDeclaredLabel, isBlockWithLocalClasses, isQPSystemBlock, nearestEnclosingBlock, printStatementList
Methods inherited from class DeclarationScope
buildCTX, buildCTX, buildCTX2, createJavaClassFile, doBuildClassFile, edCTX, edCTX, edJavaClassName, edScope, edScopeChain, findLabelMeaning, findMeaning, findProcedure, getBytesFromFile, getClassDesc, getRTBlockLevel, loadOrAddClassFile, modifyIdentifier, prep, printDeclarationList, printStaticChain, scopeID
Methods inherited from class Declaration
acceptDeclaration, buildDeclarationCode, checkAlreadyDefined, getFieldIdentifier, getJavaIdentifier, isCompatibleClasses, verifyTree
Methods inherited from class SyntaxClass
ASSERT_SEMANTICS_CHECKED, buildByteCode, doDeclarationCoding, edIndent, edTreeIndent, IS_SEMANTICS_CHECKED, SET_SEMANTICS_CHECKED, setLineNumber, toJavaCode
-
Field Details
-
parameterList
ObjectList<Parameter> parameterListThe parameter list. -
virtualSpecList
The virtual spec list. -
virtualMatchList
The virtual match list. -
protectedList
ObjectList<ProtectedSpecification> protectedListThe protected list. -
statements1
Possible statements before inner. If this is non-null then 'statements' contains the statements after inner -
prefix
Class Prefix in case of a SubClass or Prefixed Block. -
prefixClass
Class Prefix in case of a SubClass or Prefixed Block. Set by coChecking -
detachUsed
public boolean detachUsedSet true when attribute procedure 'detach' is used in/on this class. -
isLoaded
private boolean isLoadedIndicates if this class is loaded.
-
-
Constructor Details
-
ClassDeclaration
Create a new ClassDeclaration.- Parameters:
identifier
- the given identifier
-
-
Method Details
-
expectClassDeclaration
Parse Class Declaration.
Syntax: class-declaration = [ prefix ] main-part prefix = class-identifier main-part = CLASS class-identifier [ formal-parameter-part ; [ value-part ] specification-part ] ; [ protection-part ; ] [ virtual-part ; ] class-body
- Parameters:
prefix
- class identifier- Returns:
- the resulting ClassDeclaration
-
acceptValuePart
-
acceptParameterSpecificationPart
Parse Utility: Accept Class Parameter specification-part updating Parameter's type and kind.
Syntax: specification-part = class-parameter-specifier identifier-list { ; class-parameter-specifier identifier-list } class-parameter-specifier = Type | [Type] ARRAY
- Parameters:
pList
- the parameter list
-
acceptProtectionPart
Parse Utility: Accept protection-part updating Hidden and Protected lists.
Syntax: protection-part = protection-specification { ; protection-specification } protection-specification = HIDDEN identifier-list | HIDDEN PROTECTED identifier-list | PROTECTED identifier-list | PROTECTED HIDDEN identifier-list
- Parameters:
cls
- the ClassDeclaration
-
expectHiddenProtectedList
private static void expectHiddenProtectedList(ClassDeclaration cls, boolean hidden, boolean prtected) Parse Utility: Expect Hidden Protected list.
Syntax: identifier-list
- Parameters:
cls
- the ClassDeclarationhidden
- if true, update the hidden listprtected
- if true, update the protected list
-
expectClassBody
Parse Utility: Expect class-body. In case of a split-body, updating the class's declaration and statement lists.
Syntax: class-body = statement | split-body split-body = initial-operations inner-part final-operations initial-operations = ( BEGIN | block-head ; ) { statement ; } inner-part = [ label : ] INNER ; final-operations = END | ; statement { ; statement } END
- Parameters:
cls
- the ClassDeclaration
-
isSubClassOf
Checks if this class is a subclass of the 'other' class.
Consider the class definitions:
Class A ......; A Class B ......; B Class C ......;
Then Class B is a subclass of Class A, While Class C is subclass of both B and A.
- Parameters:
other
- the other ClassDeclaration- Returns:
- Boolean true iff this class is a subclass of the 'other' class.
-
doChecking
public void doChecking()Description copied from class:SyntaxClass
Perform semantic checking.
This must be redefined in every subclass.
- Overrides:
doChecking
in classSyntaxClass
-
checkHiddenList
private void checkHiddenList()Perform sematic checking of the Hidden list. -
checkProtectedList
private void checkProtectedList()Perform sematic checking of the Protected list. -
searchVirtualSpecList
Utility: Search VirtualSpec-list for 'ident'- Parameters:
ident
- argument- Returns:
- a VirtualSpecification when it was found, otherwise null
-
prefixLevel
public int prefixLevel()Returns the prefix level.- Overrides:
prefixLevel
in classDeclarationScope
- Returns:
- the prefix level
-
findLocalAttribute
Utility: Search for an attribute named 'ident'- Parameters:
ident
- argument- Returns:
- a ProcedureDeclaration when it was found, otherwise null
-
findLocalProcedure
Utility: Search Declaration-list for a procedure named 'ident'- Parameters:
ident
- argument- Returns:
- a ProcedureDeclaration when it was found, otherwise null
-
findRemoteAttributeMeaning
-
searchProtectedList
Utility: Search Protected-list for 'ident'- Parameters:
ident
- argument- Returns:
- a ProtectedSpecification when it was found, otherwise null
-
withinScope
Checks if the other scope is this scope or any of the prefixes.- Parameters:
otherScope
- the other scope- Returns:
- true if the other scope is this scope or any of the prefixes
-
findVisibleAttributeMeaning
Description copied from class:DeclarationScope
Find visible attribute's Meaning- Overrides:
findVisibleAttributeMeaning
in classDeclarationScope
- Parameters:
ident
- attribute identifier- Returns:
- the resulting Meaning
-
searchHiddenList
Utility: Search Hidden-list for 'ident'- Parameters:
ident
- argument- Returns:
- a HiddenSpecification when it was found, otherwise null
-
getPrefixClass
Returns the prefix ClassDeclaration or null.- Returns:
- the prefix ClassDeclaration or null
-
hasRealPrefix
boolean hasRealPrefix()Check if this class has a real prefix.- Returns:
- true if this class has a real prefix, otherwise false.
-
isDetachUsed
public boolean isDetachUsed()Returns true if detach is called in/on this class.- Returns:
- true if detach is called in/on this class
-
parameterIterator
-
doJavaCoding
public void doJavaCoding()Description copied from class:SyntaxClass
Output Java code.- Overrides:
doJavaCoding
in classSyntaxClass
-
doCodeConstructor
private void doCodeConstructor()Java Coding Utility: Code the constructor. -
edFormalParameterList
Edit the formal parameter list
Also used by subclass PrefixedBlockDeclaration.
- Returns:
- the resulting Java code
-
codeStatements
public void codeStatements()Description copied from class:BlockDeclaration
ClassFile coding utility: Code statements- Overrides:
codeStatements
in classBlockDeclaration
-
codeStatementsBeforeInner
private void codeStatementsBeforeInner()Java coding utility: codeStatementsBeforeInner -
codeStatementsAfterInner
private void codeStatementsAfterInner()Java coding utility: codeStatementsAfterInner -
codeClassStatements
protected void codeClassStatements()Java coding utility: Code class statements. -
edCompleteParameterList
Coding Utility: Edit the complete parameter list including all prefixes.- Returns:
- the resulting Java code
-
superClassDesc
-
buildAndLoadOrAddClassFile
Defined in DeclarationScope - Redefined in ClassDeclaration- Overrides:
buildAndLoadOrAddClassFile
in classDeclarationScope
- Throws:
IOException
- if something went wrong.
-
buildClassFile
public byte[] buildClassFile()Description copied from class:DeclarationScope
Build Class File- Specified by:
buildClassFile
in classDeclarationScope
- Returns:
- Class File bytes
-
tryBuildClassFile
-
edConstructorSignature
Edit the constructor signature.
Example: (Lsimula/runtime/RTS_RTObject;IID)V
Also used by PrefixedBlockDeclaration.
- Overrides:
edConstructorSignature
in classBlockDeclaration
- Returns:
- the MethodTypeDesc for the constructor
-
buildConstructor
Generate byteCode for the Constructor.
public Program'name(RTS_RTObject staticLink, par, par ...) { super(staticLink); // Parameter assignment to locals BBLK(); // Declaration Code _STM(); }
Also used by PrefixedBlockDeclaration
- Parameters:
codeBuilder
- the CodeBuilder
-
buildDeclaration
Description copied from class:Declaration
Output Java ByteCode. Treat Declaration.- Overrides:
buildDeclaration
in classDeclaration
- Parameters:
classBuilder
- the classBuilder to use.encloser
- the owning block.
-
buildInitAttribute
Description copied from class:Declaration
Output Java ByteCode. Build init code for an Attribute.- Overrides:
buildInitAttribute
in classDeclaration
- Parameters:
codeBuilder
- the codeBuilder to use.
-
build_STM_BODY
Generate byteCode for the '_STM' method.- Overrides:
build_STM_BODY
in classBlockDeclaration
- Parameters:
codeBuilder
- the CodeBuilderbegScope
- labelendScope
- label
-
clearLabelList
private void clearLabelList()Clear the LabelList. -
buildMethod_CatchingErrors_TRY_CATCH
private void buildMethod_CatchingErrors_TRY_CATCH(CodeBuilder codeBuilder, Label begScope, Label endScope) Generate byteCode for the 'CatchingErrors_TRY_CATCH' method.- Parameters:
codeBuilder
- the CodeBuilderbegScope
- labelendScope
- label
-
buildStatementsBeforeInner
ClassFile coding utility: buildStatementsBeforeInner- Parameters:
codeBuilder
- the codeBuilder to use.
-
buildStatementsAfterInner
ClassFile coding utility: buildStatementsAfterInner- Parameters:
codeBuilder
- the codeBuilder to use.
-
print
public void print(int indent) Description copied from class:SyntaxClass
Utility print method.- Overrides:
print
in classSyntaxClass
- Parameters:
indent
- number of spaces leading the line
-
printTree
Description copied from class:SyntaxClass
Utility print syntax tree method.- Overrides:
printTree
in classSyntaxClass
- Parameters:
indent
- number of spaces leading the lineshead
- the head of the tree.
-
toString
- Overrides:
toString
in classBlockDeclaration
-
writeObject
Description copied from class:SyntaxClass
Write a SyntaxClass object to a AttributeOutputStream.- Overrides:
writeObject
in classSyntaxClass
- Parameters:
oupt
- the AttributeOutputStream to write to.- Throws:
IOException
- if something went wrong.
-
readObject
Read and return a ClassDeclaration object.- Parameters:
inpt
- the AttributeInputStream to read from- Returns:
- the object read from the stream.
- Throws:
IOException
- if something went wrong.
-