Class MaybeBlockDeclaration


public final class MaybeBlockDeclaration extends BlockDeclaration

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
  • Constructor Details

    • MaybeBlockDeclaration

      public MaybeBlockDeclaration(String identifier)
      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

      public static MaybeBlockDeclaration createMainProgramBlock()
      Create the main program block. Used by ProgramModule.
      Returns:
      the main program block
    • expectMaybeBlock

      public BlockStatement expectMaybeBlock(int line)

      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

      static void moveLabelsFrom(DeclarationScope block)

      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 class SyntaxClass
    • getRTBlockLevel

      public int getRTBlockLevel()
      Description copied from class: DeclarationScope
      Utility: Get Runtime BlockLevel.
      Overrides:
      getRTBlockLevel in class DeclarationScope
      Returns:
      true: the Runtime BlockLevel.
    • findVisibleAttributeMeaning

      public Meaning findVisibleAttributeMeaning(String ident)
      Description copied from class: DeclarationScope
      Find visible attribute's Meaning
      Overrides:
      findVisibleAttributeMeaning in class DeclarationScope
      Parameters:
      ident - attribute identifier
      Returns:
      the resulting Meaning
    • doJavaCoding

      public void doJavaCoding()
      Description copied from class: SyntaxClass
      Output Java code.
      Overrides:
      doJavaCoding in class SyntaxClass
    • 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

      public ClassDesc getClassDesc()
      Description copied from class: DeclarationScope
      Return the ClassDesc
      Overrides:
      getClassDesc in class DeclarationScope
      Returns:
      the ClassDesc
    • buildClassFile

      public byte[] buildClassFile()
      Description copied from class: DeclarationScope
      Build Class File
      Specified by:
      buildClassFile in class DeclarationScope
      Returns:
      Class File bytes
    • buildConstructor

      private void buildConstructor(CodeBuilder codeBuilder)

      Generate byteCode for the Constructor.

          public Program'name(RTS_RTObject staticLink) {
              super(staticLink);
              // Initiate local variables
              // Declaration Code
              BBLK();
          }
      
      Parameters:
      codeBuilder - the CodeBuilder
    • buildByteCode

      public void buildByteCode(CodeBuilder codeBuilder)
      Description copied from class: SyntaxClass
      Build Java ClassFile ByteCode.
      Overrides:
      buildByteCode in class SyntaxClass
      Parameters:
      codeBuilder - the codeBuilder to use.
    • edConstructorSignature

      public String edConstructorSignature()
      Description copied from class: BlockDeclaration
      Edit the ConstructorSignature.
      Overrides:
      edConstructorSignature in class BlockDeclaration
      Returns:
      the ConstructorSignature String.
    • build_STM_BODY

      protected void build_STM_BODY(CodeBuilder codeBuilder, Label begScope, Label endScope)
      Description copied from class: BlockDeclaration
      ClassFile coding utility: Build byteCode for the '_STM' method.
      Overrides:
      build_STM_BODY in class BlockDeclaration
      Parameters:
      codeBuilder - the codeBuilder to use.
      begScope - label
      endScope - label
    • build_STMS

      private void build_STMS(CodeBuilder codeBuilder)
      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 class SyntaxClass
      Parameters:
      indent - number of spaces leading the line
    • printTree

      public void printTree(int indent, Object head)
      Description copied from class: SyntaxClass
      Utility print syntax tree method.
      Overrides:
      printTree in class SyntaxClass
      Parameters:
      indent - number of spaces leading the lines
      head - the head of the tree.
    • toString

      public String toString()
      Overrides:
      toString in class BlockDeclaration
    • writeObject

      public void writeObject(AttributeOutputStream oupt) throws IOException
      Description copied from class: SyntaxClass
      Write a SyntaxClass object to a AttributeOutputStream.
      Overrides:
      writeObject in class SyntaxClass
      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 from
      declarationKind - the declarationKind code
      Returns:
      the object read from the stream.
      Throws:
      IOException - if something went wrong.