Enum Class ScriptCommandType

java.lang.Object
java.lang.Enum<ScriptCommandType>
com.blackrook.rookscript.lang.ScriptCommandType
All Implemented Interfaces:
Serializable, Comparable<ScriptCommandType>, java.lang.constant.Constable

public enum ScriptCommandType extends Enum<ScriptCommandType>
Directive type for scripts.
Author:
Matthew Tropiano
  • Enum Constant Details

    • NOOP

      public static final ScriptCommandType NOOP
      Do nothing. No operand.
    • RETURN

      public static final ScriptCommandType RETURN
      Return value. No operand. Restores previous command index / frame.
    • CALL

      public static final ScriptCommandType CALL
      Call function. Operand is label. Pushes and sets a new command index.
    • CALL_HOST

      public static final ScriptCommandType CALL_HOST
      Call host function. Operand is function name.
    • CALL_HOST_NAMESPACE

      public static final ScriptCommandType CALL_HOST_NAMESPACE
      Call a namespaced host function. Operand1 is namespace name. Operand2 is function name.
    • JUMP

      public static final ScriptCommandType JUMP
      Jump to index. Operand is label. Sets a new command index.
    • JUMP_BRANCH

      public static final ScriptCommandType JUMP_BRANCH
      Jump to index based on POP. Operand1 is label if true. Operand2 is label if false. Sets a new command index.
    • JUMP_TRUE

      public static final ScriptCommandType JUMP_TRUE
      Jump to index if POP is true. Operand is label if true. Sets a new command index.
    • JUMP_FALSE

      public static final ScriptCommandType JUMP_FALSE
      Jump to index if POP is false. Operand is label if false. Sets a new command index.
    • JUMP_FALSECOALESCE

      public static final ScriptCommandType JUMP_FALSECOALESCE
      Jump to label if stack top is true-equivalent, else pop. Operand is label if false. Sets a new command index.
    • JUMP_NULLCOALESCE

      public static final ScriptCommandType JUMP_NULLCOALESCE
      Jump to label if stack top is not null, else pop. Operand is label if false. Sets a new command index.
    • ITERATE

      public static final ScriptCommandType ITERATE
      Performs a single iteration, expecting an OBJECTREF:ScriptIteratorType on the stack top when this is executed. If stack top is not OBJECTREF:ScriptIteratorType, Exception - script was compiled badly. If stack top's ScriptIteratorType.hasNext() is null, POP, then JUMP to [label]. Else, call ScriptIteratorType.next(), then push value. If operand2 is true, also push key. Operand1 is label. Operand2 is value/key-value flag. Sets a new command index and one POP, or 1-2 PUSHes.
    • CHECK_ERROR

      public static final ScriptCommandType CHECK_ERROR
      If the stack top is an error, jump to label. Operand1 is label. Pushes nothing.
    • PUSH

      public static final ScriptCommandType PUSH
      PUSH value. Operand is Boolean, Double, Long, String, Object. Pushes one value.
    • PUSH_NULL

      public static final ScriptCommandType PUSH_NULL
      PUSH null literal. No Operands. Pushes one value.
    • PUSH_VARIABLE

      public static final ScriptCommandType PUSH_VARIABLE
      PUSH variable. Operand1 is String - variable name. Pushes one value.
    • PUSH_SCOPE_VARIABLE

      public static final ScriptCommandType PUSH_SCOPE_VARIABLE
      PUSH scoped variable. Operand1 is String - scope name. Operand2 is String - variable name. Pushes one value, or null if no scope.
    • PUSH_LIST_NEW

      public static final ScriptCommandType PUSH_LIST_NEW
      PUSH a new blank list. No operands.
    • PUSH_LIST_INIT

      public static final ScriptCommandType PUSH_LIST_INIT
      PUSH a new blank list initialized with values. Pops a value for list length. Pops [length] values into array backwards (order pushed). Pushes array value into stack. No operands.
    • PUSH_LIST_INDEX

      public static final ScriptCommandType PUSH_LIST_INDEX
      PUSH a list value. Pops two values - an index and the array. Pushes one value onto stack. No operands.
    • PUSH_LIST_INDEX_CONTENTS

      public static final ScriptCommandType PUSH_LIST_INDEX_CONTENTS
      PUSH a list value. Pops ZERO values - only inspects two spots down in the stack! Pushes one value onto stack. No operands.
    • PUSH_MAP_NEW

      public static final ScriptCommandType PUSH_MAP_NEW
      PUSH a new blank map. No operands.
    • PUSH_MAP_INIT

      public static final ScriptCommandType PUSH_MAP_INIT
      PUSH a new blank map initialized with values. Pops a value for amount of entries. Pops [amount] values into map. Pushes map value into stack. No operands.
    • PUSH_MAP_KEY

      public static final ScriptCommandType PUSH_MAP_KEY
      PUSHes a map value using a key. Pops two values - key and map. If map value is not a map, pushes NULL. No operands.
    • PUSH_MAP_KEY_CONTENTS

      public static final ScriptCommandType PUSH_MAP_KEY_CONTENTS
      PUSHes a map value using a key. Pops ZERO values - only inspects two spots down in the stack! Pushes one value onto stack. No operands.
    • SET_ITERATOR_VARIABLE

      public static final ScriptCommandType SET_ITERATOR_VARIABLE
      Pops a variable, creates an iterator for it, and sets a variable for it. Pops one value. Sets a variable. Operand is variable name.
    • PUSH_CHECK

      public static final ScriptCommandType PUSH_CHECK
      Pushes a Check Sentinel Object onto the stack. Pushes one value onto stack. No operands.
    • POP

      public static final ScriptCommandType POP
      POP value into nothing. No operands.
    • POP_VARIABLE

      public static final ScriptCommandType POP_VARIABLE
      POP into variable variable. Operand is String - variable name.
    • POP_SCOPE_VARIABLE

      public static final ScriptCommandType POP_SCOPE_VARIABLE
      POP into variable variable. Operand is String - variable name.
    • POP_LIST

      public static final ScriptCommandType POP_LIST
      Sets a list value. Pops three values - the value, the index, and then the list. No operands.
    • POP_MAP

      public static final ScriptCommandType POP_MAP
      Sets a map value. Pops three values - the value, the key, and then the map. No operands.
    • POP_CHECK

      public static final ScriptCommandType POP_CHECK
      Optionally preserves the topmost stack value, then POPs values until the [amount]'th sentinel was popped, then pushes the preserved value onto the stack. Operand1 is amount of sentinel objects to pop. Operand2 is the preserve top flag (true = do it, false = don't).
    • SET

      public static final ScriptCommandType SET
      Set's a variable to a value. Operand1 is String - variable name. Operand2 is Object value.
    • SET_VARIABLE

      public static final ScriptCommandType SET_VARIABLE
      Set's a variable to another variable's value. Operand1 is String - variable name. Operand2 is String - variable name.
    • NOT

      public static final ScriptCommandType NOT
      Bitwise NOT. Pushes one value.
    • NEGATE

      public static final ScriptCommandType NEGATE
      Negate. Pops one value. Pushes one value.
    • ABSOLUTE

      public static final ScriptCommandType ABSOLUTE
      Absolute. Pops one value. Pushes one value.
    • LOGICAL

      public static final ScriptCommandType LOGICAL
      Turns the topmost value into a boolean-equivalent value (the same as a not-not). Pops one value. Pushes one value.
    • LOGICAL_NOT

      public static final ScriptCommandType LOGICAL_NOT
      Logical Not. Pops one value. Pushes one value.
    • ADD

      public static final ScriptCommandType ADD
      Add. Pops two values. Pushes one value.
    • SUBTRACT

      public static final ScriptCommandType SUBTRACT
      Subtract. Pops two values. Pushes one value.
    • MULTIPLY

      public static final ScriptCommandType MULTIPLY
      Multiply. Pops two values. Pushes one value.
    • DIVIDE

      public static final ScriptCommandType DIVIDE
      Divide. Pops two values. Pushes one value.
    • MODULO

      public static final ScriptCommandType MODULO
      Modulo. Pops two values. Pushes one value.
    • AND

      public static final ScriptCommandType AND
      Bitwise And. Pops two values. Pushes one value.
    • OR

      public static final ScriptCommandType OR
      Bitwise Or. Pops two values. Pushes one value.
    • XOR

      public static final ScriptCommandType XOR
      Bitwise Xor. Pops two values. Pushes one value.
    • LOGICAL_AND

      public static final ScriptCommandType LOGICAL_AND
      Logical And. Pops two values. Pushes one value.
    • LOGICAL_OR

      public static final ScriptCommandType LOGICAL_OR
      Logical Or. Pops two values. Pushes one value.
    • LEFT_SHIFT

      public static final ScriptCommandType LEFT_SHIFT
      Left Bit Shift. Pops two values. Pushes one value.
    • RIGHT_SHIFT

      public static final ScriptCommandType RIGHT_SHIFT
      Right Bit Shift. Pops two values. Pushes one value.
    • RIGHT_SHIFT_PADDED

      public static final ScriptCommandType RIGHT_SHIFT_PADDED
      Right Bit Shift Padded. Pops two values. Pushes one value.
    • LESS

      public static final ScriptCommandType LESS
      Less than. Pops two values. Pushes one value.
    • LESS_OR_EQUAL

      public static final ScriptCommandType LESS_OR_EQUAL
      Less than or equal. Pops two values. Pushes one value.
    • GREATER

      public static final ScriptCommandType GREATER
      Greater than. Pops two values. Pushes one value.
    • GREATER_OR_EQUAL

      public static final ScriptCommandType GREATER_OR_EQUAL
      Greater than or equal. Pops two values. Pushes one value.
    • EQUAL

      public static final ScriptCommandType EQUAL
      Equal. Pops two values. Pushes one value.
    • NOT_EQUAL

      public static final ScriptCommandType NOT_EQUAL
      Not Equal. Pops two values. Pushes one value.
    • STRICT_EQUAL

      public static final ScriptCommandType STRICT_EQUAL
      Strict Equal. Pops two values. Pushes one value.
    • STRICT_NOT_EQUAL

      public static final ScriptCommandType STRICT_NOT_EQUAL
      Strict Not Equal. Pops two values. Pushes one value.
  • Method Details

    • values

      public static ScriptCommandType[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static ScriptCommandType valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • execute

      public abstract boolean execute(ScriptInstance scriptInstance, Object operand1, Object operand2)
      Executes this directive.
      Parameters:
      scriptInstance - the originating script instance.
      operand1 - the first operand.
      operand2 - the second operand.
      Returns:
      if false, this halts script execution, else if true, continue.