Class DefineVariableOperation

java.lang.Object
org.kigalisim.lang.operation.DefineVariableOperation
All Implemented Interfaces:
Operation

public class DefineVariableOperation extends Object implements Operation
Operation that defines a variable and sets its value in the engine.

This operation defines a variable with the specified name and sets its value in the engine.

  • Constructor Details

    • DefineVariableOperation

      public DefineVariableOperation(String variableName, Operation valueOperation)
      Create a new DefineVariableOperation.
      Parameters:
      variableName - The name of the variable to define.
      valueOperation - The operation that calculates the value to set.
  • Method Details

    • execute

      public void execute(PushDownMachine machine)
      Executes the variable definition operation.

      This method executes the value operation to obtain the value, defines the variable if it doesn't exist, and then sets the variable value in the engine.

      Specified by:
      execute in interface Operation
      Parameters:
      machine - The push-down machine on which to execute the operation.
    • getStaticSemantics

      public OperationStaticSemantics getStaticSemantics()
      Get a record describing this operation's semantics.

      Get a record describing this operation's semantics that are inferrable from its static expression in code. In other words, properties and effects which do not require inspection at time of executing the operation.

      Specified by:
      getStaticSemantics in interface Operation
      Returns:
      Inference of common static properties found for this operation.