SAVE Instruction - craterdog-archives/js-bali-virtual-machine GitHub Wiki
The SAVE Instruction
The SAVE
instruction causes the component that is on top of the component stack to be
saved in the cloud environment. The destination 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
destination of the component.
SAVE VARIABLE variable
The SAVE
instruction with a VARIABLE
modifier removes the component that is currently
on top of the component stack and saves it in the variable identified by the variable operand.
The bytecode for this instruction has the form:
[10000xxx][xxxxxxxx] where xxxxxxxxxxx is the index of the variable containing the component
The following pseudo-code defines this instruction:
variable = task.components.pop()
context.variables.set(context.operand, variable)
context.address = context.address + 1
Example Context Before Execution
Example Context After Execution
SAVE DOCUMENT citation
The SAVE
instruction with a DOCUMENT
modifier removes the component that is currently
on top of the component stack and saves it in the document repository as a document whose
citation is saved in the variable identified by the citation operand. The bytecode
for this instruction has the form:
[10001xxx][xxxxxxxx] where xxxxxxxxxxx is the index of the variable containing the citation to the document
The following pseudo-code defines this instruction:
document = task.components.pop()
citation = repository.saveDocument(document)
context.variables.set(context.operand, citation)
context.address = context.address + 1
Example Context Before Execution
Example Context After Execution
SAVE CONTRACT name
The SAVE
instruction with a CONTRACT
modifier removes the component that is currently
on top of the component stack and saves it in the document repository as a contract whose
name is saved in the variable identified by the name operand. The bytecode for this
instruction has the form:
[10010xxx][xxxxxxxx] where xxxxxxxxxxx is the index of the variable containing the name of the contract
The following pseudo-code defines this instruction:
document = task.components.pop()
name = context.variables.get(context.operand)
repository.commitDocument(name, document)
context.address = context.address + 1
Example Context Before Execution
Example Context After Execution
SAVE MESSAGE bag
The SAVE
instruction with a MESSAGE
modifier removes the message that is currently
on top of the component stack and adds it to the message bag whose name is saved in the
variable identified by the bag operand. The bytecode for this instruction has the form:
[10011xxx][xxxxxxxx] where xxxxxxxxxxx is the index of the variable containing the name of the bag
The following pseudo-code defines this instruction:
message = task.components.pop()
bag = context.variables.get(context.operand)
repository.postMessage(bag, message)
context.address = context.address + 1