org.apache.sysds.runtime.controlprogram

## Class ProgramBlock

- java.lang.Object
- - org.apache.sysds.runtime.controlprogram.ProgramBlock

- All Implemented Interfaces:
    ParseInfo
  Direct Known Subclasses:
    BasicProgramBlock, ForProgramBlock, FunctionProgramBlock, IfProgramBlock, WhileProgramBlock

      public abstract class ProgramBlock
      extends Object
      implements ParseInfo

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `int` | `_beginColumn`
    `int` | `_beginLine`
    `int` | `_endColumn`
    `int` | `_endLine`
    `String` | `_filename`
    `String` | `_text`
    `static String` | `PRED_VAR`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ProgramBlock(Program prog)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract void` | `execute(ExecutionContext ec)` Executes this program block (incl recompilation if required).
    `ScalarObject` | `executePredicate(ArrayList<Instruction> inst, Hop hops, boolean requiresRecompile, Types.ValueType retType, ExecutionContext ec)` Executes given predicate instructions (incl recompilation if required)
    `int` | `getBeginColumn()`
    `int` | `getBeginLine()`
    `abstract ArrayList<ProgramBlock>` | `getChildBlocks()` Get the list of child program blocks if nested; otherwise this method returns null.
    `int` | `getEndColumn()`
    `int` | `getEndLine()`
    `Instruction` | `getExitInstruction()`
    `String` | `getFilename()`
    `Program` | `getProgram()`
    `StatementBlock` | `getStatementBlock()`
    `String` | `getText()`
    `long` | `getThreadID()`
    `boolean` | `hasThreadID()`
    `abstract boolean` | `isNested()` Indicates if the program block is nested, i.e., if it contains other program blocks (e.g., loops).
    `static boolean` | `isThreadID(long tid)`
    `String` | `printBlockErrorLocation()`
    `void` | `setBeginColumn(int passed)`
    `void` | `setBeginLine(int passed)`
    `void` | `setEndColumn(int passed)`
    `void` | `setEndLine(int passed)`
    `void` | `setExitInstruction(Instruction rmVar)`
    `void` | `setFilename(String passed)`
    `void` | `setParseInfo(ParseInfo parseInfo)` Set parse information.
    `void` | `setProgram(Program prog)`
    `void` | `setStatementBlock(StatementBlock sb)`
    `void` | `setText(String text)`
    `void` | `setThreadID(long id)`

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.apache.sysds.parser.ParseInfo

      `ctxAndFilenameToParseInfo`

- - ### Field Detail

    - #### PRED_VAR

          public static final String PRED_VAR

      See Also:
        Constant Field Values

    - #### _filename

          public String _filename

    - #### _beginLine

          public int _beginLine

    - #### _beginColumn

          public int _beginColumn

    - #### _endLine

          public int _endLine

    - #### _endColumn

          public int _endColumn

    - #### _text

          public String _text

  - ### Constructor Detail

    - #### ProgramBlock

          public ProgramBlock(Program prog)

  - ### Method Detail

    - #### getProgram

          public Program getProgram()

    - #### setProgram

          public void setProgram(Program prog)

    - #### getStatementBlock

          public StatementBlock getStatementBlock()

    - #### setStatementBlock

          public void setStatementBlock(StatementBlock sb)

    - #### setThreadID

          public void setThreadID(long id)

    - #### hasThreadID

          public boolean hasThreadID()

    - #### isThreadID

          public static boolean isThreadID(long tid)

    - #### getThreadID

          public long getThreadID()

    - #### setExitInstruction

          public void setExitInstruction(Instruction rmVar)

    - #### getExitInstruction

          public Instruction getExitInstruction()

    - #### getChildBlocks

          public abstract ArrayList<ProgramBlock> getChildBlocks()

      Get the list of child program blocks if nested; otherwise this method returns null.
      Returns:
        list of program blocks

    - #### isNested

          public abstract boolean isNested()

      Indicates if the program block is nested, i.e., if it contains other program blocks (e.g., loops).
      Returns:
        true if nested

    - #### execute

          public abstract void execute(ExecutionContext ec)

      Executes this program block (incl recompilation if required).
      Parameters:
        `ec` - execution context

    - #### executePredicate

          public ScalarObject executePredicate(ArrayList<Instruction> inst,
                                               Hop hops,
                                               boolean requiresRecompile,
                                               Types.ValueType retType,
                                               ExecutionContext ec)

      Executes given predicate instructions (incl recompilation if required)
      Parameters:
        `inst` - list of instructions
        `hops` - high-level operator
        `requiresRecompile` - true if requires recompile
        `retType` - value type of the return type
        `ec` - execution context
      Returns:
        scalar object

    - #### setFilename

          public void setFilename(String passed)

      Specified by:
        `setFilename` in interface `ParseInfo`

    - #### setBeginLine

          public void setBeginLine(int passed)

      Specified by:
        `setBeginLine` in interface `ParseInfo`

    - #### setBeginColumn

          public void setBeginColumn(int passed)

      Specified by:
        `setBeginColumn` in interface `ParseInfo`

    - #### setEndLine

          public void setEndLine(int passed)

      Specified by:
        `setEndLine` in interface `ParseInfo`

    - #### setEndColumn

          public void setEndColumn(int passed)

      Specified by:
        `setEndColumn` in interface `ParseInfo`

    - #### setText

          public void setText(String text)

      Specified by:
        `setText` in interface `ParseInfo`

    - #### getFilename

          public String getFilename()

      Specified by:
        `getFilename` in interface `ParseInfo`

    - #### getBeginLine

          public int getBeginLine()

      Specified by:
        `getBeginLine` in interface `ParseInfo`

    - #### getBeginColumn

          public int getBeginColumn()

      Specified by:
        `getBeginColumn` in interface `ParseInfo`

    - #### getEndLine

          public int getEndLine()

      Specified by:
        `getEndLine` in interface `ParseInfo`

    - #### getEndColumn

          public int getEndColumn()

      Specified by:
        `getEndColumn` in interface `ParseInfo`

    - #### getText

          public String getText()

      Specified by:
        `getText` in interface `ParseInfo`

    - #### printBlockErrorLocation

          public String printBlockErrorLocation()

    - #### setParseInfo

          public void setParseInfo(ParseInfo parseInfo)

      Set parse information.
      Parameters:
        `parseInfo` - parse information, such as beginning line position, beginning column position, ending line position, ending column position, text, and filename

Copyright © 2020 The Apache Software Foundation. All rights reserved.