LOAD Instruction - craterdog-archives/js-bali-virtual-machine GitHub Wiki
The LOAD Instruction
The LOAD
instruction causes a component to be retrieved from the cloud environment and loaded
onto the component stack. The source of the component depends on the specified modifier:
The operand contains an index value in the range 1..2047
of the variable that specifies the
source of the component.
LOAD VARIABLE variable
The LOAD
instruction with a VARIABLE
modifier loads, onto the component stack, the
value that is currently saved in the variable identified by the variable operand. The
bytecode for this instruction has the form:
[01100xxx][xxxxxxxx] where xxxxxxxxxxx is the index of the variable containing the component
The following pseudo-code defines this instruction:
variable = context.variables.get(context.operand)
task.components.push(variable)
context.address = context.address + 1
Example Context Before Execution
Example Context After Execution
LOAD DOCUMENT citation
The LOAD
instruction with a DOCUMENT
modifier loads, onto the component stack, the
document whose citation is saved in the variable identified by the citation operand.
The bytecode for this instruction has the form:
[01101xxx][xxxxxxxx] where xxxxxxxxxxx is the index of the variable containing the citation to the document
The following pseudo-code defines this instruction:
citation = context.variables.get(context.operand)
document = repository.retrieveDocument(citation)
task.components.push(document)
context.address = context.address + 1
Example Context Before Execution
Example Context After Execution
LOAD CONTRACT name
The LOAD
instruction with a CONTRACT
modifier loads, onto the component stack, the
contract whose name is saved in the variable identified by the name operand. The bytecode
for this instruction has the form:
[01110xxx][xxxxxxxx] where xxxxxxxxxxx is the index of the variable containing the name of the contract
The following pseudo-code defines this instruction:
name = context.variables.get(context.operand)
contract = repository.retrieveContract(name)
task.components.push(contract)
context.address = context.address + 1
Example Context Before Execution
Example Context After Execution
LOAD MESSAGE bag
The LOAD
instruction with a MESSAGE
modifier loads, onto the component stack, a message
randomly chosen from the message bag whose name is saved in the variable identified by the
bag operand. The bytecode for this instruction has the form:
[01111xxx][xxxxxxxx] where xxxxxxxxxxx is the index of the variable containing the name of the bag
The following pseudo-code defines this instruction:
bag = context.variables.get(context.operand)
message = repository.retrieveMessage(bag)
if message then {
-- the bag contained a message
task.components.push(message)
context.address = context.address + 1
} else {
-- the bag was empty, need to retry this instruction again later
repository.postMessage('/bali/vm/tasks/v1', task)
task.status = $paused
}