Module dev.civl.mc

Interface CallOrSpawnStatement

All Superinterfaces:
Sourceable, Statement

public interface CallOrSpawnStatement extends Statement
A function call or spawn. Either of the form f(x) or else v=f(x). The function expression is set only once if the function called is known statically.
  • Method Details

    • isCall

      boolean isCall()
      Is this a call (not spawn)?
      Returns:
      true iff this is a call
    • isSpawn

      boolean isSpawn()
      Is this a spawn (not call)?
      Returns:
      true iff this is a spawn
    • isRun

      boolean isRun()

      Pre-condition: isSpawn() == true

      Is this a spawn for $run statement ?
      Returns:
      true if and only if this is a spawn and it is translated from a $run statement.
    • isInitializer

      boolean isInitializer()
      Returns:
      true iff the lhs() expression will be initialized by the return value of this call statement, i.e. the function call is an initializer of a declaration.
    • lhs

      Returns:
      The left hand side expression if applicable. Else null.
    • function

      CIVLFunction function()
      TODO: get rid of it
      Returns:
      The function being called.
    • arguments

      List<Expression> arguments()
      Returns:
      The arguments to the function.
    • setLhs

      void setLhs(LHSExpression lhs)
      Parameters:
      lhs - The left hand side expression if applicable. Else null.
    • setAsRun

      void setAsRun(boolean isRun)

      Pre-condition: isSpawn() == true

      Set the statement as a $spawn for $run. i.e. A $spawn statement which is translated from a $run statement.
      Parameters:
      isRun -
    • setFunction

      void setFunction(FunctionIdentifierExpression function)
      TODO: get rid of this, but updates the function expression instead.
      Parameters:
      function - The function being called.
    • setArguments

      void setArguments(List<Expression> arguments)
      Parameters:
      arguments - The arguments to the function.
    • isSystemCall

      boolean isSystemCall()
      Check if the statement is calling a system function.
      Returns:
    • functionExpression

      Expression functionExpression()
    • replaceWith

      CallOrSpawnStatement replaceWith(ConditionalExpression oldExpression, Expression newExpression)
      Description copied from interface: Statement
      Return a new statement by copying this statement and modifying it as well as its guard by replacing a certain conditional expression with a expression, used when translating away conditional expression WITHOUT introducing temporary variables. The original statement can't be modified, because it needs to be used twice to generate the if branch statement and the else branch statement.
      For example, x = a ? b : c will be translated into if(a) x = b; else x = c;
      Another example, $when(a?b:c) x = k; will be translated into if(a) $when(b) x=k; else $when(c) x=k;
      Specified by:
      replaceWith in interface Statement
      Parameters:
      oldExpression - The conditional expression to be cleared.
      newExpression - The new expression to take place of the conditional expression. Usually, it is one of the choice expressions of the conditional expression.
      Returns:
      A new statement without the conditional expression