0.3.3
Instance of this class are used to compile a yarn AST output by the YarnParser
(CompilerConfig)
the configuration for this compiler
Link and finalize assembly of the bytecode ready for writing. (Passes 4, 5 and 6)
Write the assembled file out to the supplied streams.
(stream.Writable)
the logic bytecode stream
(stream.Writable)
the "default" language dialogue stream
(stream.Writable)
the sourcemap stream (if null, won't be writte)
(stream.Writable)
the debug stream (if null, won't be written)
Promise
:
when this is completed
Write the bytecode as buffers
(boolean)
if the buffer object includes a sourcemap
(boolean)
if the buffer object includes a debug text file
Promise
:
when this is completed.
The promise's resolve will have an argument that is a BufferObj containing
the compiled bytecode
Reset the state of this Compiler
Compiler configuration
Command types by name (constant is the opcode in octal)
Do nothing. Octal: 0, Decimal: 0, Hex: 0 This is a valid Logic File instruction. This is a valid Dialog File instruction. No parameters
Display the last X arguments on the stack. Octal: 1, Decimal: 1, Hex: 1 This is a valid Logic File instruction. This is a valid Dialog File instruction. No parameters.
Pass the the last X arguments on the stack to the engine as a message Octal: 101, Decimal: 65, Hex: 41 This is a valid Logic File instruction. This is a valid Dialog File instruction. No parameters.
Display the given dialog block Octal: 201, Decimal: 129, Hex: 81 This is a valid Logic File instruction. 0 - (varBytes) - the dialog block reference in the Dialog File 1 - (varInt) - the character reference in the Dialog File (or -1 if no character)
End the Dialog Block Octal: 301, Decimal: 193, Hex: C1 This is a valid Dialog File instruction. No parameters.
Enter the node Octal: 2, Decimal: 2, Hex: 2 This is a valid Logic File instruction. 0 - (varInt) nodetable index of the node we are entering.
Jump to another instruction Octal: 3, Decimal: 3, Hex: 3 This is a valid Logic File instruction. 0 - (varInt) byte offset of the instruction list to jump to
Jump to another instruction if the last stack value is true. Octal: 103, Decimal: 67, Hex: 43 Remove the top argument on the stack regardless. This is a valid Logic File instruction. 0 - (varInt) byte offset of the instruction list to jump to
Jump to another instruction if the last stack value is false Octal: 203, Decimal: 131, Hex: 83 Remove the top argument on the stack regardless. This is a valid Logic File instruction. 0 - (varInt) byte offset of the instruction list to jump to
Load the variable at the index specified onto the stack Octal: 20, Decimal: 16, Hex: 10 This is a valid Logic File instruction. This is a valid Dialog File instruction. 0 - (varInt) variabletable index
Save the last stack value to the specified variable Octal: 220, Decimal: 144 Hex: 90 This is a valid Logic File instruction. 0 - (varInt) variabletable index
Load a null onto the stack Octal: 21, Decimal: 17 Hex: 11 This is a valid Logic File instruction. This is a valid Dialog File instruction. No parameters.
Load a true onto the stack Octal: 121, Decimal: 81 Hex: 51 This is a valid Logic File instruction. This is a valid Dialog File instruction. No parameters.
Load a false onto the stack Octal: 221, Decimal: 145 Hex: 91 This is a valid Logic File instruction. This is a valid Dialog File instruction. No parameters.
Load a string onto the stack Octal: 221, Decimal: 209 Hex: D1 This is a valid Logic File instruction. This is a valid Dialog File instruction. 0 - (varInt) String Table index
Load a float onto the stack Octal: 22, Decimal: 18 Hex: 12 This is a valid Logic File instruction. This is a valid Dialog File instruction. 0 - (float) the float
Load an integer onto the stack Octal: 122, Decimal: 82 Hex: 52 This is a valid Logic File instruction. This is a valid Dialog File instruction. 0 - (varInt) the integer
Use the specified stack values, add them and push the result onto the stack Octal: 23, Decimal: 19 Hex: 13 This is a valid Logic File instruction. This is a valid Dialog File instruction. 0 - (StackOffset) the left argument 1 - (StackOffset) the right argument
Use the specified stack values, subtract them and push the result onto the stack Octal: 123, Decimal: 83 Hex: 53 This is a valid Logic File instruction. This is a valid Dialog File instruction. 0 - (StackOffset) the left argument 1 - (StackOffset) the right argument
Use the specified stack values, multiply them and push the result onto the stack Octal: 24, Decimal: 20 Hex: 14 This is a valid Logic File instruction. This is a valid Dialog File instruction. 0 - (StackOffset) the left argument 1 - (StackOffset) the right argument
Use the specified stack values, divide the oldest by the newest and push the result onto the stack Octal: 124, Decimal: 84 Hex: 54 This is a valid Logic File instruction. This is a valid Dialog File instruction. 0 - (StackOffset) the left argument 1 - (StackOffset) the right argument
Use the specified stack values, return the oldest mod'ed by the newest and push the result onto the stack Octal: 224, Decimal: 148 Hex: 94 This is a valid Logic File instruction. This is a valid Dialog File instruction. 0 - (StackOffset) the left argument 1 - (StackOffset) the right argument
Use the specified stack values, push true on the stack if they are equal, false otherwise Octal: 25, Decimal: 21 Hex: 15 This is a valid Logic File instruction. This is a valid Dialog File instruction. 0 - (StackOffset) the left argument 1 - (StackOffset) the right argument
Use the specified stack value and push the not value of it onto the stack Octal: 125, Decimal: 85 Hex: 55 This is a valid Logic File instruction. This is a valid Dialog File instruction. 0 - (StackOffset) the argument
Use the specified stack values, push the AND result onto the stack Octal: 26, Decimal: 22 Hex: 16 This is a valid Logic File instruction. This is a valid Dialog File instruction. 0 - (StackOffset) the left argument 1 - (StackOffset) the right argument
Use the specified stack values, push the OR result onto the stack Octal: 126, Decimal: 86 Hex: 56 This is a valid Logic File instruction. This is a valid Dialog File instruction. 0 - (StackOffset) the left argument 1 - (StackOffset) the right argument
Use the specified stack values, push the OR result onto the stack Octal: 226, Decimal: 150 Hex: 96 This is a valid Logic File instruction. This is a valid Dialog File instruction. 0 - (StackOffset) the left argument 1 - (StackOffset) the right argument
Use the specified stack values, push true if the older is greater than the newer onto the stack, false otherwise Octal: 27, Decimal: 23 Hex: 17 This is a valid Logic File instruction. This is a valid Dialog File instruction. 0 - (StackOffset) the left argument 1 - (StackOffset) the right argument
Use the specified stack values, push true if the older is less than the newer onto the stack, false otherwise Octal: 127, Decimal: 87 Hex: 57 This is a valid Logic File instruction. This is a valid Dialog File instruction. 0 - (StackOffset) the left argument 1 - (StackOffset) the right argument
Use the specified stack values, run the specified function and push the result onto the stack. Octal: 30, Decimal: 24, Hex: 18 This is a valid Logic File instruction. This is a valid Dialog File instruction. 0 - (varInt) functiontable index of the function to run 1 - (byte) the number of arguments to reference 2..n - (StackOffset) - the argument stack offset
Use the specified stack values, run the specified function. Result is discarded. Octal: 130, Decimal: 88, Hex: 58 This is a valid Logic File instruction. This is a valid Dialog File instruction. 0 - (varInt) functiontable index of the function to run 1 - (byte) the number of arguments to reference 2..n - (StackOffset) - the argument stack offset
Add another option to the option stack. Octal: 50, Decimal: 40, Hex: 28 This is a valid Logic File instruction. 0 - (varInt) byte offset of the instruction after this option's instructions
Run all the options on the stack. (Should clear the option stack) Octal: 51, Decimal: 41, Hex: 29 This is a valid Logic File instruction. No Parameters.
Clear the top (arg1) values starting from arg0 off the argument stack, or to the end (if arg1 is 255) Octal: 375, Decimal: 253, Hex: FD This is a valid Logic File instruction. This is a valid Dialog File instruction. 0 - (bytes) the index to start clearing from the stack (top is 0) 1 - (bytes) the number of values to clear from the stack. If this is 255, clear to the end.
Clear the top (arg1) values starting from arg0 off the option stack, or the end (if arg1 is 255) Octal: 376, Decimal: 254, Hex: FE This is a valid Logic File instruction. 0 - (bytes) the index to start clearing from the stack (top is 0) 1 - (bytes) the number of values to remove from the stack, If this is 255, clear to the end.
Stop execution. Octal:377, Decimal: 255, Hex: FF At some point this will be removed. This is a valid Logic File instruction. No parameters.
Command types by name (constant is the opcode in octal)
Create a new private field store
Object<string, any>
:
an object that is the private variables with new instances of any non-overridden values
Buffer return object
This Handles pass 1 compiling which just unrolls all the nested statements into a continous list of commands. Jump instructions are either referencing command indexes or node names function, variable and string references are still referencing the names. This is desiggned to run on one node at a time.
(any)
This Handles pass 2 compiling which concatenates all the nodes into one long list and builds the start of the node table (for the logic file) and dialog table (for the dialog file)
(any)
(any)
This pass converts all the commands into bytecode. It includes the lengths of all non-jump instructions Jump instructions lengths are set at the maximum possible size of the instructions
(any)
Calculate size of jump addresses now we know the rough locations of everything
(any)