Class MaybeBlockDeclaration
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.MaybeBlockDeclaration
Maybe Block Declaration. I.e: CompoundStatement or SubBlock depends on whether it contains declarations.
Simula Standard: 4.9 Compound statement Simula Standard: 4.9 Blocks MaybeBlockDeclaration = compound-statement | subblock compound-statement = BEGIN [ { statement ; } ] END subblock = BEGIN [ { declaration ; } ] [ { statement ; } ] END
Link to GitHub: Source File.
- Author:
- SIMULA Standards Group, Øystein Myhre Andersen
-
Field Summary
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
ConstructorsConstructorDescriptionDefault constructor used by Attribute File I/OMaybeBlockDeclaration
(String identifier) Create a new MaybeBlockDeclaration, i.e. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
build_STM_BODY
(CodeBuilder codeBuilder, Label begScope, Label endScope) ClassFile coding utility: Build byteCode for the '_STM' method.private void
build_STMS
(CodeBuilder codeBuilder) ClassFile coding utility: Build the statements.void
buildByteCode
(CodeBuilder codeBuilder) Build Java ClassFile ByteCode.byte[]
Build Class Fileprivate void
buildConstructor
(CodeBuilder codeBuilder) Generate byteCode for the Constructor.static MaybeBlockDeclaration
Create the main program block.void
Perform semantic checking.private void
Java Coding utility: Code constructorprivate void
Java Coding utility: Code statementsprivate void
Java Coding utility: Code compound statementvoid
Output Java code.private void
Java Coding utility: Code sub-blockEdit the ConstructorSignature.expectMaybeBlock
(int line) Parse CompoundStatement or SubBlock.Find visible attribute's MeaningReturn the ClassDescint
Utility: Get Runtime BlockLevel.(package private) static void
moveLabelsFrom
(DeclarationScope block) Utility: Moves labels from the givent block.void
print
(int indent) Utility print method.void
Utility print syntax tree method.static MaybeBlockDeclaration
readObject
(AttributeInputStream inpt, int declarationKind) Read and return a MaybeBlockDeclaration object.toString()
void
Write a SyntaxClass object to a AttributeOutputStream.Methods inherited from class BlockDeclaration
addLeadingLabel, allocateLocalVariable, build_TRY_CATCH, buildIsMethodDetachUsed, buildIsQPSystemBlock, buildMethod_STM, buildMethodMain, codeMethodMain, codeStatements, codeSTMBody, currentClassDesc, expectFormalParameterPart, getConstructorMethodTypeDesc, hasAccumLabel, hasDeclaredLabel, isBlockWithLocalClasses, isQPSystemBlock, nearestEnclosingBlock, printStatementList
Methods inherited from class DeclarationScope
buildAndLoadOrAddClassFile, buildCTX, buildCTX, buildCTX2, createJavaClassFile, doBuildClassFile, edCTX, edCTX, edJavaClassName, edScope, edScopeChain, findLabelMeaning, findMeaning, findProcedure, getBytesFromFile, loadOrAddClassFile, modifyIdentifier, prefixLevel, prep, printDeclarationList, printStaticChain, scopeID
Methods inherited from class Declaration
acceptDeclaration, buildDeclaration, buildDeclarationCode, buildInitAttribute, checkAlreadyDefined, getFieldIdentifier, getJavaIdentifier, isCompatibleClasses, verifyTree
Methods inherited from class SyntaxClass
ASSERT_SEMANTICS_CHECKED, doDeclarationCoding, edIndent, edTreeIndent, IS_SEMANTICS_CHECKED, readObject, SET_SEMANTICS_CHECKED, setLineNumber, toJavaCode
-
Constructor Details
-
MaybeBlockDeclaration
Create a new MaybeBlockDeclaration, i.e. CompoundStatement or SubBlock.- Parameters:
identifier
- block identifier
-
MaybeBlockDeclaration
public MaybeBlockDeclaration()Default constructor used by Attribute File I/O
-
-
Method Details
-
createMainProgramBlock
Create the main program block. Used by ProgramModule.- Returns:
- the main program block
-
expectMaybeBlock
Parse CompoundStatement or SubBlock.
Syntax: Block = CompoundStatement | SubBlock CompoundStatement = BEGIN [ { Statement ; } ] END SubBlock = BEGIN [ { Declaration ; } ] [ { Statement ; } ] END
Pre-condition: BEGIN is already read.
- Parameters:
line
- source line number- Returns:
- a BlockStatement
-
moveLabelsFrom
Utility: Moves labels from the givent block.
Special case: Labels in a CompoundStatement or ConnectionBlock.
Move Label Declaration to nearest enclosing Block which is not a CompoundStatement or ConnectionBlock.
- Parameters:
block
- the block containing labels to be moved
-
doChecking
public void doChecking()Description copied from class:SyntaxClass
Perform semantic checking.
This must be redefined in every subclass.
- Overrides:
doChecking
in classSyntaxClass
-
getRTBlockLevel
public int getRTBlockLevel()Description copied from class:DeclarationScope
Utility: Get Runtime BlockLevel.- Overrides:
getRTBlockLevel
in classDeclarationScope
- Returns:
- true: the Runtime BlockLevel.
-
findVisibleAttributeMeaning
Description copied from class:DeclarationScope
Find visible attribute's Meaning- Overrides:
findVisibleAttributeMeaning
in classDeclarationScope
- Parameters:
ident
- attribute identifier- Returns:
- the resulting Meaning
-
doJavaCoding
public void doJavaCoding()Description copied from class:SyntaxClass
Output Java code.- Overrides:
doJavaCoding
in classSyntaxClass
-
doCompoundStatementCoding
private void doCompoundStatementCoding()Java Coding utility: Code compound statement -
doSubBlockCoding
private void doSubBlockCoding()Java Coding utility: Code sub-block -
doCodeConstructor
private void doCodeConstructor()Java Coding utility: Code constructor -
doCodeStatements
private void doCodeStatements()Java Coding utility: Code statements -
getClassDesc
Description copied from class:DeclarationScope
Return the ClassDesc- Overrides:
getClassDesc
in classDeclarationScope
- Returns:
- the ClassDesc
-
buildClassFile
public byte[] buildClassFile()Description copied from class:DeclarationScope
Build Class File- Specified by:
buildClassFile
in classDeclarationScope
- Returns:
- Class File bytes
-
buildConstructor
Generate byteCode for the Constructor.
public Program'name(RTS_RTObject staticLink) { super(staticLink); // Initiate local variables // Declaration Code BBLK(); }
- Parameters:
codeBuilder
- the CodeBuilder
-
buildByteCode
Description copied from class:SyntaxClass
Build Java ClassFile ByteCode.- Overrides:
buildByteCode
in classSyntaxClass
- Parameters:
codeBuilder
- the codeBuilder to use.
-
edConstructorSignature
Description copied from class:BlockDeclaration
Edit the ConstructorSignature.- Overrides:
edConstructorSignature
in classBlockDeclaration
- Returns:
- the ConstructorSignature String.
-
build_STM_BODY
Description copied from class:BlockDeclaration
ClassFile coding utility: Build byteCode for the '_STM' method.- Overrides:
build_STM_BODY
in classBlockDeclaration
- Parameters:
codeBuilder
- the codeBuilder to use.begScope
- labelendScope
- label
-
build_STMS
ClassFile coding utility: Build the statements.- 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
public static MaybeBlockDeclaration readObject(AttributeInputStream inpt, int declarationKind) throws IOException Read and return a MaybeBlockDeclaration object.- Parameters:
inpt
- the AttributeInputStream to read fromdeclarationKind
- the declarationKind code- Returns:
- the object read from the stream.
- Throws:
IOException
- if something went wrong.
-