Class LabelList

java.lang.Object
simula.compiler.utilities.LabelList

public class LabelList extends Object

A list of LabelDeclarations.

Link to GitHub: Source File.

Author:
Øystein Myhre Andersen
  • Field Details

    • TRACING

      private static boolean TRACING
      Debug utility.
    • LABEL_SEQU

      private static int LABEL_SEQU
      Utility to help make unique sequence numbers.
    • sequ

      private int sequ
      The sequence number of this label list.
    • declaredIn

      private DeclarationScope declaredIn
      The owner of this label list.
    • declaredLabels

      private Vector<LabelDeclaration> declaredLabels
      The labels in this list.
    • READY_FOR_CODING

      private boolean READY_FOR_CODING
      true: this LabelList is ready for coding.
    • accumLabels

      private Vector<LabelDeclaration> accumLabels
      Set by MAKE_READY_FOR_CODING or accumLabelList
    • defaultTarget

      private Label defaultTarget
      beginning of the default handler block. Set by MAKE_READY_FOR_CODING
    • tableSwitchCases

      private Vector<SwitchCase> tableSwitchCases
      Set by MAKE_READY_FOR_CODING
  • Constructor Details

    • LabelList

      public LabelList(DeclarationScope declaredIn)
      A list of LabelDeclarations.
      Parameters:
      declaredIn - the DeclarationScope owning this list.
  • Method Details

    • clear

      public void clear()
      Clears this list.
    • ident

      private String ident()
      Debug utility: Return identification String.
      Returns:
      identification String.
    • getDeclaredLabels

      public Vector<LabelDeclaration> getDeclaredLabels()
      Get DeclaredLabels
      Returns:
      DeclaredLabels
    • getAccumLabels

      public Vector<LabelDeclaration> getAccumLabels()
      Get all labels. Accumulated through the prefix chain for classes and prefixed blocks.
      Returns:
      a Vector of LabelDeclarations
    • accumLabelSize

      public int accumLabelSize()
      Get number of accumulated labels. Accumulated through the prefix chain for classes and prefixed blocks.
      Returns:
      number of accumulated labels.
    • declaredLabelSize

      public int declaredLabelSize()
      Get number of local labels.
      Returns:
      number of local labels.
    • getLastDeclaredLabel

      public LabelDeclaration getLastDeclaredLabel(String ident)
      Get last declared local label with the given ident.
      Parameters:
      ident - label identifier
      Returns:
      number of accumulated labels.
    • add

      public void add(LabelDeclaration lab)
      Add a label to the local label list.
      Parameters:
      lab - the label to add.
    • accumLabelList

      public static void accumLabelList(BlockDeclaration blk)

      Accumulate the label list for the given block. accumulated through the prefix chain for classes and prefixed blocks.

      This method is used when generating .java source.

      Parameters:
      blk - the given BlockDeclaration.
    • getTableSwitchCases

      public List<SwitchCase> getTableSwitchCases(CodeBuilder codeBuilder)

      Get a List of SwitchCase suitable for the 'tableswitch' instruction.

      This method is used when generating classFile using the codeBuilder.

      Parameters:
      codeBuilder - the codeBuilder
      Returns:
      a List of SwitchCase
    • setLabelIdexes

      public void setLabelIdexes()

      Sets the label indexes suitable for the 'tableswitch' instruction.

      This method is used when generating classFile using the codeBuilder.

    • MAKE_READY_FOR_CODING

      private void MAKE_READY_FOR_CODING(CodeBuilder codeBuilder)
      ClassFile coding utility: Make this LabelList ready for coding.
      Parameters:
      codeBuilder - the codeBuilder to use
    • build_JUMPTABLE

      public void build_JUMPTABLE(CodeBuilder.BlockCodeBuilder codeBuilder)
      ClassFile coding utility: Build the TableSwitch Instruction.
      Parameters:
      codeBuilder - the codeBuilder to use
    • labelBinding

      public void labelBinding(LabelDeclaration label, CodeBuilder codeBuilder)
      ClassFile coding utility: Build a labelBinding.
      Parameters:
      label - the label to bind
      codeBuilder - the codeBuilder to use
    • printTree

      public void printTree(int indent, BlockDeclaration owner)
      Debug utility: Print Syntax tree
      Parameters:
      indent - indentation
      owner - the BlockDeclaration owning this LabelList
    • print

      public void print(String title)
      Debug utility: print the LabelList
      Parameters:
      title - title String
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • writeLabelList

      public static void writeLabelList(LabelList labelList, AttributeOutputStream oupt) throws IOException
      Write a LabelList to a AttributeOutputStream.
      Parameters:
      labelList - the LabelList to write.
      oupt - the AttributeOutputStream to write to.
      Throws:
      IOException - if something went wrong.
    • readLabelList

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