DROP Instruction - craterdog-archives/js-bali-virtual-machine GitHub Wiki

The DROP Instruction

The DROP instruction causes a component to be dropped from the cloud environment. The type of component depends on the specified modifier:

The operand contains an index value in the range 1..2047 of the variable that specifies the location of the component.

DROP VARIABLE variable

The DROP instruction with a VARIABLE modifier drops the value currently saved in the variable identified by the variable operand and replaces it with the value none. The bytecode for this instruction has the form:

[10100xxx][xxxxxxxx] where xxxxxxxxxxx is the index of the variable

The following pseudo-code defines this instruction:

context.variables.set(context.operand, none)
context.address = context.address + 1

Example Context Before Execution

DROP VARIABLE - Before

Example Context After Execution

DROP VARIABLE - After

DROP DOCUMENT citation

The DROP instruction with a DOCUMENT modifier drops from the repository the document whose citation is saved in the variable identified by the citation operand. The bytecode for this instruction has the form:

[10101xxx][xxxxxxxx] where xxxxxxxxxxx is the index of the variable

The following pseudo-code defines this instruction:

citation = context.variables.get(context.operand)
repository.discardDocument(citation)
context.address = context.address + 1

Example Context Before Execution

DROP DOCUMENT - Before

Example Context After Execution

DROP DOCUMENT - After

DROP CONTRACT name

The DROP instruction with a CONTRACT modifier drops from the repository the contract whose name is saved in the variable identified by the name operand. The bytecode for this instruction has the form:

[10110xxx][xxxxxxxx] where xxxxxxxxxxx is the index of the variable

The following pseudo-code defines this instruction:

name = context.variables.get(context.operand)
repository.deleteContract(name)
context.address = context.address + 1

Example Context Before Execution

DROP CONTRACT - Before

Example Context After Execution

DROP CONTRACT - After

DROP MESSAGE bag

The DROP instruction with a MESSAGE modifier drops from its message bag the message that is saved in the variable identified by the bag operand. The bytecode for this instruction has the form:

[10111xxx][xxxxxxxx] where xxxxxxxxxxx is the index of the variable

The following pseudo-code defines this instruction:

message = context.variables.get(context.operand)
repository.acceptMessage(message)
context.address = context.address + 1

Example Context Before Execution

DROP MESSAGE - Before

Example Context After Execution

DROP MESSAGE - After