Interface IProgramBuilder

All Known Implementing Classes:
ProgramBuilder

public interface IProgramBuilder
Interface for simplifying program creation process. This interface is useful when full program context has not been fully created, but will be at later point. The final program can be built using the build() method.
Author:
Erik Zemčík
See Also:
  • Method Details

    • addInstruction

      void addInstruction(IInstruction instruction, int linePosition)
      Appends instruction to all instructions of the program.
      Parameters:
      instruction - instruction to add
      linePosition - line position associated with the instruction
      Throws:
      IllegalArgumentException - if instruction is null or if linePosition is not a positive integer
    • addJumpLabelMapping

      void addJumpLabelMapping(String label, int linePosition)
      Adds unique jump label mapping to the program. If addition of the same jump label is attempted, this method should throw IllegalStateException. Dedicated method hasJumpLabelMapping(String) can be used to check if label has been already added.
      Parameters:
      label - jump label of the mapping
      linePosition - zero-based line position to jump to
      Throws:
      IllegalArgumentException - if label is null or empty or if linePosition is not a positive integer
      IllegalStateException - if label is already assigned to different mapping
      See Also:
    • hasJumpLabelMapping

      boolean hasJumpLabelMapping(String label)
      Check if jump label has been added to the program.
      Parameters:
      label - jump label to check
      Returns:
      true if the builder already contains the jump label, else false
      Throws:
      IllegalArgumentException - if label is null or empty
    • build

      Program build()
      Builds the program based on the data specified during the lifetime of the builder.
      Returns:
      program