Class LabelDeclaration


public final class LabelDeclaration extends SimpleVariableDeclaration

Label Declaration.

Link to GitHub: Source File.

Author:
Øystein Myhre Andersen
  • Field Details

    • index

      public int index
      The label index. Set by BlockDeclaration.doAccumLabels.
    • movedTo

      public DeclarationScope movedTo
      Special case: Labels in a CompoundStatement or ConnectionBlock are moved to nearest enclosing Block which is not a CompoundStatement or ConnectionBlock.
    • isBinded

      public boolean isBinded
      Indicates that codeBuilder.labelBinding is called.
  • Constructor Details

    • LabelDeclaration

      public LabelDeclaration(String identifier)
      Create a new Label Declaration.
      Parameters:
      identifier - label identifier
  • Method Details

    • doChecking

      public void doChecking()
      Description copied from class: SyntaxClass

      Perform semantic checking.

      This must be redefined in every subclass.

      Overrides:
      doChecking in class SimpleVariableDeclaration
    • declareLocalLabel

      public void declareLocalLabel(BlockDeclaration encloser)
      Declare a local Label.
      Parameters:
      encloser - the BlockDeclaration to update.
    • buildDeclaration

      public void buildDeclaration(ClassBuilder classBuilder, BlockDeclaration encloser)
      Description copied from class: Declaration
      Output Java ByteCode. Treat Declaration.
      Overrides:
      buildDeclaration in class SimpleVariableDeclaration
      Parameters:
      classBuilder - the classBuilder to use.
      encloser - the owning block.
    • isLatestVirtualLabel

      private boolean isLatestVirtualLabel(DeclarationScope encloser)
      Check if this label is the last label in the owner's label list.
      Parameters:
      encloser - the owner.
      Returns:
      true: if this label is the last label in the owner's label list.
    • getPrefixLevel

      private int getPrefixLevel()
      Returns the prefix level.
      Returns:
      the prefix level.
    • buildVirtualMatchMethodBody

      private void buildVirtualMatchMethodBody(int prefixLevel, CodeBuilder codeBuilder)
      ClassFile coding utility: Build Virtual Match Method Body.
      Parameters:
      prefixLevel - the prefix level.
      codeBuilder - the codeBuilder to use.
    • getFieldRefEntry

      public FieldRefEntry getFieldRefEntry(ConstantPoolBuilder pool)
      Description copied from class: SimpleVariableDeclaration
      ClassFile coding utility: get FieldRefEntry of this SimpleVariable.
      Overrides:
      getFieldRefEntry in class SimpleVariableDeclaration
      Parameters:
      pool - the ConstantPoolBuilder to use.
      Returns:
      the FieldRefEntry of this SimpleVariable.
    • getFieldIdentifier

      public String getFieldIdentifier()
      Description copied from class: Declaration
      ClassFile coding utility: get getFieldIdentifier.
      Overrides:
      getFieldIdentifier in class SimpleVariableDeclaration
      Returns:
      the resulting String.
    • buildInitAttribute

      public void buildInitAttribute(CodeBuilder codeBuilder)
      Description copied from class: Declaration
      Output Java ByteCode. Build init code for an Attribute.
      Overrides:
      buildInitAttribute in class SimpleVariableDeclaration
      Parameters:
      codeBuilder - the codeBuilder to use.
    • doBind

      public void doBind(CodeBuilder codeBuilder)
      Build binding for this Label.
      Parameters:
      codeBuilder - the codeBuilder to use.
    • buildLabelQuant

      public void buildLabelQuant(CodeBuilder codeBuilder)
      Build Label Quantity
      Parameters:
      codeBuilder - the codeBuilder to use
    • toString

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

      public void writeObject(AttributeOutputStream oupt) throws IOException
      Description copied from class: SyntaxClass
      Write a SyntaxClass object to a AttributeOutputStream.
      Overrides:
      writeObject in class SimpleVariableDeclaration
      Parameters:
      oupt - the AttributeOutputStream to write to.
      Throws:
      IOException - if something went wrong.
    • readObject

      public static LabelDeclaration readObject(AttributeInputStream inpt) throws IOException
      Read and return an object.
      Parameters:
      inpt - the AttributeInputStream to read from
      Returns:
      the object read from the stream.
      Throws:
      IOException - if something went wrong.