constructor
Adds a statement at end of existing bytecode
Discards any existing bytecode
Loads bytecode. Discards any existing bytecode
Changes labels to label indexes, and resolves addresses, in arguments
Verifies a loaded bytecode, to make sure only valid instructions exist, and correct number of arguments and types are loaded No more statements should be added after this has been called
string[] source = [ "start: instA l2", " instB 50 50.5", " instC \"hello\" false", "l2: instd 'c' start" ]; NaInstTable iTable = new NaInstTable(); NaInst inst = NaInst("insta",[NaInstArgType.Label]); iTable.addInstruction(inst); inst = NaInst("instb", [NaInstArgType.Integer, NaInstArgType.Double]); iTable.addInstruction(inst); inst = NaInst("instc", [NaInstArgType.String, NaInstArgType.Boolean]); iTable.addInstruction(inst); inst = NaInst("instd", [NaInstArgType.Char, NaInstArgType.Label]); iTable.addInstruction(inst); NaBytecode bcode = new NaBytecode(iTable); bcode.load(source); assert(bcode.labelNames == ["start", "l2"]); assert(bcode.labelIndexes == [[0, 0], [3, 5]]); assert(bcode.instArgTypes == [NaInstArgType.Label, NaInstArgType.Integer, NaInstArgType.Double, NaInstArgType.String, NaInstArgType.Boolean, NaInstArgType.Char, NaInstArgType.Label]); assert(bcode.verify == true); .destroy(iTable); .destroy(bcode);
Stores bytecode