Class AwkTuples

java.lang.Object
io.jawk.intermediate.AwkTuples
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
AwkExpression, AwkProgram, SandboxedAwkTuples

public class AwkTuples extends Object implements Serializable

AwkTuples class.

Author:
Danny Daglas
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates an empty tuple list, ready for the front end to append to.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add()
    add.
    void
    addGlobalVariableNameToOffsetMapping(String varname, int offset, boolean isArray)
    Accept a {variable_name -> offset} mapping such that global variables can be assigned while processing name=value and filename command-line arguments.
    address(Address address)
    address.
    void
    applyRS.
    void
    applySubsep(int count)
    applySubsep.
    void
    applySubsepUnderTop.
    void
    argcOffset(int offset)
    argcOffset.
    void
    argvOffset(int offset)
    argvOffset.
    void
    assign(int offset, boolean isGlobal)
    assign.
    void
    Assigns the top-of-stack value to ARGC.
    void
    Emits the tuple assigning the top of the stack to ARGIND, managed by the JRT.
    void
    assignArray(int offset, boolean isGlobal)
    assignArray.
    void
    assignAsInput.
    void
    assignAsInputField.
    void
    Assigns the top-of-stack value to CONVFMT.
    void
    Emits the tuple assigning the top of the stack to ERRNO, managed by the JRT.
    void
    Assigns the top-of-stack value to FILENAME.
    void
    Assigns the top-of-stack value to FNR.
    void
    Assigns the top-of-stack value to FS.
    void
    Emits a tuple assigning the top of the stack to IGNORECASE.
    void
    Assigns a value to a stack-provided associative-array element.
    void
    Assigns the top-of-stack value to NF.
    void
    Assigns the top-of-stack value to NR.
    void
    Assigns the top-of-stack value to OFMT.
    void
    Assigns the top-of-stack value to OFS.
    void
    Assigns the top-of-stack value to ORS.
    void
    Assigns the top-of-stack value to RLENGTH.
    void
    Assigns the top-of-stack value to RS.
    void
    Assigns the top-of-stack value to RSTART.
    void
    Assigns the top-of-stack value to SUBSEP.
    void
    atan2.
    void
    Emits the tuple that runs the extension beforeStart hooks, placed at the end of the preamble.
    void
    callFunction(Supplier<Address> addressSupplier, String funcName, int numFormalParams, int numActualParams)
    callFunction.
    boolean
    checkClass(Class<?> cls)
    checkClass.
    void
    close.
    void
    cmpEq.
    void
    cmpGt.
    void
    cmpLt.
    void
    concat.
    void
    Deprecated.
    Evaluates both range conditions on every record, which is incorrect when the conditions have side effects.
    void
    Marks the specified range pattern as active, after its start condition matched the current record.
    void
    Pushes whether the specified range pattern is currently active, i.e. its start condition matched a previous record and its end condition hasn't matched yet.
    void
    Marks the specified range pattern as inactive, after its end condition matched the current record.
    void
    Emits the tuple consuming one record of the current input file only, jumping to the given address at end of the current file.
    void
    consumeInput.
    void
    convfmtOffset(int offset)
    convfmtOffset.
    void
    cos()
    cos.
    createAddress.
    void
    dec(int offset, boolean isGlobal)
    dec.
    void
    decArrayRef(int offset, boolean isGlobal)
    decArrayRef.
    void
    decDollarRef.
    void
    Decrements a stack-provided associative-array element reference.
    void
    deleteArray(int offset, boolean isGlobal)
    deleteArray.
    void
    deleteArrayElement(int offset, boolean isGlobal)
    deleteArrayElement.
    void
    Deletes a stack-provided associative-array element.
    void
    dereference(int offset, boolean isArray, boolean isGlobal)
    dereference.
    void
    dereferenceArray.
    void
    divEq(int offset, boolean isGlobal)
    divEq.
    void
    divEqArray(int offset, boolean isGlobal)
    divEqArray.
    void
    divEqInputField.
    void
    Applies /= to a stack-provided associative-array element.
    void
    divide.
    void
    Dumps the queued tuples to the provided PrintStream.
    void
    dup()
    dup.
    void
    Dereferences an associative-array element as a nested array, creating it if needed.
    void
    environOffset(int offset)
    environOffset.
    void
    Emits the tuple executing the next statement at runtime, for uses inside user-defined functions, where the calling rule cannot be known statically.
    void
    Emits the tuple executing the nextfile statement at runtime.
    void
    exitWithCode.
    void
    exitWithCode.
    void
    exp()
    exp.
    void
    extension(ExtensionFunction function, int paramCount)
    Emits an extension invocation tuple.
    void
    filenameOffset(int offset)
    filenameOffset.
    void
    fnrOffset(int offset)
    fnrOffset.
    void
    Freezes the tuple metadata after compilation so execution can reuse the published maps and sets without creating fresh unmodifiable wrappers.
    void
    fsOffset(int offset)
    fsOffset.
    void
    function(String funcName, int numFormalParams)
    function.
    Returns the address of the ENDFILE section, or null when the program has no BEGINFILE/ENDFILE rules.
    Returns the address of the END blocks section, or null when the tuple stream is an expression stream with no END blocks.
    void
    getFirstAndRemoveFromList.
    getFunctionNameSet.
    getGlobalVariableAarrayMap.
    getGlobalVariableOffsetMap.
    void
    getInputField.
    void
    getInputField(long fieldIndex)
    getInputField.
    void
    getlineInput.
    void
    getlineInputToTarget(Address noRecordAddress)
    Reads one record of the main input for getline target without touching the current record.
    Returns the address of the main input loop's next-record entry point, or null when the program has no main input loop.
    Returns the address of the NEXT_FILE tuple that opens each input file, or null when the program does not use per-file input stepping.
    Returns the description of the primary script source.
    void
    gotoAddress.
    void
    ifFalse(Address address)
    ifFalse.
    void
    ifTrue(Address address)
    ifTrue.
    void
    inc(int offset, boolean isGlobal)
    inc.
    void
    incArrayRef(int offset, boolean isGlobal)
    incArrayRef.
    void
    incDollarRef.
    void
    Increments a stack-provided associative-array element reference.
    void
    index.
    void
    indirectCall(Map<String,Tuple.IndirectFunctionTarget> userFunctions, Map<String,ExtensionFunction> extensionFunctions, int numActualParams, String sourceName, int lineNumber)
    Emits a call whose function name is evaluated at runtime.
    void
    intFunc.
    void
    isEmptyList.
    void
    isIn.
    void
    key list.
    void
    length(int numExprs)
    length.
    void
    log()
    log.
    void
    Marks this tuple stream as an expression-eval program rather than a full AWK script.
    void
    match.
    void
    matches.
    void
    minusEq(int offset, boolean isGlobal)
    minusEq.
    void
    minusEqArray(int offset, boolean isGlobal)
    minusEqArray.
    void
    minusEqInputField.
    void
    Applies -= to a stack-provided associative-array element.
    void
    mod()
    mod.
    void
    modEq(int offset, boolean isGlobal)
    modEq.
    void
    modEqArray(int offset, boolean isGlobal)
    modEqArray.
    void
    modEqInputField.
    void
    Applies %= to a stack-provided associative-array element.
    void
    multEq(int offset, boolean isGlobal)
    multEq.
    void
    multEqArray(int offset, boolean isGlobal)
    multEqArray.
    void
    multEqInputField.
    void
    Applies *= to a stack-provided associative-array element.
    void
    multiply.
    void
    negate.
    void
    nextFile(Address address)
    Emits the tuple advancing the main input to the next input file, or jumping to the given address when no input file remains.
    void
    nfOffset(int offset)
    nfOffset.
    void
    nop()
    nop.
    void
    not()
    not.
    void
    nrOffset(int offset)
    nrOffset.
    void
    ofmtOffset(int offset)
    ofmtOffset.
    void
    ofsOffset(int offset)
    ofsOffset.
    void
    Performs tuple queue optimizations such as reachability pruning, redundant eval-global setup removal, and NOP collapsing.
    void
    orsOffset(int offset)
    orsOffset.
    void
    Looks up an associative-array element without creating a blank entry when the key is missing.
    void
    peekDereference(int offset, boolean isGlobal)
    Emits a variable read that does not assign a blank value when the variable is still untyped.
    void
    plusEq(int offset, boolean isGlobal)
    plusEq.
    void
    plusEqArray(int offset, boolean isGlobal)
    plusEqArray.
    void
    plusEqInputField.
    void
    Applies += to a stack-provided associative-array element.
    void
    pop()
    pop.
    void
    Discards a value that was evaluated in scalar context.
    void
    popSourceLineNumber(int lineno)
    popSourceLineNumber.
    void
    postDec(int offset, boolean isGlobal)
    postDec.
    void
    postInc(int offset, boolean isGlobal)
    postInc.
    void
    Executed after all tuples are entered in the queue.
    void
    pow()
    pow.
    void
    powEq(int offset, boolean isGlobal)
    powEq.
    void
    powEqArray(int offset, boolean isGlobal)
    powEqArray.
    void
    powEqInputField.
    void
    Applies exponentiation assignment to a stack-provided associative-array element.
    void
    print(int numExprs)
    print.
    void
    printf(int numExprs)
    printf.
    void
    printfToFile(int numExprs, boolean append)
    printfToFile.
    void
    printfToPipe(int numExprs)
    printfToPipe.
    void
    printToFile(int numExprs, boolean append)
    printToFile.
    void
    printToPipe(int numExprs)
    printToPipe.
    void
    push.
    void
    Pushes the current value of ARGC onto the operand stack.
    void
    Emits the tuple pushing the value of ARGIND, managed by the JRT.
    void
    Pushes the current value of CONVFMT onto the operand stack.
    void
    Emits the tuple pushing the value of ERRNO, managed by the JRT.
    void
    Pushes the current value of FILENAME onto the operand stack.
    void
    Pushes the current value of FNR onto the operand stack.
    void
    Pushes the current value of FS onto the operand stack.
    void
    Emits a tuple pushing the value of IGNORECASE.
    void
    pushIndirectArgument(int offset, boolean isGlobal)
    Emits a variable reference whose scalar value is captured immediately while retaining the variable location for a runtime-selected array parameter.
    void
    Emits an indirect-call subarray argument after its containing map and key.
    void
    Pushes the current value of NF onto the operand stack.
    void
    Pushes the current value of NR onto the operand stack.
    void
    Pushes the current value of OFMT onto the operand stack.
    void
    Pushes the current value of OFS onto the operand stack.
    void
    Pushes the current value of ORS onto the operand stack.
    void
    Pushes the current value of RLENGTH onto the operand stack.
    void
    Pushes the current value of RS onto the operand stack.
    void
    Pushes the current value of RSTART onto the operand stack.
    void
    Push the current line number onto the line number stack.
    void
    Pushes the current value of SUBSEP onto the operand stack.
    void
    rand.
    void
    regexp(String regexpStr)
    regexp.
    void
    returnFromFunction.
    void
    rlengthOffset(int offset)
    rlengthOffset.
    void
    rsOffset(int offset)
    rsOffset.
    void
    rstartOffset(int offset)
    rstartOffset.
    void
    Emits a tuple that pushes the current script context onto the stack.
    void
    Registers the address of the ENDFILE section, so that a runtime nextfile statement can jump to it.
    void
    Registers the address of the END blocks section, so that a runtime exit statement can jump to it.
    void
    Accept a set of function names from the parser.
    void
    Registers the address of the main input loop's next-record entry point, so that a runtime next statement executed from a user-defined function can resume the loop there.
    void
    Registers the address of the NEXT_FILE tuple that opens each input file, so that a runtime nextfile statement can bypass the ENDFILE rules for input files that could not be opened.
    void
    setNumGlobals(int numGlobals)
    setNumGlobals.
    void
    setReturnResult.
    void
    setSourceDescription(String sourceDescriptionParam)
    Records the description of the primary script source (typically its file name) so runtime diagnostics can point at it.
    void
    setWithinEndBlocks(boolean b)
    setWithinEndBlocks.
    void
    sin()
    sin.
    void
    split(int numargs)
    split.
    void
    sprintf(int numExprs)
    sprintf.
    void
    sqrt.
    void
    srand(int num)
    srand.
    void
    subForArrayReference(int offset, boolean isGlobal, boolean isGsub)
    subForArrayReference.
    void
    subForDollar0(boolean isGsub)
    subForDollar0.
    void
    subForDollarReference(boolean isGsub)
    subForDollarReference.
    void
    subForMapReference(boolean isGsub)
    Applies sub/gsub to a stack-provided associative-array element.
    void
    subForVariable(int offset, boolean isGlobal, boolean isGsub)
    subForVariable.
    void
    subsepOffset(int offset)
    subsepOffset.
    void
    substr(int numargs)
    substr.
    void
    subtract.
    void
    swap.
    void
    system.
    void
    tolower.
    void
    toNumber.
    static String
    toOpcodeString(int opcode)
    toOpcodeString.
    top()
    top.
    void
    toupper.
    void
    unary plus.
    void
    updateFunctab(int offset)
    Emits the tuple populating the FUNCTAB array.
    void
    updateSymtab(int offset)
    Emits the tuple populating the SYMTAB array.
    void
    useAsCommandInput(Address noRecordAddress)
    Reads one record from the output of a command for a redirected getline.
    void
    useAsFileInput(Address noRecordAddress)
    Reads one record from a file for a redirected getline.
    void
    warning(String message)
    Emits a tuple that prints a diagnostic message to the warning stream when executed.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AwkTuples

      public AwkTuples()
      Creates an empty tuple list, ready for the front end to append to.
  • Method Details

    • setSourceDescription

      public void setSourceDescription(String sourceDescriptionParam)
      Records the description of the primary script source (typically its file name) so runtime diagnostics can point at it.
      Parameters:
      sourceDescriptionParam - script source description
    • getSourceDescription

      public String getSourceDescription()
      Returns the description of the primary script source.
      Returns:
      script source description, or null when unknown
    • toOpcodeString

      public static String toOpcodeString(int opcode)

      toOpcodeString.

      Parameters:
      opcode - a int
      Returns:
      a String object
    • pop

      public void pop()

      pop.

    • popScalar

      public void popScalar()
      Discards a value that was evaluated in scalar context.
    • push

      public void push(Object o)

      push.

      Parameters:
      o - a Object object
    • ifFalse

      public void ifFalse(Address address)

      ifFalse.

      Parameters:
      address - a Address object
    • toNumber

      public void toNumber()

      toNumber.

    • ifTrue

      public void ifTrue(Address address)

      ifTrue.

      Parameters:
      address - a Address object
    • gotoAddress

      public void gotoAddress(Address address)

      gotoAddress.

      Parameters:
      address - a Address object
    • createAddress

      public Address createAddress(String label)

      createAddress.

      Parameters:
      label - a String object
      Returns:
      a Address object
    • address

      public AwkTuples address(Address address)

      address.

      Parameters:
      address - a Address object
      Returns:
      a AwkTuples object
    • nop

      public void nop()

      nop.

    • print

      public void print(int numExprs)

      print.

      Parameters:
      numExprs - a int
    • printToFile

      public void printToFile(int numExprs, boolean append)

      printToFile.

      Parameters:
      numExprs - a int
      append - a boolean
    • printToPipe

      public void printToPipe(int numExprs)

      printToPipe.

      Parameters:
      numExprs - a int
    • printf

      public void printf(int numExprs)

      printf.

      Parameters:
      numExprs - a int
    • printfToFile

      public void printfToFile(int numExprs, boolean append)

      printfToFile.

      Parameters:
      numExprs - a int
      append - a boolean
    • printfToPipe

      public void printfToPipe(int numExprs)

      printfToPipe.

      Parameters:
      numExprs - a int
    • sprintf

      public void sprintf(int numExprs)

      sprintf.

      Parameters:
      numExprs - a int
    • length

      public void length(int numExprs)

      length.

      Parameters:
      numExprs - a int
    • concat

      public void concat()

      concat.

    • assign

      public void assign(int offset, boolean isGlobal)

      assign.

      Parameters:
      offset - a int
      isGlobal - a boolean
    • assignArray

      public void assignArray(int offset, boolean isGlobal)

      assignArray.

      Parameters:
      offset - a int
      isGlobal - a boolean
    • assignMapElement

      public void assignMapElement()
      Assigns a value to a stack-provided associative-array element.
    • assignAsInput

      public void assignAsInput()

      assignAsInput.

    • markEvalTupleStream

      public void markEvalTupleStream()
      Marks this tuple stream as an expression-eval program rather than a full AWK script. Eval tuple streams can use small tuple-level optimizations that are unsafe for the general case.
    • assignAsInputField

      public void assignAsInputField()

      assignAsInputField.

    • dereference

      public void dereference(int offset, boolean isArray, boolean isGlobal)

      dereference.

      Parameters:
      offset - a int
      isArray - a boolean
      isGlobal - a boolean
    • peekDereference

      public void peekDereference(int offset, boolean isGlobal)
      Emits a variable read that does not assign a blank value when the variable is still untyped.

      This is used by extension functions such as gawk's typeof() that need the current lvalue state, not AWK's normal scalar autovivification side effect.

      Parameters:
      offset - variable offset
      isGlobal - whether the variable is global
    • pushIndirectArgument

      public void pushIndirectArgument(int offset, boolean isGlobal)
      Emits a variable reference whose scalar value is captured immediately while retaining the variable location for a runtime-selected array parameter.
      Parameters:
      offset - variable offset
      isGlobal - whether the variable is global
    • pushIndirectArrayArgument

      public void pushIndirectArrayArgument()
      Emits an indirect-call subarray argument after its containing map and key.
    • plusEq

      public void plusEq(int offset, boolean isGlobal)

      plusEq.

      Parameters:
      offset - a int
      isGlobal - a boolean
    • minusEq

      public void minusEq(int offset, boolean isGlobal)

      minusEq.

      Parameters:
      offset - a int
      isGlobal - a boolean
    • multEq

      public void multEq(int offset, boolean isGlobal)

      multEq.

      Parameters:
      offset - a int
      isGlobal - a boolean
    • divEq

      public void divEq(int offset, boolean isGlobal)

      divEq.

      Parameters:
      offset - a int
      isGlobal - a boolean
    • modEq

      public void modEq(int offset, boolean isGlobal)

      modEq.

      Parameters:
      offset - a int
      isGlobal - a boolean
    • powEq

      public void powEq(int offset, boolean isGlobal)

      powEq.

      Parameters:
      offset - a int
      isGlobal - a boolean
    • plusEqArray

      public void plusEqArray(int offset, boolean isGlobal)

      plusEqArray.

      Parameters:
      offset - a int
      isGlobal - a boolean
    • plusEqMapElement

      public void plusEqMapElement()
      Applies += to a stack-provided associative-array element.
    • minusEqArray

      public void minusEqArray(int offset, boolean isGlobal)

      minusEqArray.

      Parameters:
      offset - a int
      isGlobal - a boolean
    • minusEqMapElement

      public void minusEqMapElement()
      Applies -= to a stack-provided associative-array element.
    • multEqArray

      public void multEqArray(int offset, boolean isGlobal)

      multEqArray.

      Parameters:
      offset - a int
      isGlobal - a boolean
    • multEqMapElement

      public void multEqMapElement()
      Applies *= to a stack-provided associative-array element.
    • divEqArray

      public void divEqArray(int offset, boolean isGlobal)

      divEqArray.

      Parameters:
      offset - a int
      isGlobal - a boolean
    • divEqMapElement

      public void divEqMapElement()
      Applies /= to a stack-provided associative-array element.
    • modEqArray

      public void modEqArray(int offset, boolean isGlobal)

      modEqArray.

      Parameters:
      offset - a int
      isGlobal - a boolean
    • modEqMapElement

      public void modEqMapElement()
      Applies %= to a stack-provided associative-array element.
    • powEqArray

      public void powEqArray(int offset, boolean isGlobal)

      powEqArray.

      Parameters:
      offset - a int
      isGlobal - a boolean
    • powEqMapElement

      public void powEqMapElement()
      Applies exponentiation assignment to a stack-provided associative-array element.
    • plusEqInputField

      public void plusEqInputField()

      plusEqInputField.

    • minusEqInputField

      public void minusEqInputField()

      minusEqInputField.

    • multEqInputField

      public void multEqInputField()

      multEqInputField.

    • divEqInputField

      public void divEqInputField()

      divEqInputField.

    • modEqInputField

      public void modEqInputField()

      modEqInputField.

    • powEqInputField

      public void powEqInputField()

      powEqInputField.

    • srand

      public void srand(int num)

      srand.

      Parameters:
      num - a int
    • rand

      public void rand()

      rand.

    • intFunc

      public void intFunc()

      intFunc.

    • sqrt

      public void sqrt()

      sqrt.

    • log

      public void log()

      log.

    • exp

      public void exp()

      exp.

    • sin

      public void sin()

      sin.

    • cos

      public void cos()

      cos.

    • atan2

      public void atan2()

      atan2.

    • match

      public void match()

      match.

    • index

      public void index()

      index.

    • subForDollar0

      public void subForDollar0(boolean isGsub)

      subForDollar0.

      Parameters:
      isGsub - a boolean
    • subForDollarReference

      public void subForDollarReference(boolean isGsub)

      subForDollarReference.

      Parameters:
      isGsub - a boolean
    • subForVariable

      public void subForVariable(int offset, boolean isGlobal, boolean isGsub)

      subForVariable.

      Parameters:
      offset - a int
      isGlobal - a boolean
      isGsub - a boolean
    • subForArrayReference

      public void subForArrayReference(int offset, boolean isGlobal, boolean isGsub)

      subForArrayReference.

      Parameters:
      offset - a int
      isGlobal - a boolean
      isGsub - a boolean
    • subForMapReference

      public void subForMapReference(boolean isGsub)
      Applies sub/gsub to a stack-provided associative-array element.
      Parameters:
      isGsub - true for gsub, false for sub
    • split

      public void split(int numargs)

      split.

      Parameters:
      numargs - a int
    • substr

      public void substr(int numargs)

      substr.

      Parameters:
      numargs - a int
    • tolower

      public void tolower()

      tolower.

    • toupper

      public void toupper()

      toupper.

    • system

      public void system()

      system.

    • swap

      public void swap()

      swap.

    • add

      public void add()

      add.

    • subtract

      public void subtract()

      subtract.

    • multiply

      public void multiply()

      multiply.

    • divide

      public void divide()

      divide.

    • mod

      public void mod()

      mod.

    • pow

      public void pow()

      pow.

    • inc

      public void inc(int offset, boolean isGlobal)

      inc.

      Parameters:
      offset - a int
      isGlobal - a boolean
    • dec

      public void dec(int offset, boolean isGlobal)

      dec.

      Parameters:
      offset - a int
      isGlobal - a boolean
    • postInc

      public void postInc(int offset, boolean isGlobal)

      postInc.

      Parameters:
      offset - a int
      isGlobal - a boolean
    • postDec

      public void postDec(int offset, boolean isGlobal)

      postDec.

      Parameters:
      offset - a int
      isGlobal - a boolean
    • incArrayRef

      public void incArrayRef(int offset, boolean isGlobal)

      incArrayRef.

      Parameters:
      offset - a int
      isGlobal - a boolean
    • incMapRef

      public void incMapRef()
      Increments a stack-provided associative-array element reference.
    • decArrayRef

      public void decArrayRef(int offset, boolean isGlobal)

      decArrayRef.

      Parameters:
      offset - a int
      isGlobal - a boolean
    • decMapRef

      public void decMapRef()
      Decrements a stack-provided associative-array element reference.
    • incDollarRef

      public void incDollarRef()

      incDollarRef.

    • decDollarRef

      public void decDollarRef()

      decDollarRef.

    • dup

      public void dup()

      dup.

    • not

      public void not()

      not.

    • negate

      public void negate()

      negate.

    • unaryPlus

      public void unaryPlus()

      unary plus.

    • cmpEq

      public void cmpEq()

      cmpEq.

    • cmpLt

      public void cmpLt()

      cmpLt.

    • cmpGt

      public void cmpGt()

      cmpGt.

    • matches

      public void matches()

      matches.

    • dereferenceArray

      public void dereferenceArray()

      dereferenceArray.

    • peekArrayElement

      public void peekArrayElement()
      Looks up an associative-array element without creating a blank entry when the key is missing.
    • ensureArrayElement

      public void ensureArrayElement()
      Dereferences an associative-array element as a nested array, creating it if needed.
    • keylist

      public void keylist()

      key list.

    • isEmptyList

      public void isEmptyList(Address address)

      isEmptyList.

      Parameters:
      address - a Address object
    • getFirstAndRemoveFromList

      public void getFirstAndRemoveFromList()

      getFirstAndRemoveFromList.

    • checkClass

      public boolean checkClass(Class<?> cls)

      checkClass.

      Parameters:
      cls - a Class object
      Returns:
      a boolean
    • getInputField

      public void getInputField()

      getInputField.

    • getInputField

      public void getInputField(long fieldIndex)

      getInputField.

      Parameters:
      fieldIndex - a long
    • consumeInput

      public void consumeInput(Address address)

      consumeInput.

      Parameters:
      address - a Address object
    • getlineInput

      public void getlineInput()

      getlineInput.

    • getlineInputToTarget

      public void getlineInputToTarget(Address noRecordAddress)
      Reads one record of the main input for getline target without touching the current record.
      Parameters:
      noRecordAddress - address to jump to when no record was read, with only the return code pushed
    • useAsFileInput

      public void useAsFileInput(Address noRecordAddress)
      Reads one record from a file for a redirected getline.
      Parameters:
      noRecordAddress - address to jump to when no record was read, with only the return code pushed
    • useAsCommandInput

      public void useAsCommandInput(Address noRecordAddress)
      Reads one record from the output of a command for a redirected getline.
      Parameters:
      noRecordAddress - address to jump to when no record was read, with only the return code pushed
    • nfOffset

      public void nfOffset(int offset)

      nfOffset.

      Parameters:
      offset - a int
    • nrOffset

      public void nrOffset(int offset)

      nrOffset.

      Parameters:
      offset - a int
    • fnrOffset

      public void fnrOffset(int offset)

      fnrOffset.

      Parameters:
      offset - a int
    • fsOffset

      public void fsOffset(int offset)

      fsOffset.

      Parameters:
      offset - a int
    • rsOffset

      public void rsOffset(int offset)

      rsOffset.

      Parameters:
      offset - a int
    • ofsOffset

      public void ofsOffset(int offset)

      ofsOffset.

      Parameters:
      offset - a int
    • orsOffset

      public void orsOffset(int offset)

      orsOffset.

      Parameters:
      offset - a int
    • rstartOffset

      public void rstartOffset(int offset)

      rstartOffset.

      Parameters:
      offset - a int
    • rlengthOffset

      public void rlengthOffset(int offset)

      rlengthOffset.

      Parameters:
      offset - a int
    • filenameOffset

      public void filenameOffset(int offset)

      filenameOffset.

      Parameters:
      offset - a int
    • subsepOffset

      public void subsepOffset(int offset)

      subsepOffset.

      Parameters:
      offset - a int
    • convfmtOffset

      public void convfmtOffset(int offset)

      convfmtOffset.

      Parameters:
      offset - a int
    • ofmtOffset

      public void ofmtOffset(int offset)

      ofmtOffset.

      Parameters:
      offset - a int
    • environOffset

      public void environOffset(int offset)

      environOffset.

      Parameters:
      offset - a int
    • beforeStartHooks

      public void beforeStartHooks()
      Emits the tuple that runs the extension beforeStart hooks, placed at the end of the preamble.
    • updateSymtab

      public void updateSymtab(int offset)
      Emits the tuple populating the SYMTAB array.
      Parameters:
      offset - offset of the SYMTAB global
    • updateFunctab

      public void updateFunctab(int offset)
      Emits the tuple populating the FUNCTAB array.
      Parameters:
      offset - offset of the FUNCTAB global
    • argcOffset

      public void argcOffset(int offset)

      argcOffset.

      Parameters:
      offset - a int
    • argvOffset

      public void argvOffset(int offset)

      argvOffset.

      Parameters:
      offset - a int
    • pushNF

      public void pushNF()
      Pushes the current value of NF onto the operand stack.
    • assignNF

      public void assignNF()
      Assigns the top-of-stack value to NF.
    • pushNR

      public void pushNR()
      Pushes the current value of NR onto the operand stack.
    • assignNR

      public void assignNR()
      Assigns the top-of-stack value to NR.
    • pushFNR

      public void pushFNR()
      Pushes the current value of FNR onto the operand stack.
    • assignFNR

      public void assignFNR()
      Assigns the top-of-stack value to FNR.
    • pushFS

      public void pushFS()
      Pushes the current value of FS onto the operand stack.
    • assignFS

      public void assignFS()
      Assigns the top-of-stack value to FS.
    • pushIGNORECASE

      public void pushIGNORECASE()
      Emits a tuple pushing the value of IGNORECASE.
    • assignIGNORECASE

      public void assignIGNORECASE()
      Emits a tuple assigning the top of the stack to IGNORECASE.
    • pushERRNO

      public void pushERRNO()
      Emits the tuple pushing the value of ERRNO, managed by the JRT.
    • assignERRNO

      public void assignERRNO()
      Emits the tuple assigning the top of the stack to ERRNO, managed by the JRT.
    • pushARGIND

      public void pushARGIND()
      Emits the tuple pushing the value of ARGIND, managed by the JRT.
    • assignARGIND

      public void assignARGIND()
      Emits the tuple assigning the top of the stack to ARGIND, managed by the JRT.
    • pushRS

      public void pushRS()
      Pushes the current value of RS onto the operand stack.
    • assignRS

      public void assignRS()
      Assigns the top-of-stack value to RS.
    • pushOFS

      public void pushOFS()
      Pushes the current value of OFS onto the operand stack.
    • assignOFS

      public void assignOFS()
      Assigns the top-of-stack value to OFS.
    • pushORS

      public void pushORS()
      Pushes the current value of ORS onto the operand stack.
    • assignORS

      public void assignORS()
      Assigns the top-of-stack value to ORS.
    • pushRSTART

      public void pushRSTART()
      Pushes the current value of RSTART onto the operand stack.
    • assignRSTART

      public void assignRSTART()
      Assigns the top-of-stack value to RSTART.
    • pushRLENGTH

      public void pushRLENGTH()
      Pushes the current value of RLENGTH onto the operand stack.
    • assignRLENGTH

      public void assignRLENGTH()
      Assigns the top-of-stack value to RLENGTH.
    • pushFILENAME

      public void pushFILENAME()
      Pushes the current value of FILENAME onto the operand stack.
    • assignFILENAME

      public void assignFILENAME()
      Assigns the top-of-stack value to FILENAME.
    • pushSUBSEP

      public void pushSUBSEP()
      Pushes the current value of SUBSEP onto the operand stack.
    • assignSUBSEP

      public void assignSUBSEP()
      Assigns the top-of-stack value to SUBSEP.
    • pushCONVFMT

      public void pushCONVFMT()
      Pushes the current value of CONVFMT onto the operand stack.
    • assignCONVFMT

      public void assignCONVFMT()
      Assigns the top-of-stack value to CONVFMT.
    • pushOFMT

      public void pushOFMT()
      Pushes the current value of OFMT onto the operand stack.
    • assignOFMT

      public void assignOFMT()
      Assigns the top-of-stack value to OFMT.
    • pushARGC

      public void pushARGC()
      Pushes the current value of ARGC onto the operand stack.
    • assignARGC

      public void assignARGC()
      Assigns the top-of-stack value to ARGC.
    • applyRS

      public void applyRS()

      applyRS.

    • function

      public void function(String funcName, int numFormalParams)

      function.

      Parameters:
      funcName - a String object
      numFormalParams - a int
    • callFunction

      public void callFunction(Supplier<Address> addressSupplier, String funcName, int numFormalParams, int numActualParams)

      callFunction.

      Parameters:
      addressSupplier - supplier resolving the function's entry point
      funcName - a String object
      numFormalParams - a int
      numActualParams - a int
    • indirectCall

      public void indirectCall(Map<String,Tuple.IndirectFunctionTarget> userFunctions, Map<String,ExtensionFunction> extensionFunctions, int numActualParams, String sourceName, int lineNumber)
      Emits a call whose function name is evaluated at runtime.
      Parameters:
      userFunctions - available user-defined function targets
      extensionFunctions - available extension function targets
      numActualParams - number of evaluated actual parameters
      sourceName - source name for runtime diagnostics
      lineNumber - source line for runtime diagnostics
    • warning

      public void warning(String message)
      Emits a tuple that prints a diagnostic message to the warning stream when executed. Planted by the parser just before the instruction it describes, so the warning appears in runtime order, exactly where gawk emits it.
      Parameters:
      message - warning text to print
    • setReturnResult

      public void setReturnResult()

      setReturnResult.

    • returnFromFunction

      public void returnFromFunction()

      returnFromFunction.

    • setNumGlobals

      public void setNumGlobals(int numGlobals)

      setNumGlobals.

      Parameters:
      numGlobals - a int
    • close

      public void close()

      close.

    • applySubsep

      public void applySubsep(int count)

      applySubsep.

      Parameters:
      count - a int
    • applySubsepUnderTop

      public void applySubsepUnderTop(int count)

      applySubsepUnderTop.

      Parameters:
      count - a int
    • deleteArrayElement

      public void deleteArrayElement(int offset, boolean isGlobal)

      deleteArrayElement.

      Parameters:
      offset - a int
      isGlobal - a boolean
    • deleteMapElement

      public void deleteMapElement()
      Deletes a stack-provided associative-array element.
    • deleteArray

      public void deleteArray(int offset, boolean isGlobal)

      deleteArray.

      Parameters:
      offset - a int
      isGlobal - a boolean
    • setExitAddress

      public void setExitAddress(Address addr)
      Registers the address of the END blocks section, so that a runtime exit statement can jump to it. A property of the tuple stream rather than a tuple: the interpreter reads it once when it installs the program.
      Parameters:
      addr - address of the END blocks section
    • getExitAddress

      public Address getExitAddress()
      Returns the address of the END blocks section, or null when the tuple stream is an expression stream with no END blocks.
      Returns:
      address of the END blocks section, or null
    • setWithinEndBlocks

      public void setWithinEndBlocks(boolean b)

      setWithinEndBlocks.

      Parameters:
      b - a boolean
    • setEndFileAddress

      public void setEndFileAddress(Address addr)
      Registers the address of the ENDFILE section, so that a runtime nextfile statement can jump to it. A property of the tuple stream rather than a tuple: the interpreter reads it once when it installs the program.
      Parameters:
      addr - address of the ENDFILE section
    • getEndFileAddress

      public Address getEndFileAddress()
      Returns the address of the ENDFILE section, or null when the program has no BEGINFILE/ENDFILE rules.
      Returns:
      address of the ENDFILE section, or null
    • setNextFileAddress

      public void setNextFileAddress(Address addr)
      Registers the address of the NEXT_FILE tuple that opens each input file, so that a runtime nextfile statement can bypass the ENDFILE rules for input files that could not be opened. A property of the tuple stream rather than a tuple: the interpreter reads it once when it installs the program.
      Parameters:
      addr - address of the NEXT_FILE tuple
    • getNextFileAddress

      public Address getNextFileAddress()
      Returns the address of the NEXT_FILE tuple that opens each input file, or null when the program does not use per-file input stepping.
      Returns:
      address of the NEXT_FILE tuple, or null
    • setNextAddress

      public void setNextAddress(Address addr)
      Registers the address of the main input loop's next-record entry point, so that a runtime next statement executed from a user-defined function can resume the loop there. A property of the tuple stream rather than a tuple: the interpreter reads it once when it installs the program.
      Parameters:
      addr - address where the main input loop consumes the next record
    • getNextAddress

      public Address getNextAddress()
      Returns the address of the main input loop's next-record entry point, or null when the program has no main input loop.
      Returns:
      address where the main input loop consumes the next record, or null
    • nextFile

      public void nextFile(Address address)
      Emits the tuple advancing the main input to the next input file, or jumping to the given address when no input file remains.
      Parameters:
      address - address to jump to when no more input files remain
    • consumeFileInput

      public void consumeFileInput(Address address)
      Emits the tuple consuming one record of the current input file only, jumping to the given address at end of the current file.
      Parameters:
      address - address to jump to at end of the current input file
    • execNextfile

      public void execNextfile()
      Emits the tuple executing the nextfile statement at runtime.
    • execNext

      public void execNext()
      Emits the tuple executing the next statement at runtime, for uses inside user-defined functions, where the calling rule cannot be known statically.
    • exitWithCode

      public void exitWithCode()

      exitWithCode.

    • exitWithoutCode

      public void exitWithoutCode()

      exitWithCode.

    • regexp

      public void regexp(String regexpStr)

      regexp.

      Parameters:
      regexpStr - a String object
    • conditionPair

      @Deprecated public void conditionPair()
      Deprecated.
      Evaluates both range conditions on every record, which is incorrect when the conditions have side effects. Use conditionPairInRange(long), conditionPairEnter(long) and conditionPairLeave(long) with conditional jumps instead.

      regexpPair.

    • conditionPairInRange

      public void conditionPairInRange(long id)
      Pushes whether the specified range pattern is currently active, i.e. its start condition matched a previous record and its end condition hasn't matched yet.
      Parameters:
      id - unique identifier of the range pattern within the script
    • conditionPairEnter

      public void conditionPairEnter(long id)
      Marks the specified range pattern as active, after its start condition matched the current record.
      Parameters:
      id - unique identifier of the range pattern within the script
    • conditionPairLeave

      public void conditionPairLeave(long id)
      Marks the specified range pattern as inactive, after its end condition matched the current record.
      Parameters:
      id - unique identifier of the range pattern within the script
    • isIn

      public void isIn()

      isIn.

    • scriptThis

      public void scriptThis()
      Emits a tuple that pushes the current script context onto the stack.
    • extension

      public void extension(ExtensionFunction function, int paramCount)
      Emits an extension invocation tuple.
      Parameters:
      function - metadata describing the extension method to invoke
      paramCount - number of arguments supplied for the call
    • dump

      public void dump(PrintStream ps)
      Dumps the queued tuples to the provided PrintStream.
      Parameters:
      ps - destination stream for the tuple listing
    • top

      public PositionTracker top()

      top.

      Returns:
      a PositionTracker object
    • postProcess

      public void postProcess()
      Executed after all tuples are entered in the queue. Its main functions are:
      • Assign queue.next to the next element in the queue.
      • Calls touch(...) per Tuple so that addresses can be normalized/assigned/allocated properly.
    • optimize

      public void optimize()
      Performs tuple queue optimizations such as reachability pruning, redundant eval-global setup removal, and NOP collapsing.

      This method is idempotent. Repeated invocations after a successful optimization run will have no additional effect.

      Peephole optimization happens at the tuple layer instead of during AST construction. Folding after parsing guarantees that any tuple-level transformations (for example, address resolution and extension hooks) have already run, and it keeps a single optimization toggle (optimize()) for callers. Performing the work at the tuple layer also lets us recurse until no more changes occur without complicating the parser.

    • addGlobalVariableNameToOffsetMapping

      public void addGlobalVariableNameToOffsetMapping(String varname, int offset, boolean isArray)
      Accept a {variable_name -> offset} mapping such that global variables can be assigned while processing name=value and filename command-line arguments.
      Parameters:
      varname - Name of the global variable
      offset - What offset to use for the variable
      isArray - Whether the variable is actually an array
    • setFunctionNameSet

      public void setFunctionNameSet(Set<String> names)
      Accept a set of function names from the parser. This is useful for invalidating name=value assignments from the command line parameters, either via -v arguments or passed into ARGV.
      Parameters:
      names - A set of function name strings.
    • freezeMetadata

      public void freezeMetadata()
      Freezes the tuple metadata after compilation so execution can reuse the published maps and sets without creating fresh unmodifiable wrappers. Repeated calls are ignored.
    • getGlobalVariableOffsetMap

      public Map<String,Integer> getGlobalVariableOffsetMap()

      getGlobalVariableOffsetMap.

      Returns:
      a Map object
    • getGlobalVariableAarrayMap

      public Map<String,Boolean> getGlobalVariableAarrayMap()

      getGlobalVariableAarrayMap.

      Returns:
      a Map object
    • getFunctionNameSet

      public Set<String> getFunctionNameSet()

      getFunctionNameSet.

      Returns:
      a Set object
    • pushSourceLineNumber

      public void pushSourceLineNumber(int lineno)
      Push the current line number onto the line number stack. This is called by the parser to keep track of the current source line number. Keeping track of line numbers this way allows the runtime to report more meaningful errors by providing source line numbers within error reports.
      Parameters:
      lineno - The current source line number.
    • popSourceLineNumber

      public void popSourceLineNumber(int lineno)

      popSourceLineNumber.

      Parameters:
      lineno - a int