Enum Opcode

java.lang.Object
java.lang.Enum<Opcode>
org.metricshub.jawk.intermediate.Opcode
All Implemented Interfaces:
Serializable, Comparable<Opcode>

public enum Opcode extends Enum<Opcode>
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    Numerically adds the top two elements of the stack with the result pushed onto the stack.
    Apply the RS variable by notifying the partitioning reader that there is a new regular expression to use when partitioning input records.
    Convert a list of array indices to a concatenated string with SUBSEP.
    Assign the ARGC variable offset.
    Assign the ARGV variable offset.
    Assigns the top-of-stack to a variable.
    Assigns an item to an array element.
    Assigns the top-of-stack to $0.
    Assigns an item as a particular input field; the field number can be 0.
    Built-in function that pops the first two items off the stack, calls the java.lang.Math.atan2 method with these as arguments, and places the result onto the stack.
    Call a user function.
    Checks whether the top-of-stack is of a particular class type; if not, an AwkRuntimeException is thrown.
    Close the specified file.
    Compares the top two stack elements; pushes 1 onto the stack if equal, 0 if not equal.
    Compares the top two stack elements; pushes 1 onto the stack if x1 > x2, 0 if not equal.
    Compares the top two stack elements; pushes 1 onto the stack if x1 < x2, 0 if not equal.
    Pop and concatenate two strings from the top-of-stack; push the result onto the stack.
    Returns a pair of regex patterns.
    Consume next line of input; assigning $0 and recalculating $1, $2, etc.
    Assign the CONVFMT variable offset.
    Built-in function that pops the top-of-stack, calls the java.lang.Math.cos method with the top-of-stack as the argument, and places the result onto the stack.
    Decreases the variable reference by one; pushes the result onto the stack.
    Decreases the array element reference by one; pushes the result onto the stack.
    Decreases the input field variable by one; pushes the result onto the stack.
    Delete the specified array.
    Deletes an entry in an array.
    Constant DEREF_ARRAY=336
    Obtains an item from the variable manager and push it onto the stack.
    Divides the contents of the variable by an adjustment value; assigns the result to the variable and pushes the result onto the stack.
    Divides the contents of an indexed array by an adjustment value; assigns the result to the array and pushes the result onto the stack.
    Divides the contents of an input field by an adjustment value; assigns the result to the input field and pushes the result onto the stack.
    Numerically divides the top two elements of the stack with the result pushed onto the stack.
    Duplicates the top-of-stack on the stack.
    Assign the ENVIRON variable offset.
    Execute the specified AWK code
    Terminates execution and returns specified exit code.
    Terminates execution without specifying an exit code.
    Built-in function that pops the top-of-stack, calls the java.lang.Math.exp method with the top-of-stack as the argument, and places the result onto the stack.
    Call a function from an extension
    Assign the FILENAME variable offset.
    Assign the FNR variable offset.
    Assign the FS variable offset.
    Define a user function.
    Removes an item from the key list (deque) and pushes it onto the operand stack.
    Push an input field onto the stack.
    Obtains input from stdin/filename-args and pushes input line and status code onto the stack.
    Jumps to a specified address.
    Pops and evaluates the top-of-stack; if false, it jumps to a specified address.
    Pops and evaluates the top-of-stack; if true, it jumps to a specified address.
    Increases the variable reference by one; pushes the result onto the stack.
    Increases the array element reference by one; pushes the result onto the stack.
    Increases the input field variable by one; pushes the result onto the stack.
    Built-in function that locates a substring within a source string and pushes the location onto the stack.
    Built-in function that pops the top-of-stack, removes its fractional part, if any, and places the result onto the stack.
    Tests whether the key list (deque) is empty; jumps to the argument address if empty, steps to the next instruction if not.
    Returns whether the specified key is in the array.
    Retrieves and pushes a set of keys from an associative array onto the stack.
    Depending on the argument, pop and evaluate the string length of the top-of-stack or evaluate the string length of $0; in either case, push the result onto the stack.
    Built-in function that pops the top-of-stack, calls the java.lang.Math.log method with the top-of-stack as the argument, and places the result onto the stack.
    Built-in function that searches a string as input to a regular expression, the location of the match is pushed onto the stack.
    Applies a regular expression to the top stack element; pushes 1 if it matches, 0 if it does not match.
    Decreases the contents of the variable by an adjustment value; assigns the result to the variable and pushes the result onto the stack.
    Decreases the contents of an indexed array by an adjustment value; assigns the result to the array and pushes the result onto the stack.
    Decreases the contents of an input field by an adjustment value; assigns the result to the input field and pushes the result onto the stack.
    Numerically takes the modulus of the top two elements of the stack with the result pushed onto the stack.
    Takes the modules of the contents of the variable by an adjustment value; assigns the result to the variable and pushes the result onto the stack.
    Takes the modulus of the contents of an indexed array by an adjustment value; assigns the result to the array and pushes the result onto the stack.
    Takes the modulus of the contents of an input field by an adjustment value; assigns the result to the input field and pushes the result onto the stack.
    Multiplies the contents of the variable by an adjustment value; assigns the result to the variable and pushes the result onto the stack.
    Multiplies the contents of an indexed array by an adjustment value; assigns the result to the array and pushes the result onto the stack.
    Multiplies the contents of an input field by an adjustment value; assigns the result to the input field and pushes the result onto the stack.
    Numerically multiplies the top two elements of the stack with the result pushed onto the stack.
    Evaluates the numerical NEGATION of the top stack element; pushes the result onto the stack.
    Assign the NF variable offset.
    A no-operation.
    Evaluates the logical NOT of the top stack element; pushes the result onto the stack.
    Assign the NR variable offset.
    Assign the OFMT variable offset.
    Assign the OFS variable offset.
    Assign the ORS variable offset.
    Increase the contents of the variable by an adjustment value; assigns the result to the variable and pushes the result onto the stack.
    Increase the contents of an indexed array by an adjustment value; assigns the result to the array and pushes the result onto the stack.
    Increases the contents of an input field by an adjustment value; assigns the result to the input field and pushes the result onto the stack.
    Pops an item off the operand stack.
    Decreases the variable reference by one; pushes the original value onto the stack.
    Increases the variable reference by one; pushes the original value onto the stack.
    Numerically raises the top element to the power of the next element with the result pushed onto the stack.
    Raises the contents of the variable to the power of the adjustment value; assigns the result to the variable and pushes the result onto the stack.
    Raises the contents of an indexed array to the power of an adjustment value; assigns the result to the array and pushes the result onto the stack.
    Raises the contents of an input field to the power of an adjustment value; assigns the result to the input field and pushes the result onto the stack.
    Prints N number of items that are on the operand stack.
    Prints N number of items that are on the operand stack to a specified file.
    Prints N number of items that are on the operand stack to a process executing a specified command (via a pipe).
    Performs a formatted print of N items that are on the operand stack.
    Performs a formatted print of N items that are on the operand stack to a specified file.
    Performs a formatted print of N items that are on the operand stack to a process executing a specified command (via a pipe).
    Pushes an item onto the operand stack.
    Obtains the next random number from the random number generator and push it onto the stack.
    Returns a regex pattern.
    Get the return value of the user function that was called
    Assign the RLENGTH variable offset.
    Assign the RS variable offset.
    Assign the RSTART variable offset.
    Internal.
    Read stdin for simple AWK expression evaluation.
    Internal: sets the number of global variables
    Sets the return value of a user function.
    Internal.
    Built-in function that pops the top-of-stack, calls the java.lang.Math.sin method with the top-of-stack as the argument, and places the result onto the stack.
    Built-in function to split a string by a regexp and put the components into an array.
    Constant SPRINTF=270
    Built-in function that pops the top-of-stack, takes its square root, and places the result onto the stack.
    Seeds the random number generator.
    Built-in function that substitutes an occurrence (or all occurrences) of a string in a particular array cell and replaces it with another.
    Built-in function that substitutes an occurrence (or all occurrences) of a string in $0 and replaces it with another.
    Built-in function that substitutes an occurrence (or all occurrences) of a string in a field reference and replaces it with another.
    Built-in function that substitutes an occurrence (or all occurrences) of a string in a particular variable and replaces it with another.
    Assign the SUBSEP variable offset.
    Built-in function that pushes a substring of the top-of-stack onto the stack.
    Numerically subtracts the top two elements of the stack with the result pushed onto the stack.
    Swaps the top two elements of the stack.
    Built-in function that executes the top-of-stack as a system command and pushes the return code onto the stack.
    Deprecated.
    Converts the top-of-stack to a number.
    Built-in function that converts all the letters in the top-of-stack to lower case and pushes the result onto the stack.
    Built-in function that converts all the letters in the top-of-stack to upper case and pushes the result onto the stack.
    Converts the top stack element to a number; pushes the result onto the stack.
    Obtains input from a command (process) and pushes input line and status code onto the stack.
    Obtains input from a file and pushes input line and status code onto the stack.
  • Method Summary

    Modifier and Type
    Method
    Description
    static Opcode
    fromId(int id)
     
    static Opcode
    Returns the enum constant of this type with the specified name.
    static Opcode[]
    Returns an array containing the constants of this enum type, in the order they are declared.

    Methods inherited from class java.lang.Enum

    compareTo, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • POP

      public static final Opcode POP
      Pops an item off the operand stack.

      Stack before: x ...
      Stack after: ...

    • PUSH

      public static final Opcode PUSH
      Pushes an item onto the operand stack.

      Stack before: ...
      Stack after: x ...

    • IFFALSE

      public static final Opcode IFFALSE
      Pops and evaluates the top-of-stack; if false, it jumps to a specified address.

      Argument: address

      Stack before: x ...
      Stack after: ...

    • TO_NUMBER

      public static final Opcode TO_NUMBER
      Converts the top-of-stack to a number.

      Stack before: x ...
      Stack after: x (as a number)

    • IFTRUE

      public static final Opcode IFTRUE
      Pops and evaluates the top-of-stack; if true, it jumps to a specified address.

      Argument: address

      Stack before: x ...
      Stack after: ...

    • GOTO

      public static final Opcode GOTO
      Jumps to a specified address. The operand stack contents are unaffected.
    • NOP

      public static final Opcode NOP
      A no-operation. The operand stack contents are unaffected.
    • PRINT

      public static final Opcode PRINT
      Prints N number of items that are on the operand stack. The number of items are passed in as a tuple argument.

      Argument: # of items (N)

      Stack before: x1 x2 x3 .. xN ...
      Stack after: ...

    • PRINTF

      public static final Opcode PRINTF
      Performs a formatted print of N items that are on the operand stack. The number of items are passed in as a tuple argument.

      Argument: # of items (N)

      Stack before: x1 x2 x3 .. xN ...
      Stack after: ...

    • PRINTF_TO_FILE

      public static final Opcode PRINTF_TO_FILE
      Performs a formatted print of N items that are on the operand stack to a specified file. The file is passed in on the stack. The number of items are passed in as a tuple argument, as well as whether to overwrite the file or not (append mode).

      Argument 1: # of items (N)
      Argument 2: true = append, false = overwrite

      Stack before: x1 x2 x3 .. xN filename ...
      Stack after: ...

    • PRINTF_TO_PIPE

      public static final Opcode PRINTF_TO_PIPE
      Performs a formatted print of N items that are on the operand stack to a process executing a specified command (via a pipe). The command string is passed in on the stack. The number of items are passed in as a tuple argument.

      Argument: # of items (N)

      Stack before: x1 x2 x3 .. xN command-string ...
      Stack after: ...

    • SPRINTF

      public static final Opcode SPRINTF
      Constant SPRINTF=270
    • LENGTH

      public static final Opcode LENGTH
      Depending on the argument, pop and evaluate the string length of the top-of-stack or evaluate the string length of $0; in either case, push the result onto the stack.

      The input field length evaluation mode is provided to support backward compatibility with the deprecated usage of length (i.e., no arguments).

      Argument: 0 to use $0, use top-of-stack otherwise

      If argument is 0:

      Stack before: ...
      Stack after: length-of-$0 ...
      else
      Stack before: x ...
      Stack after: length-of-x ...
    • CONCAT

      public static final Opcode CONCAT
      Pop and concatenate two strings from the top-of-stack; push the result onto the stack.

      Stack before: x y ...
      Stack after: x-concatenated-with-y ...

    • ASSIGN

      public static final Opcode ASSIGN
      Assigns the top-of-stack to a variable. The contents of the stack are unaffected.

      Argument 1: offset of the particular variable into the variable manager
      Argument 2: whether the variable is global or local

      Stack before: x ...
      Stack after: x ...

    • ASSIGN_ARRAY

      public static final Opcode ASSIGN_ARRAY
      Assigns an item to an array element. The item remains on the stack.

      Argument 1: offset of the particular associative array into the variable manager
      Argument 2: whether the associative array is global or local

      Stack before: index-into-array item ...
      Stack after: item ...

    • ASSIGN_AS_INPUT

      public static final Opcode ASSIGN_AS_INPUT
      Assigns the top-of-stack to $0. The contents of the stack are unaffected. Upon assignment, individual field variables are recalculated.

      Stack before: x ...
      Stack after: x ...

    • ASSIGN_AS_INPUT_FIELD

      public static final Opcode ASSIGN_AS_INPUT_FIELD
      Assigns an item as a particular input field; the field number can be 0. Upon assignment, associating input fields are affected. For example, if the following assignment were made:
       $3 = "hi"
       
      $0 would be recalculated. Likewise, if the following assignment were made:
       $0 = "hello there"
       
      $1, $2, ... would be recalculated.

      Stack before: field-num x ...
      Stack after: x ...

    • DEREFERENCE

      public static final Opcode DEREFERENCE
      Obtains an item from the variable manager and push it onto the stack.

      Argument 1: offset of the particular variable into the variable manager
      Argument 2: whether the variable is global or local

      Stack before: ...
      Stack after: x ...

    • PLUS_EQ

      public static final Opcode PLUS_EQ
      Increase the contents of the variable by an adjustment value; assigns the result to the variable and pushes the result onto the stack.

      Argument 1: offset of the particular variable into the variable manager
      Argument 2: whether the variable is global or local

      Stack before: n ...
      Stack after: x+n ...

    • MINUS_EQ

      public static final Opcode MINUS_EQ
      Decreases the contents of the variable by an adjustment value; assigns the result to the variable and pushes the result onto the stack.

      Argument 1: offset of the particular variable into the variable manager
      Argument 2: whether the variable is global or local

      Stack before: n ...
      Stack after: x-n ...

    • MULT_EQ

      public static final Opcode MULT_EQ
      Multiplies the contents of the variable by an adjustment value; assigns the result to the variable and pushes the result onto the stack.

      Argument 1: offset of the particular variable into the variable manager
      Argument 2: whether the variable is global or local

      Stack before: n ...
      Stack after: x*n ...

    • DIV_EQ

      public static final Opcode DIV_EQ
      Divides the contents of the variable by an adjustment value; assigns the result to the variable and pushes the result onto the stack.

      Argument 1: offset of the particular variable into the variable manager
      Argument 2: whether the variable is global or local

      Stack before: n ...
      Stack after: x/n ...

    • MOD_EQ

      public static final Opcode MOD_EQ
      Takes the modules of the contents of the variable by an adjustment value; assigns the result to the variable and pushes the result onto the stack.

      Argument 1: offset of the particular variable into the variable manager
      Argument 2: whether the variable is global or local

      Stack before: n ...
      Stack after: x%n ...

    • POW_EQ

      public static final Opcode POW_EQ
      Raises the contents of the variable to the power of the adjustment value; assigns the result to the variable and pushes the result onto the stack.

      Argument 1: offset of the particular variable into the variable manager
      Argument 2: whether the variable is global or local

      Stack before: n ...
      Stack after: x^n ...

    • PLUS_EQ_ARRAY

      public static final Opcode PLUS_EQ_ARRAY
      Increase the contents of an indexed array by an adjustment value; assigns the result to the array and pushes the result onto the stack.

      Argument 1: offset of the associative array into the variable manager
      Argument 2: whether the associative array is global or local

      Stack before: array-idx n ...
      Stack after: x+n ...

    • MINUS_EQ_ARRAY

      public static final Opcode MINUS_EQ_ARRAY
      Decreases the contents of an indexed array by an adjustment value; assigns the result to the array and pushes the result onto the stack.

      Argument 1: offset of the associative array into the variable manager
      Argument 2: whether the associative array is global or local

      Stack before: array-idx n ...
      Stack after: x-n ...

    • MULT_EQ_ARRAY

      public static final Opcode MULT_EQ_ARRAY
      Multiplies the contents of an indexed array by an adjustment value; assigns the result to the array and pushes the result onto the stack.

      Argument 1: offset of the associative array into the variable manager
      Argument 2: whether the associative array is global or local

      Stack before: array-idx n ...
      Stack after: x*n ...

    • DIV_EQ_ARRAY

      public static final Opcode DIV_EQ_ARRAY
      Divides the contents of an indexed array by an adjustment value; assigns the result to the array and pushes the result onto the stack.

      Argument 1: offset of the associative array into the variable manager
      Argument 2: whether the associative array is global or local

      Stack before: array-idx n ...
      Stack after: x/n ...

    • MOD_EQ_ARRAY

      public static final Opcode MOD_EQ_ARRAY
      Takes the modulus of the contents of an indexed array by an adjustment value; assigns the result to the array and pushes the result onto the stack.

      Argument 1: offset of the associative array into the variable manager
      Argument 2: whether the associative array is global or local

      Stack before: array-idx n ...
      Stack after: x%n ...

    • POW_EQ_ARRAY

      public static final Opcode POW_EQ_ARRAY
      Raises the contents of an indexed array to the power of an adjustment value; assigns the result to the array and pushes the result onto the stack.

      Argument 1: offset of the associative array into the variable manager
      Argument 2: whether the associative array is global or local

      Stack before: array-idx n ...
      Stack after: x^n ...

    • PLUS_EQ_INPUT_FIELD

      public static final Opcode PLUS_EQ_INPUT_FIELD
      Increases the contents of an input field by an adjustment value; assigns the result to the input field and pushes the result onto the stack.

      Stack before: input-field_number n ...
      Stack after: x+n ...

    • MINUS_EQ_INPUT_FIELD

      public static final Opcode MINUS_EQ_INPUT_FIELD
      Decreases the contents of an input field by an adjustment value; assigns the result to the input field and pushes the result onto the stack.

      Stack before: input-field_number n ...
      Stack after: x-n ...

    • MULT_EQ_INPUT_FIELD

      public static final Opcode MULT_EQ_INPUT_FIELD
      Multiplies the contents of an input field by an adjustment value; assigns the result to the input field and pushes the result onto the stack.

      Stack before: input-field_number n ...
      Stack after: x*n ...

    • DIV_EQ_INPUT_FIELD

      public static final Opcode DIV_EQ_INPUT_FIELD
      Divides the contents of an input field by an adjustment value; assigns the result to the input field and pushes the result onto the stack.

      Stack before: input-field_number n ...
      Stack after: x/n ...

    • MOD_EQ_INPUT_FIELD

      public static final Opcode MOD_EQ_INPUT_FIELD
      Takes the modulus of the contents of an input field by an adjustment value; assigns the result to the input field and pushes the result onto the stack.

      Stack before: input-field_number n ...
      Stack after: x%n ...

    • POW_EQ_INPUT_FIELD

      public static final Opcode POW_EQ_INPUT_FIELD
      Raises the contents of an input field to the power of an adjustment value; assigns the result to the input field and pushes the result onto the stack.

      Stack before: input-field_number n ...
      Stack after: x^n ...

    • SRAND

      public static final Opcode SRAND
      Seeds the random number generator. If there are no arguments, the current time (as a long value) is used as the seed. Otherwise, the top-of-stack is popped and used as the seed value.

      Argument: # of arguments

      If # of arguments is 0:

      Stack before: ...
      Stack after: old-seed ...
      else
      Stack before: x ...
      Stack after: old-seed ...
    • RAND

      public static final Opcode RAND
      Obtains the next random number from the random number generator and push it onto the stack.

      Stack before: ...
      Stack after: random-number ...

    • INTFUNC

      public static final Opcode INTFUNC
      Built-in function that pops the top-of-stack, removes its fractional part, if any, and places the result onto the stack.

      Stack before: x ...
      Stack after: (int)x ...

    • SQRT

      public static final Opcode SQRT
      Built-in function that pops the top-of-stack, takes its square root, and places the result onto the stack.

      Stack before: x ...
      Stack after: sqrt(x) ...

    • LOG

      public static final Opcode LOG
      Built-in function that pops the top-of-stack, calls the java.lang.Math.log method with the top-of-stack as the argument, and places the result onto the stack.

      Stack before: x ...
      Stack after: log(x) ...

    • EXP

      public static final Opcode EXP
      Built-in function that pops the top-of-stack, calls the java.lang.Math.exp method with the top-of-stack as the argument, and places the result onto the stack.

      Stack before: x ...
      Stack after: exp(x) ...

    • SIN

      public static final Opcode SIN
      Built-in function that pops the top-of-stack, calls the java.lang.Math.sin method with the top-of-stack as the argument, and places the result onto the stack.

      Stack before: x ...
      Stack after: sin(x) ...

    • COS

      public static final Opcode COS
      Built-in function that pops the top-of-stack, calls the java.lang.Math.cos method with the top-of-stack as the argument, and places the result onto the stack.

      Stack before: x ...
      Stack after: cos(x) ...

    • ATAN2

      public static final Opcode ATAN2
      Built-in function that pops the first two items off the stack, calls the java.lang.Math.atan2 method with these as arguments, and places the result onto the stack.

      Stack before: x1 x2 ...
      Stack after: atan2(x1,x2) ...

    • MATCH

      public static final Opcode MATCH
      Built-in function that searches a string as input to a regular expression, the location of the match is pushed onto the stack. The RSTART and RLENGTH variables are set as a side effect. If a match is found, RSTART and function return value are set to the location of the match and RLENGTH is set to the length of the substring matched against the regular expression. If no match is found, RSTART (and return value) is set to 0 and RLENGTH is set to -1.

      Stack before: string regexp ...
      Stack after: RSTART ...

    • INDEX

      public static final Opcode INDEX
      Built-in function that locates a substring within a source string and pushes the location onto the stack. If the substring is not found, 0 is pushed onto the stack.

      Stack before: string substring ...
      Stack after: location-index ...

    • SUB_FOR_DOLLAR_0

      public static final Opcode SUB_FOR_DOLLAR_0
      Built-in function that substitutes an occurrence (or all occurrences) of a string in $0 and replaces it with another.

      Argument: true if global sub, false otherwise.

      Stack before: regexp replacement-string ...
      Stack after: ...

    • SUB_FOR_DOLLAR_REFERENCE

      public static final Opcode SUB_FOR_DOLLAR_REFERENCE
      Built-in function that substitutes an occurrence (or all occurrences) of a string in a field reference and replaces it with another.

      Argument: true if global sub, false otherwise.

      Stack before: field-num regexp replacement-string ...
      Stack after: ...

    • SUB_FOR_VARIABLE

      public static final Opcode SUB_FOR_VARIABLE
      Built-in function that substitutes an occurrence (or all occurrences) of a string in a particular variable and replaces it with another.

      Argument 1: variable offset in variable manager
      Argument 2: is global variable
      Argument 3: is global sub

      Stack before: regexp replacement-string orig-string ...
      Stack after: ...

    • SUB_FOR_ARRAY_REFERENCE

      public static final Opcode SUB_FOR_ARRAY_REFERENCE
      Built-in function that substitutes an occurrence (or all occurrences) of a string in a particular array cell and replaces it with another.

      Argument 1: array map offset in variable manager
      Argument 2: is global array map
      Argument 3: is global sub

      Stack before: array-index regexp replacement-string orig-string ...
      Stack after: ...

    • SPLIT

      public static final Opcode SPLIT
      Built-in function to split a string by a regexp and put the components into an array.

      Argument: # of arguments (parameters on stack)

      If # of arguments is 2:

      Stack before: string array ...
      Stack after: n ...
      else
      Stack before: string array regexp ...
      Stack after: n ...
    • SUBSTR

      public static final Opcode SUBSTR
      Built-in function that pushes a substring of the top-of-stack onto the stack. The tuple argument indicates whether to limit the substring to a particular end position, or to take the substring up to the end-of-string.

      Argument: # of arguments

      If # of arguments is 2:

      Stack before: string start-pos ...
      Stack after: substring ...
      else
      Stack before: string start-pos end-pos ...
      Stack after: substring ...
    • TOLOWER

      public static final Opcode TOLOWER
      Built-in function that converts all the letters in the top-of-stack to lower case and pushes the result onto the stack.

      Stack before: STRING-ARGUMENT ...
      Stack after: string-argument ...

    • TOUPPER

      public static final Opcode TOUPPER
      Built-in function that converts all the letters in the top-of-stack to upper case and pushes the result onto the stack.

      Stack before: string-argument ...
      Stack after: STRING-ARGUMENT ...

    • SYSTEM

      public static final Opcode SYSTEM
      Built-in function that executes the top-of-stack as a system command and pushes the return code onto the stack.

      Stack before: cmd ...
      Stack after: return-code ...

    • SWAP

      public static final Opcode SWAP
      Swaps the top two elements of the stack.

      Stack before: x1 x2 ...
      Stack after: x2 x1 ...

    • ADD

      public static final Opcode ADD
      Numerically adds the top two elements of the stack with the result pushed onto the stack.

      Stack before: x1 x2 ...
      Stack after: x1+x2 ...

    • SUBTRACT

      public static final Opcode SUBTRACT
      Numerically subtracts the top two elements of the stack with the result pushed onto the stack.

      Stack before: x1 x2 ...
      Stack after: x1-x2 ...

    • MULTIPLY

      public static final Opcode MULTIPLY
      Numerically multiplies the top two elements of the stack with the result pushed onto the stack.

      Stack before: x1 x2 ...
      Stack after: x1*x2 ...

    • DIVIDE

      public static final Opcode DIVIDE
      Numerically divides the top two elements of the stack with the result pushed onto the stack.

      Stack before: x1 x2 ...
      Stack after: x1/x2 ...

    • MOD

      public static final Opcode MOD
      Numerically takes the modulus of the top two elements of the stack with the result pushed onto the stack.

      Stack before: x1 x2 ...
      Stack after: x1%x2 ...

    • POW

      public static final Opcode POW
      Numerically raises the top element to the power of the next element with the result pushed onto the stack.

      Stack before: x1 x2 ...
      Stack after: x1^x2 ...

    • INC

      public static final Opcode INC
      Increases the variable reference by one; pushes the result onto the stack.

      Argument 1: offset of the particular variable into the variable manager
      Argument 2: whether the variable is global or local

      Stack before: ...
      Stack after: x+1 ...

    • DEC

      public static final Opcode DEC
      Decreases the variable reference by one; pushes the result onto the stack.

      Argument 1: offset of the particular variable into the variable manager
      Argument 2: whether the variable is global or local

      Stack before: ...
      Stack after: x-1 ...

    • INC_ARRAY_REF

      public static final Opcode INC_ARRAY_REF
      Increases the array element reference by one; pushes the result onto the stack.

      Argument 1: offset of the associative array into the variable manager
      Argument 2: whether the associative array is global or local

      Stack before: array-idx ...
      Stack after: x+1 ...

    • DEC_ARRAY_REF

      public static final Opcode DEC_ARRAY_REF
      Decreases the array element reference by one; pushes the result onto the stack.

      Argument 1: offset of the associative array into the variable manager
      Argument 2: whether the associative array is global or local

      Stack before: array-idx ...
      Stack after: x-1 ...

    • INC_DOLLAR_REF

      public static final Opcode INC_DOLLAR_REF
      Increases the input field variable by one; pushes the result onto the stack.

      Stack before: field-idx ...
      Stack after: x+1

    • DEC_DOLLAR_REF

      public static final Opcode DEC_DOLLAR_REF
      Decreases the input field variable by one; pushes the result onto the stack.

      Stack before: field-idx ...
      Stack after: x-1

    • DUP

      public static final Opcode DUP
      Duplicates the top-of-stack on the stack.

      Stack before: x ...
      Stack after: x x ...

    • NOT

      public static final Opcode NOT
      Evaluates the logical NOT of the top stack element; pushes the result onto the stack.

      Stack before: x ...
      Stack after: !x ...

    • NEGATE

      public static final Opcode NEGATE
      Evaluates the numerical NEGATION of the top stack element; pushes the result onto the stack.

      Stack before: x ...
      Stack after: -x ...

    • CMP_EQ

      public static final Opcode CMP_EQ
      Compares the top two stack elements; pushes 1 onto the stack if equal, 0 if not equal.

      Stack before: x1 x2 ...
      Stack after: x1==x2

    • CMP_LT

      public static final Opcode CMP_LT
      Compares the top two stack elements; pushes 1 onto the stack if x1 < x2, 0 if not equal.

      Stack before: x1 x2 ...
      Stack after: x1<x2

    • CMP_GT

      public static final Opcode CMP_GT
      Compares the top two stack elements; pushes 1 onto the stack if x1 > x2, 0 if not equal.

      Stack before: x1 x2 ...
      Stack after: x1>x2

    • MATCHES

      public static final Opcode MATCHES
      Applies a regular expression to the top stack element; pushes 1 if it matches, 0 if it does not match.

      Stack before: x1 x2 ...
      Stack after: (x1 ~ /x2/) ...

    • DEREF_ARRAY

      public static final Opcode DEREF_ARRAY
      Constant DEREF_ARRAY=336
    • KEYLIST

      public static final Opcode KEYLIST
      Retrieves and pushes a set of keys from an associative array onto the stack. The set is stored in a Deque for iteration.

      Stack before: associative-array ...
      Stack after: key-list-set ...

    • IS_EMPTY_KEYLIST

      public static final Opcode IS_EMPTY_KEYLIST
      Tests whether the key list (deque) is empty; jumps to the argument address if empty, steps to the next instruction if not.

      Argument: jump-address-if-empty

      Stack before: key-list ...
      Stack after: ...

    • GET_FIRST_AND_REMOVE_FROM_KEYLIST

      public static final Opcode GET_FIRST_AND_REMOVE_FROM_KEYLIST
      Removes an item from the key list (deque) and pushes it onto the operand stack.

      Stack before: key-list ...
      Stack after: 1st-item ...

    • CHECK_CLASS

      public static final Opcode CHECK_CLASS
      Checks whether the top-of-stack is of a particular class type; if not, an AwkRuntimeException is thrown. The stack remains unchanged upon a successful check.

      Argument: class-type (i.e., java.util.Deque.class)

      Stack before: obj ...
      Stack after: obj ...

    • GET_INPUT_FIELD

      public static final Opcode GET_INPUT_FIELD
      Push an input field onto the stack.

      Stack before: field-id ...
      Stack after: x ...

    • CONSUME_INPUT

      public static final Opcode CONSUME_INPUT
      Consume next line of input; assigning $0 and recalculating $1, $2, etc. The input can come from the following sources:
      • stdin
      • filename arguments
      The operand stack is unaffected.
    • GETLINE_INPUT

      public static final Opcode GETLINE_INPUT
      Obtains input from stdin/filename-args and pushes input line and status code onto the stack. The input is partitioned into records based on the RS variable assignment as a regular expression.

      If there is input available, the input string and a return code of 1 is pushed. If EOF is reached, a blank (null) string ("") is pushed along with a 0 return code. Upon an IO error, a blank string and a -1 is pushed onto the operand stack.

      Stack before: ...
      Stack after: input-string return-code ...

    • USE_AS_FILE_INPUT

      public static final Opcode USE_AS_FILE_INPUT
      Obtains input from a file and pushes input line and status code onto the stack. The input is partitioned into records based on the RS variable assignment as a regular expression.

      Upon initial execution, the file is opened and the handle is maintained until it is explicitly closed, or until the VM exits. Subsequent calls will obtain subsequent lines (records) of input until no more records are available.

      If there is input available, the input string and a return code of 1 is pushed. If EOF is reached, a blank (null) string ("") is pushed along with a 0 return code. Upon an IO error, a blank string and a -1 is pushed onto the operand stack.

      Stack before: filename ...
      Stack after: input-string return-code ...

    • USE_AS_COMMAND_INPUT

      public static final Opcode USE_AS_COMMAND_INPUT
      Obtains input from a command (process) and pushes input line and status code onto the stack. The input is partitioned into records based on the RS variable assignment as a regular expression.

      Upon initial execution, the a process is spawned to execute the specified command and the process reference is maintained until it is explicitly closed, or until the VM exits. Subsequent calls will obtain subsequent lines (records) of input until no more records are available.

      If there is input available, the input string and a return code of 1 is pushed. If EOF is reached, a blank (null) string ("") is pushed along with a 0 return code. Upon an IO error, a blank string and a -1 is pushed onto the operand stack.

      Stack before: command-line ...
      Stack after: input-string return-code ...

    • NF_OFFSET

      public static final Opcode NF_OFFSET
      Assign the NF variable offset. This is important for the AVM to set the variables as new input lines are processed.

      The operand stack is unaffected.

    • NR_OFFSET

      public static final Opcode NR_OFFSET
      Assign the NR variable offset. This is important for the AVM to increase the record number as new input lines received.

      The operand stack is unaffected.

    • FNR_OFFSET

      public static final Opcode FNR_OFFSET
      Assign the FNR variable offset. This is important for the AVM to increase the "file" record number as new input lines are received.

      The operand stack is unaffected.

    • FS_OFFSET

      public static final Opcode FS_OFFSET
      Assign the FS variable offset. This is important for the AVM to know how to split fields upon incoming records of input.

      The operand stack is unaffected.

    • RS_OFFSET

      public static final Opcode RS_OFFSET
      Assign the RS variable offset. This is important for the AVM to know how to create records from the stream(s) of input.

      The operand stack is unaffected.

    • OFS_OFFSET

      public static final Opcode OFS_OFFSET
      Assign the OFS variable offset. This is important for the AVM to use when outputting expressions via PRINT.

      The operand stack is unaffected.

    • RSTART_OFFSET

      public static final Opcode RSTART_OFFSET
      Assign the RSTART variable offset. The AVM sets this variable while executing the match() builtin function.

      The operand stack is unaffected.

    • RLENGTH_OFFSET

      public static final Opcode RLENGTH_OFFSET
      Assign the RLENGTH variable offset. The AVM sets this variable while executing the match() builtin function.

      The operand stack is unaffected.

    • FILENAME_OFFSET

      public static final Opcode FILENAME_OFFSET
      Assign the FILENAME variable offset. The AVM sets this variable while processing files from the command-line for input.

      The operand stack is unaffected.

    • SUBSEP_OFFSET

      public static final Opcode SUBSEP_OFFSET
      Assign the SUBSEP variable offset. The AVM uses this variable while building an index of a multi-dimensional array.

      The operand stack is unaffected.

    • CONVFMT_OFFSET

      public static final Opcode CONVFMT_OFFSET
      Assign the CONVFMT variable offset. The AVM uses this variable while converting numbers to strings.

      The operand stack is unaffected.

    • OFMT_OFFSET

      public static final Opcode OFMT_OFFSET
      Assign the OFMT variable offset. The AVM uses this variable while converting numbers to strings for printing.

      The operand stack is unaffected.

    • ENVIRON_OFFSET

      public static final Opcode ENVIRON_OFFSET
      Assign the ENVIRON variable offset. The AVM provides environment variables through this array.

      The operand stack is unaffected.

    • ARGC_OFFSET

      public static final Opcode ARGC_OFFSET
      Assign the ARGC variable offset. The AVM provides the number of arguments via this variable.

      The operand stack is unaffected.

    • ARGV_OFFSET

      public static final Opcode ARGV_OFFSET
      Assign the ARGV variable offset. The AVM provides command-line arguments via this variable.

      The operand stack is unaffected.

    • APPLY_RS

      public static final Opcode APPLY_RS
      Apply the RS variable by notifying the partitioning reader that there is a new regular expression to use when partitioning input records.

      The stack remains unaffected.

    • CALL_FUNCTION

      public static final Opcode CALL_FUNCTION
      Call a user function.

      Stack before: x1, x2, ..., xn
      Stack after: f(x1, x2, ..., xn)

    • FUNCTION

      public static final Opcode FUNCTION
      Define a user function.

      Stack remains unchanged

    • SET_RETURN_RESULT

      public static final Opcode SET_RETURN_RESULT
      Sets the return value of a user function.

      Stack before: x
      Stack after: ...

    • RETURN_FROM_FUNCTION

      public static final Opcode RETURN_FROM_FUNCTION
      Get the return value of the user function that was called

      Stack before: ...
      Stack after: x

    • SET_NUM_GLOBALS

      public static final Opcode SET_NUM_GLOBALS
      Internal: sets the number of global variables
    • CLOSE

      public static final Opcode CLOSE
      Close the specified file.

      Stack before: file name
      Stack after: result of the close operation

    • APPLY_SUBSEP

      public static final Opcode APPLY_SUBSEP
      Convert a list of array indices to a concatenated string with SUBSEP. This is used for multidimensional arrays.

      Stack before: i1, i2, ..., in
      Stack after: "i1SUBSEPi2SUBSEP...in"

    • DELETE_ARRAY_ELEMENT

      public static final Opcode DELETE_ARRAY_ELEMENT
      Deletes an entry in an array.

      Stack before: i
      Stack after: ...

    • SET_EXIT_ADDRESS

      public static final Opcode SET_EXIT_ADDRESS
      Internal.

      Stack remains unchanged.

    • SET_WITHIN_END_BLOCKS

      public static final Opcode SET_WITHIN_END_BLOCKS
      Internal.

      Stack remains unchanged.

    • EXIT_WITH_CODE

      public static final Opcode EXIT_WITH_CODE
      Terminates execution and returns specified exit code.

      Stack before: integer
      Stack after: N/A

    • REGEXP

      public static final Opcode REGEXP
      Returns a regex pattern.

      Stack before: ...
      Stack after: the regex pattern object

    • CONDITION_PAIR

      public static final Opcode CONDITION_PAIR
      Returns a pair of regex patterns.

      Stack before: pattern1, pattern2
      Stack after: regex pair object

    • IS_IN

      public static final Opcode IS_IN
      Returns whether the specified key is in the array.

      Stack before: key, array
      Stack after: true|false

    • THIS

      public static final Opcode THIS
      Deprecated.
    • EXTENSION

      public static final Opcode EXTENSION
      Call a function from an extension

      Stack before: x1, x2, ..., xn
      Stack after: f(x1, x2, ..., xn)

    • EXEC

      public static final Opcode EXEC
      Execute the specified AWK code

      Stack before: script
      Stack after: exit code of the script, or zero when successful, -1 when failed

    • DELETE_ARRAY

      public static final Opcode DELETE_ARRAY
      Delete the specified array.

      Stack remains unchanged.

    • UNARY_PLUS

      public static final Opcode UNARY_PLUS
      Converts the top stack element to a number; pushes the result onto the stack.

      Stack before: x ...
      Stack after: x ... (as a number)

    • EXIT_WITHOUT_CODE

      public static final Opcode EXIT_WITHOUT_CODE
      Terminates execution without specifying an exit code.

      Stack before: N/A
      Stack after: N/A

    • ORS_OFFSET

      public static final Opcode ORS_OFFSET
      Assign the ORS variable offset. This is important for the AVM to use when outputting expressions via PRINT.

      The operand stack is unaffected.

    • POSTINC

      public static final Opcode POSTINC
      Increases the variable reference by one; pushes the original value onto the stack.

      Argument 1: offset of the particular variable into the variable manager
      Argument 2: whether the variable is global or local

      Stack before: ...
      Stack after: x ... or 0 if uninitialized

    • POSTDEC

      public static final Opcode POSTDEC
      Decreases the variable reference by one; pushes the original value onto the stack.

      Argument 1: offset of the particular variable into the variable manager
      Argument 2: whether the variable is global or local

      Stack before: ...
      Stack after: x ... or 0 if uninitialized

    • SET_INPUT_FOR_EVAL

      public static final Opcode SET_INPUT_FOR_EVAL
      Read stdin for simple AWK expression evaluation.

      Stack before: ...
      Stack after: ...

  • Method Details

    • values

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

      public static Opcode valueOf(String name)
      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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 type has no constant with the specified name
      NullPointerException - if the argument is null
    • fromId

      public static Opcode fromId(int id)