java.lang.Object
simula.compiler.syntaxClass.SyntaxClass
simula.compiler.syntaxClass.declaration.Declaration
simula.compiler.syntaxClass.declaration.DeclarationScope
simula.compiler.syntaxClass.declaration.BlockDeclaration
simula.compiler.syntaxClass.declaration.ClassDeclaration
- All Implemented Interfaces:
Externalizable
,Serializable
- Direct Known Subclasses:
PrefixedBlockDeclaration
,StandardClass
public sealed class ClassDeclaration
extends BlockDeclaration
implements Externalizable
permits StandardClass, PrefixedBlockDeclaration
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
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionfinal class
Utility: ClassParameterIterator - Iterates through prefix-chain.Nested classes/interfaces inherited from class simula.compiler.syntaxClass.declaration.Declaration
Declaration.Kind
-
Field Summary
Modifier and TypeFieldDescriptionStatement code before inner.Statement code after inner.boolean
Set true when attribute procedure 'detach' is used in/on this class.private String
The external prefix'identifier.The hidden list.The parameter list.Class Prefix in case of a SubClass or Prefixed Block.(package private) Vector
<ProtectedSpecification> The protected list.protected Vector
<VirtualMatch> The virtual match list.protected Vector
<VirtualSpecification> The virtual spec list.Fields inherited from class simula.compiler.syntaxClass.declaration.BlockDeclaration
isContextFree, isMainModule, isPreCompiled, labelcodeList, lastLineNumber, statements
Fields inherited from class simula.compiler.syntaxClass.declaration.DeclarationScope
ctBlockLevel, currentRTBlockLevel, declarationList, hasLocalClasses, labelList, rtBlockLevel, sourceBlockLevel
Fields inherited from class simula.compiler.syntaxClass.declaration.Declaration
declarationKind, declaredIn, externalIdent, identifier, isProtected, type
Fields inherited from class simula.compiler.syntaxClass.SyntaxClass
lineNumber
-
Constructor Summary
ModifierConstructorDescriptionDefault constructor used by Externalization.protected
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.private void
Perform sematic checking of the Hidden list.private void
Perform sematic checking of the Protected list.protected void
Coding utility: Code class statements.void
Coding utility: Code statementsvoid
Perform semantic checking.private void
Coding Utility: Code the constructor.void
Output Java code.protected String
Coding Utility: Edit the complete parameter list including all prefixes.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 Meaning(package private) int
Returns the number of labels in this class.Returns the prefix ClassDeclaration or null.protected boolean
hasLabel()
Returns true if this block has one ore more labels.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
printTree
(int indent) Utility print syntax tree method.void
readExternal
(ObjectInput inpt) (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'toString()
private static boolean
withinScope
(DeclarationScope otherScope) Checks if the other scope is this scope or any of the prefixes.protected void
Coding utility: writeCode1 -- Write code before innerprotected void
Coding utility: writeCode2 -- Write code after innervoid
writeExternal
(ObjectOutput oupt) Methods inherited from class simula.compiler.syntaxClass.declaration.BlockDeclaration
addLeadingLabel, codeSTMBody, doCheckLabelList, expectFormalParameterPart, isBlockWithLocalClasses, isQPSystemBlock, printStatementList
Methods inherited from class simula.compiler.syntaxClass.declaration.DeclarationScope
edCTX, edCTX, edJavaClassName, edScopeChain, findLabelMeaning, findMeaning, findProcedure, printDeclarationList, scopeID
Methods inherited from class simula.compiler.syntaxClass.declaration.Declaration
getJavaIdentifier, isCompatibleClasses, modifyIdentifier, parseDeclaration
Methods inherited from class simula.compiler.syntaxClass.SyntaxClass
ASSERT_SEMANTICS_CHECKED, doDeclarationCoding, edIndent, edTreeIndent, IS_SEMANTICS_CHECKED, SET_SEMANTICS_CHECKED, toJavaCode
-
Field Details
-
externalPrefixIdent
The external prefix'identifier. -
parameterList
The parameter list. -
virtualSpecList
The virtual spec list. -
virtualMatchList
The virtual match list. -
protectedList
Vector<ProtectedSpecification> protectedListThe protected list. -
code1
Statement code before inner. -
code2
Statement code after inner. -
prefix
Class Prefix in case of a SubClass or Prefixed Block. -
detachUsed
public boolean detachUsedSet true when attribute procedure 'detach' is used in/on this class.
-
-
Constructor Details
-
ClassDeclaration
Create a new ClassDeclaration.- Parameters:
identifier
- the given identifier
-
ClassDeclaration
public ClassDeclaration()Default constructor used by Externalization.
-
-
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
Parse utility: Accept value part and set matching parameter's mode.Syntax: VALUE identifier-list ;
- Parameters:
pList
- Parameter list
-
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.- Returns:
- the prefix level
-
getNlabels
int getNlabels()Returns the number of labels in this class.- Returns:
- the number of labels in this class
-
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
Find Remote Attribute's Meaning.- Parameters:
ident
- attribute identifier- Returns:
- the resulting Meaning
-
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
-
hasNoRealPrefix
private boolean hasNoRealPrefix()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
Iterates through all class parameters.- Returns:
- a ClassParameterIterator
-
doJavaCoding
public void doJavaCoding()Description copied from class:SyntaxClass
Output Java code.- Overrides:
doJavaCoding
in classSyntaxClass
-
doCodeConstructor
private void doCodeConstructor()Coding Utility: Code the constructor. -
edFormalParameterList
Edit the formal parameter listAlso used by subclass PrefixedBlockDeclaration.
- Returns:
- the resulting Java code
-
hasLabel
protected boolean hasLabel()Description copied from class:BlockDeclaration
Returns true if this block has one ore more labels.- Overrides:
hasLabel
in classBlockDeclaration
- Returns:
- true if this block has one ore more labels.
-
codeStatements
public void codeStatements()Description copied from class:BlockDeclaration
Coding utility: Code statements- Overrides:
codeStatements
in classBlockDeclaration
-
writeCode1
protected void writeCode1()Coding utility: writeCode1 -- Write code before inner -
writeCode2
protected void writeCode2()Coding utility: writeCode2 -- Write code after inner -
codeClassStatements
protected void codeClassStatements()Coding utility: Code class statements. -
edCompleteParameterList
Coding Utility: Edit the complete parameter list including all prefixes.- Returns:
- the resulting Java code
-
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
public void printTree(int indent) Description copied from class:SyntaxClass
Utility print syntax tree method.- Overrides:
printTree
in classSyntaxClass
- Parameters:
indent
- number of spaces leading the lines
-
toString
- Overrides:
toString
in classBlockDeclaration
-
writeExternal
- Specified by:
writeExternal
in interfaceExternalizable
- Throws:
IOException
-
readExternal
- Specified by:
readExternal
in interfaceExternalizable
- Throws:
IOException
ClassNotFoundException
-