Flow of Control, Procedure, and State Operators

Execute

The Execute operator takes a single operand

  • <x: Any> and may return results, depending on the type of its operand as described below:

    If x is of type Operator, it is executed.

    If x is of type Procedure, the effect is to interpret the sequence of tokens in the Procedure as though encountered in content.

    If x is of type Identifier and its executability attribute is executable, the effect is to interpret it as though it were an executable Name encountered in content .

    If x is of type Identifier and its executability attribute is literal, or if x is of any other type, it is pushed back onto the operand stack.

    Exit

    The Exit operator takes no operands and returns no results.

    The effect of interpreting the Exit operator in a Procedure being interpreted by a Repeat, Loop, For, or ForAll looping operator is to terminate the interpretation of that looping operator. In the case of nested looping operators, only the interpretation of the operator interpreting the Procedure containing the Exit operator is terminated.

    If an Exit operator is encountered in any context other than inside a Procedure being interpreted by a Repeat, Loop, For, or ForAll operator, RaiseError shall be invoked with InvalidExit as its operand.

    For

    The For operator takes four operands

  • <proc: Procedure>
  • <limit: Number>
  • <increment: Number>
  • <initial: Number> and returns no results. The Procedure is repeatedly interpreted as though by the Execute operator.

    Before each interpretation of proc, a value is placed on the operand stack as an operand to proc; these values run in sequence from initial by steps of increment to limit. Interpretation of the For operator ceases when the value to be placed on the operand stack as an operand to proc would be greater than limit (in the case of a positive increment), or when the value would be less than limit (in the case of a negative increment).

    The interpretation of the For operator may terminate before limit is reached if an Exit operator is encountered during an interpretation of proc.

    ForAll

    The ForAll operator takes two operands

  • <proc: Procedure>
  • <x: VectorReference, DictionaryReference, or OctetStringReference> and returns no results. The elements of the object referenced by x, or in the case that x is a DictionaryReference, the key/value pairs of the referenced Dictionary, are enumerated, and proc is interpreted once for each element (key/value pair) in the object referenced by x. The Procedure is repeatedly interpreted as though by the Execute operator.

    Before each interpretation of proc, an element (key/value pair) of x is placed on the operand stack as an operand to proc.

    If x is of type VectorReference the elements of the Vector referenced by x are pushed onto the operand stack beginning with the element whose index is 0 and continuing sequentially.

    If x is of type OctetStringReference the elements of the referenced OctetString are pushed onto the operand stack beginning with the first octet of the OctetString and continuing sequentially; the individual octets are represented on the operand stack by their Cardinal representations (see ).

    If x is of type DictionaryReference the key/value pairs of the referenced Dictionary are pushed onto the operand stack in an arbitrary order; for each key/value pair the key bound by the key/value pair is pushed onto the operand stack first, followed by the value to which the key is bound in the Dictionary.

    Interpretation of the ForAll operator ceases after proc has been interpreted for the last element (key/value pair) in x. If there are no elements (key/value pairs) in x then proc is not executed at all.

    The interpretation of the ForAll operator may terminate before all elements (key/value pairs) of x have been enumerated if an Exit operator is encountered during an interpretation of proc.

    GetDeviceDescription

    The GetDeviceDescription operator takes no operands and returns one result

  • <devdict: DictionaryReference> where devdict is the current value of the DeviceDescription state variable (see ).

    If

    The If operator takes two operands

  • <proc: Procedure>
  • <cond: Boolean> and returns no results; however, if proc is interpreted, it may leave results on the operand stack.

    If the value of cond is true, the Procedure is interpreted as though by the Execute operator.

    If the value of cond is false the Procedure is not interpreted.

    IfElse

    The IfElse operator takes three operands

  • <proc1: Procedure>
  • <proc0: Procedure>
  • <cond: Boolean> and returns no results; however, proc0 or proc1 may leave results on the operand stack.

    If the value of cond is true, proc0 is interpreted as though by the Execute operator.

    If the value of cond is false, proc1 is interpreted as though by the Execute operator.

    Loop

    The Loop operator takes a single operand

  • <proc: Procedure> and returns no results. The Procedure is interpreted as though by the Execute operator repeatedly until an Exit operator is encountered during an interpretation of proc.

    Noop

    The Noop operator takes no operands and returns no results. It has no effect on the virtual machine state.

    Repeat

    The Repeat operator takes two operands

  • <proc: Procedure>
  • <n: Cardinal> and returns no results. The Procedure is interpreted as though by the Execute operator n times in sequence, or until an Exit operator is encountered.

    RestoreGraphicsState

    The RestoreGraphicsState operator takes no operands and returns no results. Interpretation of the RestoreGraphicsState operator causes the entire graphics state, including the values of all state variables (see ), to be restored from the last Graphics State saved by interpretation of the SaveGraphicsState operator. Interpretation of the RestoreGraphicsState operator normally causes a pop of the Graphics State Stack. If the saved Graphics State that is on the top of the Graphics State Stack was created implicitly by a SaveState operator or at the beginning of the most immediately superior block, no pop of the Graphics State Stack is done and the Graphics State Stack is left unchanged. only the RestoreState operator can remove a Graphics State Stack entry that was created by a SaveState operator.

    RestoreGraphicsStateXCP

    The RestoreGraphicsStateXCP operator takes no operands and returns no results. Interpretation of the RestoreGraphicsStateXCP operator causes the entire graphics state, including the values of all state variables except CurrentPosition (see ), to be restored from the last Graphics State saved by interpretation of the SaveGraphicsState operator.

    Interpretation of the RestoreGraphicsStateXCP operator normally causes a pop of the Graphics State Stack. If the saved Graphics State that is on the top of the Graphics State Stack was created implicitly by a SaveState operator or at the beginning of the most immediately superior block, no pop of the Graphics State Stack is done and the Graphics State Stack is left unchanged.

    RestoreSavedGraphicsState

    The RestoreSavedGraphicsState operator takes no operands and returns no results. Interpretation of the RestoreSavedGraphicsState operator causes the entire Graphics State, including the values of all state variables (see ), to be restored.

    The RestoreSavedGraphicsState operator repeatedly pops the Graphics State Stack until it encounters a Graphics State that was saved by the SaveState operator or it encounters the Graphics State at the bottom of the Graphics State Stack (see ), then implicitly executes the RestoreGraphicsState operator to restore to that Graphics State. The Graphics State that was restored is left on the Graphics State Stack.

    RestoreState

    The RestoreState operator takes one operand

  • <s: SaveObject> and returns no results. The effect of the RestoreState operator is to restore the Graphics State, the Graphics State Stack, the State Variables, and the set of Referenced Objects to their state at the time s was saved (see ).

    If the Context Stack or Operand Stack contains ObjectReferences to objects created after s was created, RaiseError shall be invoked with InvalidRestore as its operand. The RestoreState operator implicitly executes the RestoreSavedGraphicsState operator to restore the Graphics State and then pops the Graphics State Stack removing the entry placed there by the SaveState operator that created s.

    SaveGraphicsState

    The SaveGraphicsState operator takes no operands and returns no results. Interpretation of the SaveGraphicsState operator causes the entire Graphics State, including the values of all State Variables (see ), to be saved on the Graphics State Stack.

    SaveState

    The SaveState operator takes no operands and returns a single result

  • <s: SaveObject> The effect of the SaveState operator is to save the current state of the Graphics State on the Graphics State Stack and create a SaveObject s that contains the Graphics State Stack, the State Variables, and the set of Referenced Objects (see ). The SaveState operator saves the Graphics State by logically executing the SaveGraphicsState operator.