Class AwkTuples
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
AwkExpression,AwkProgram,SandboxedAwkTuples
AwkTuples class.
- Author:
- Danny Daglas
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd()add.voidaddGlobalVariableNameToOffsetMapping(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.voidapplyRS()applyRS.voidapplySubsep(int count) applySubsep.voidargcOffset(int offset) argcOffset.voidargvOffset(int offset) argvOffset.voidassign(int offset, boolean isGlobal) assign.voidAssigns the top-of-stack value toARGC.voidassignArray(int offset, boolean isGlobal) assignArray.voidassignAsInput.voidassignAsInputField.voidAssigns the top-of-stack value toCONVFMT.voidAssigns the top-of-stack value toFILENAME.voidAssigns the top-of-stack value toFNR.voidassignFS()Assigns the top-of-stack value toFS.voidAssigns a value to a stack-provided associative-array element.voidassignNF()Assigns the top-of-stack value toNF.voidassignNR()Assigns the top-of-stack value toNR.voidAssigns the top-of-stack value toOFMT.voidAssigns the top-of-stack value toOFS.voidAssigns the top-of-stack value toORS.voidAssigns the top-of-stack value toRLENGTH.voidassignRS()Assigns the top-of-stack value toRS.voidAssigns the top-of-stack value toRSTART.voidAssigns the top-of-stack value toSUBSEP.voidatan2()atan2.voidcallFunction(Supplier<Address> addressSupplier, String funcName, int numFormalParams, int numActualParams) callFunction.booleancheckClass(Class<?> cls) checkClass.voidclose()close.voidcmpEq()cmpEq.voidcmpGt()cmpGt.voidcmpLt()cmpLt.voidconcat()concat.voidregexpPair.voidconsumeInput(Address address) consumeInput.voidconvfmtOffset(int offset) convfmtOffset.voidcos()cos.createAddress(String label) createAddress.voiddec(int offset, boolean isGlobal) dec.voiddecArrayRef(int offset, boolean isGlobal) decArrayRef.voiddecDollarRef.voidDecrements a stack-provided associative-array element reference.voiddeleteArray(int offset, boolean isGlobal) deleteArray.voiddeleteArrayElement(int offset, boolean isGlobal) deleteArrayElement.voidDeletes a stack-provided associative-array element.voiddereference(int offset, boolean isArray, boolean isGlobal) dereference.voiddereferenceArray.voiddivEq(int offset, boolean isGlobal) divEq.voiddivEqArray(int offset, boolean isGlobal) divEqArray.voiddivEqInputField.voidApplies/=to a stack-provided associative-array element.voiddivide()divide.voiddump(PrintStream ps) Dumps the queued tuples to the providedPrintStream.voiddup()dup.voidDereferences an associative-array element as a nested array, creating it if needed.voidenvironOffset(int offset) environOffset.voidexitWithCode.voidexitWithCode.voidexp()exp.voidextension(ExtensionFunction function, int paramCount, boolean isInitial) Emits an extension invocation tuple.voidfilenameOffset(int offset) filenameOffset.voidfnrOffset(int offset) fnrOffset.voidFreezes the tuple metadata after compilation so execution can reuse the published maps and sets without creating fresh unmodifiable wrappers.voidfsOffset(int offset) fsOffset.voidfunction.voidgetFirstAndRemoveFromList.getFunctionNameSet.getGlobalVariableAarrayMap.getGlobalVariableOffsetMap.voidgetInputField.voidgetInputField(long fieldIndex) getInputField.voidgetlineInput.voidgetlineInputToTarget.voidgotoAddress(Address address) gotoAddress.voidifFalse.voidifTrue.voidinc(int offset, boolean isGlobal) inc.voidincArrayRef(int offset, boolean isGlobal) incArrayRef.voidincDollarRef.voidIncrements a stack-provided associative-array element reference.voidindex()index.voidintFunc()intFunc.voidisEmptyList(Address address) isEmptyList.voidisIn()isIn.voidkeylist()key list.voidlength(int numExprs) length.voidlog()log.voidMarks this tuple stream as an expression-eval program rather than a full AWK script.voidmatch()match.voidmatches()matches.voidminusEq(int offset, boolean isGlobal) minusEq.voidminusEqArray(int offset, boolean isGlobal) minusEqArray.voidminusEqInputField.voidApplies-=to a stack-provided associative-array element.voidmod()mod.voidmodEq(int offset, boolean isGlobal) modEq.voidmodEqArray(int offset, boolean isGlobal) modEqArray.voidmodEqInputField.voidApplies%=to a stack-provided associative-array element.voidmultEq(int offset, boolean isGlobal) multEq.voidmultEqArray(int offset, boolean isGlobal) multEqArray.voidmultEqInputField.voidApplies*=to a stack-provided associative-array element.voidmultiply()multiply.voidnegate()negate.voidnfOffset(int offset) nfOffset.voidnop()nop.voidnot()not.voidnrOffset(int offset) nrOffset.voidofmtOffset(int offset) ofmtOffset.voidofsOffset(int offset) ofsOffset.voidoptimize()Performs tuple queue optimizations such as reachability pruning, redundant eval-global setup removal, and NOP collapsing.voidorsOffset(int offset) orsOffset.voidLooks up an associative-array element without creating a blank entry when the key is missing.voidplusEq(int offset, boolean isGlobal) plusEq.voidplusEqArray(int offset, boolean isGlobal) plusEqArray.voidplusEqInputField.voidApplies+=to a stack-provided associative-array element.voidpop()pop.voidpopSourceLineNumber(int lineno) popSourceLineNumber.voidpostDec(int offset, boolean isGlobal) postDec.voidpostInc(int offset, boolean isGlobal) postInc.voidExecuted after all tuples are entered in the queue.voidpow()pow.voidpowEq(int offset, boolean isGlobal) powEq.voidpowEqArray(int offset, boolean isGlobal) powEqArray.voidpowEqInputField.voidApplies exponentiation assignment to a stack-provided associative-array element.voidprint(int numExprs) print.voidprintf(int numExprs) printf.voidprintfToFile(int numExprs, boolean append) printfToFile.voidprintfToPipe(int numExprs) printfToPipe.voidprintToFile(int numExprs, boolean append) printToFile.voidprintToPipe(int numExprs) printToPipe.voidpush.voidpushARGC()Pushes the current value ofARGConto the operand stack.voidPushes the current value ofCONVFMTonto the operand stack.voidPushes the current value ofFILENAMEonto the operand stack.voidpushFNR()Pushes the current value ofFNRonto the operand stack.voidpushFS()Pushes the current value ofFSonto the operand stack.voidpushNF()Pushes the current value ofNFonto the operand stack.voidpushNR()Pushes the current value ofNRonto the operand stack.voidpushOFMT()Pushes the current value ofOFMTonto the operand stack.voidpushOFS()Pushes the current value ofOFSonto the operand stack.voidpushORS()Pushes the current value ofORSonto the operand stack.voidPushes the current value ofRLENGTHonto the operand stack.voidpushRS()Pushes the current value ofRSonto the operand stack.voidPushes the current value ofRSTARTonto the operand stack.voidpushSourceLineNumber(int lineno) Push the current line number onto the line number stack.voidPushes the current value ofSUBSEPonto the operand stack.voidrand()rand.voidregexp.voidreturnFromFunction.voidrlengthOffset(int offset) rlengthOffset.voidrsOffset(int offset) rsOffset.voidrstartOffset(int offset) rstartOffset.voidEmits a tuple that pushes the current script context onto the stack.voidsetExitAddress(Address addr) setExitAddress.voidsetFunctionNameSet(Set<String> names) Accept a set of function names from the parser.voidsetNumGlobals(int numGlobals) setNumGlobals.voidsetReturnResult.voidsetWithinEndBlocks(boolean b) setWithinEndBlocks.voidsin()sin.voidsplit(int numargs) split.voidsprintf(int numExprs) sprintf.voidsqrt()sqrt.voidsrand(int num) srand.voidsubForArrayReference(int offset, boolean isGlobal, boolean isGsub) subForArrayReference.voidsubForDollar0(boolean isGsub) subForDollar0.voidsubForDollarReference(boolean isGsub) subForDollarReference.voidsubForMapReference(boolean isGsub) Appliessub/gsubto a stack-provided associative-array element.voidsubForVariable(int offset, boolean isGlobal, boolean isGsub) subForVariable.voidsubsepOffset(int offset) subsepOffset.voidsubstr(int numargs) substr.voidsubtract()subtract.voidswap()swap.voidsystem()system.voidtolower()tolower.voidtoNumber()toNumber.static StringtoOpcodeString(int opcode) toOpcodeString.top()top.voidtoupper()toupper.voidunary plus.voiduseAsCommandInput.voiduseAsFileInput.
-
Constructor Details
-
AwkTuples
public AwkTuples()
-
-
Method Details
-
toOpcodeString
toOpcodeString.
- Parameters:
opcode- a int- Returns:
- a
Stringobject
-
pop
public void pop()pop.
-
push
push.
- Parameters:
o- aObjectobject
-
ifFalse
ifFalse.
- Parameters:
address- aAddressobject
-
toNumber
public void toNumber()toNumber.
-
ifTrue
ifTrue.
- Parameters:
address- aAddressobject
-
gotoAddress
gotoAddress.
- Parameters:
address- aAddressobject
-
createAddress
createAddress.
-
address
address.
-
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 intappend- 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 intappend- 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 intisGlobal- a boolean
-
assignArray
public void assignArray(int offset, boolean isGlobal) assignArray.
- Parameters:
offset- a intisGlobal- 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 intisArray- a booleanisGlobal- a boolean
-
plusEq
public void plusEq(int offset, boolean isGlobal) plusEq.
- Parameters:
offset- a intisGlobal- a boolean
-
minusEq
public void minusEq(int offset, boolean isGlobal) minusEq.
- Parameters:
offset- a intisGlobal- a boolean
-
multEq
public void multEq(int offset, boolean isGlobal) multEq.
- Parameters:
offset- a intisGlobal- a boolean
-
divEq
public void divEq(int offset, boolean isGlobal) divEq.
- Parameters:
offset- a intisGlobal- a boolean
-
modEq
public void modEq(int offset, boolean isGlobal) modEq.
- Parameters:
offset- a intisGlobal- a boolean
-
powEq
public void powEq(int offset, boolean isGlobal) powEq.
- Parameters:
offset- a intisGlobal- a boolean
-
plusEqArray
public void plusEqArray(int offset, boolean isGlobal) plusEqArray.
- Parameters:
offset- a intisGlobal- 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 intisGlobal- 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 intisGlobal- 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 intisGlobal- 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 intisGlobal- 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 intisGlobal- 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 intisGlobal- a booleanisGsub- a boolean
-
subForArrayReference
public void subForArrayReference(int offset, boolean isGlobal, boolean isGsub) subForArrayReference.
- Parameters:
offset- a intisGlobal- a booleanisGsub- a boolean
-
subForMapReference
public void subForMapReference(boolean isGsub) Appliessub/gsubto a stack-provided associative-array element.- Parameters:
isGsub-trueforgsub,falseforsub
-
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 intisGlobal- a boolean
-
dec
public void dec(int offset, boolean isGlobal) dec.
- Parameters:
offset- a intisGlobal- a boolean
-
postInc
public void postInc(int offset, boolean isGlobal) postInc.
- Parameters:
offset- a intisGlobal- a boolean
-
postDec
public void postDec(int offset, boolean isGlobal) postDec.
- Parameters:
offset- a intisGlobal- a boolean
-
incArrayRef
public void incArrayRef(int offset, boolean isGlobal) incArrayRef.
- Parameters:
offset- a intisGlobal- 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 intisGlobal- 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
isEmptyList.
- Parameters:
address- aAddressobject
-
getFirstAndRemoveFromList
public void getFirstAndRemoveFromList()getFirstAndRemoveFromList.
-
checkClass
checkClass.
- Parameters:
cls- aClassobject- Returns:
- a boolean
-
getInputField
public void getInputField()getInputField.
-
getInputField
public void getInputField(long fieldIndex) getInputField.
- Parameters:
fieldIndex- a long
-
consumeInput
consumeInput.
- Parameters:
address- aAddressobject
-
getlineInput
public void getlineInput()getlineInput.
-
getlineInputToTarget
public void getlineInputToTarget()getlineInputToTarget.
-
useAsFileInput
public void useAsFileInput()useAsFileInput.
-
useAsCommandInput
public void useAsCommandInput()useAsCommandInput.
-
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
-
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 ofNFonto the operand stack. -
assignNF
public void assignNF()Assigns the top-of-stack value toNF. -
pushNR
public void pushNR()Pushes the current value ofNRonto the operand stack. -
assignNR
public void assignNR()Assigns the top-of-stack value toNR. -
pushFNR
public void pushFNR()Pushes the current value ofFNRonto the operand stack. -
assignFNR
public void assignFNR()Assigns the top-of-stack value toFNR. -
pushFS
public void pushFS()Pushes the current value ofFSonto the operand stack. -
assignFS
public void assignFS()Assigns the top-of-stack value toFS. -
pushRS
public void pushRS()Pushes the current value ofRSonto the operand stack. -
assignRS
public void assignRS()Assigns the top-of-stack value toRS. -
pushOFS
public void pushOFS()Pushes the current value ofOFSonto the operand stack. -
assignOFS
public void assignOFS()Assigns the top-of-stack value toOFS. -
pushORS
public void pushORS()Pushes the current value ofORSonto the operand stack. -
assignORS
public void assignORS()Assigns the top-of-stack value toORS. -
pushRSTART
public void pushRSTART()Pushes the current value ofRSTARTonto the operand stack. -
assignRSTART
public void assignRSTART()Assigns the top-of-stack value toRSTART. -
pushRLENGTH
public void pushRLENGTH()Pushes the current value ofRLENGTHonto the operand stack. -
assignRLENGTH
public void assignRLENGTH()Assigns the top-of-stack value toRLENGTH. -
pushFILENAME
public void pushFILENAME()Pushes the current value ofFILENAMEonto the operand stack. -
assignFILENAME
public void assignFILENAME()Assigns the top-of-stack value toFILENAME. -
pushSUBSEP
public void pushSUBSEP()Pushes the current value ofSUBSEPonto the operand stack. -
assignSUBSEP
public void assignSUBSEP()Assigns the top-of-stack value toSUBSEP. -
pushCONVFMT
public void pushCONVFMT()Pushes the current value ofCONVFMTonto the operand stack. -
assignCONVFMT
public void assignCONVFMT()Assigns the top-of-stack value toCONVFMT. -
pushOFMT
public void pushOFMT()Pushes the current value ofOFMTonto the operand stack. -
assignOFMT
public void assignOFMT()Assigns the top-of-stack value toOFMT. -
pushARGC
public void pushARGC()Pushes the current value ofARGConto the operand stack. -
assignARGC
public void assignARGC()Assigns the top-of-stack value toARGC. -
applyRS
public void applyRS()applyRS.
-
function
function.
- Parameters:
funcName- aStringobjectnumFormalParams- a int
-
callFunction
public void callFunction(Supplier<Address> addressSupplier, String funcName, int numFormalParams, int numActualParams) callFunction.
- Parameters:
addressSupplier- supplier resolving the function's entry pointfuncName- aStringobjectnumFormalParams- a intnumActualParams- a int
-
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
-
deleteArrayElement
public void deleteArrayElement(int offset, boolean isGlobal) deleteArrayElement.
- Parameters:
offset- a intisGlobal- 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 intisGlobal- a boolean
-
setExitAddress
setExitAddress.
- Parameters:
addr- aAddressobject
-
setWithinEndBlocks
public void setWithinEndBlocks(boolean b) setWithinEndBlocks.
- Parameters:
b- a boolean
-
exitWithCode
public void exitWithCode()exitWithCode.
-
exitWithoutCode
public void exitWithoutCode()exitWithCode.
-
regexp
regexp.
- Parameters:
regexpStr- aStringobject
-
conditionPair
public void conditionPair()regexpPair.
-
isIn
public void isIn()isIn.
-
scriptThis
public void scriptThis()Emits a tuple that pushes the current script context onto the stack. -
extension
Emits an extension invocation tuple.- Parameters:
function- metadata describing the extension method to invokeparamCount- number of arguments supplied for the callisInitial-truewhen this tuple opens an extension call sequence
-
dump
Dumps the queued tuples to the providedPrintStream.- Parameters:
ps- destination stream for the tuple listing
-
top
top.
- Returns:
- a
PositionTrackerobject
-
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
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 variableoffset- What offset to use for the variableisArray- Whether the variable is actually an array
-
setFunctionNameSet
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
getGlobalVariableOffsetMap.
- Returns:
- a
Mapobject
-
getGlobalVariableAarrayMap
getGlobalVariableAarrayMap.
- Returns:
- a
Mapobject
-
getFunctionNameSet
getFunctionNameSet.
- Returns:
- a
Setobject
-
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
-