116 lines
2.4 KiB
Markdown
116 lines
2.4 KiB
Markdown
Gir uses three types of IR, with and without offsets and flattened. Under
|
|
each section each subsection shows the properties the command object of that
|
|
type has in given IR
|
|
|
|
Without offsets
|
|
---------------
|
|
This is produced by `parse`
|
|
|
|
### add
|
|
property | value
|
|
---------|------
|
|
type | `add`
|
|
value | The number to add to current cell
|
|
|
|
Generated on `+` and `-`
|
|
|
|
### moveHead
|
|
property | value
|
|
---------|------
|
|
type | `add`
|
|
type | `moveHead`
|
|
value | The number of steps to move the tape head right
|
|
|
|
Generated on `<` and `>`
|
|
|
|
### writeByte
|
|
property | value
|
|
---------|------
|
|
type | `writeByte`
|
|
|
|
Generated on `.`
|
|
|
|
### readByte
|
|
property | value
|
|
---------|------
|
|
type | `readByte`
|
|
|
|
Generated on `,`
|
|
|
|
### loop
|
|
property | value
|
|
---------|------
|
|
type | `loop`
|
|
contents | An array of the commands making up the loop body
|
|
|
|
Generated on `[`…`]`
|
|
|
|
### clear
|
|
property | value
|
|
---------|------
|
|
type | `clear`
|
|
|
|
Not generated by the parser directly, but generated by optimizations
|
|
|
|
|
|
With offsets
|
|
------------
|
|
This is produced by the optimization pass `addOffsetProperties`
|
|
|
|
### add
|
|
property | value
|
|
---------|------
|
|
type | `add`
|
|
value | The number to add to the cell
|
|
offfset | The location of the cell relative to current tape position
|
|
|
|
### moveHead
|
|
property | value
|
|
---------|------
|
|
type | `moveHead`
|
|
value | The number of steps to move the tape head right
|
|
|
|
### writeByte
|
|
property | value
|
|
---------|------
|
|
type | `writeByte`
|
|
offset | The location of the cell relative to current tape position
|
|
|
|
### readByte
|
|
property | value
|
|
---------|------
|
|
type | `readByte`
|
|
offset | The location of the cell relative to current tape position
|
|
|
|
### loop
|
|
property | value
|
|
-----------|------
|
|
type | `loop`
|
|
contents | An array of the commands making up the loop body
|
|
isBalanced | Whether execution of the loop body ends in same cell it started in
|
|
|
|
### clear
|
|
property | value
|
|
---------|------
|
|
type | `clear`
|
|
offset | The location of the cell relative to current tape position
|
|
|
|
|
|
Flattened
|
|
---------
|
|
This is produced by the optimization pass `flattenLoops`. `loop` doesn't
|
|
exist in flattened IR, but all other unlisted commands are the same as in IR
|
|
with offsets
|
|
|
|
### jumpIfZero
|
|
property | value
|
|
---------|------
|
|
type | `jumpIfZero`
|
|
target | The index of the command to jump to if the current cell is zero
|
|
|
|
### jumpIfNonZero
|
|
property | value
|
|
---------|------
|
|
type | `jumpIfNonZero`
|
|
target | The index of the command to jump to if the current cell is nonzero
|