33 void runOneStep(int16_t *oldgrid,
44 for (
int x=0 ; x<width ; x++)
46 for (
int y=0 ; y<height ; y++,i++)
51 bzero(state.
a,
sizeof(state.
a));
93 uint16_t v =
value->interpret(s);
94 uint16_t o =
target->interpret(s);
114 result = std::min(o,v);
117 result = std::max(o,v);
120 target->assign(s, result);
126 uint16_t input =
value->interpret(s);
127 for (
auto &range :
ranges.objects())
129 uint16_t end = range->end->value;
130 if (range->start.get())
132 uint16_t start = range->start->value;
133 if ((input >= start) && (input <= end))
135 return range->value->interpret(s);
138 else if (input == end)
140 return range->value->interpret(s);
149 for (
int x = state.
x - 1 ; x <= state.
x + 1 ; x++)
151 if (x < 0 || x >= state.
width)
continue;
152 for (
int y = state.
y - 1 ; y <= state.
y + 1 ; y++)
154 if (y < 0 || y >= state.
height)
continue;
155 if (x == state.
x && y == state.
y)
continue;
int16_t g[10]
The global registers.
virtual uint16_t interpret(Interpreter::State &) override
Interpret this node, updating the given interpreter step and returning the value (if there is one)...
pegmatite::ASTPtr< Statement > value
The value to assign to the register.
pegmatite::ASTPtr< Op > op
The operation to perform.
uint16_t value
The value for this literal.
virtual uint16_t interpret(Interpreter::State &) override
Interpret this node, updating the given interpreter step and returning the value (if there is one)...
virtual uint16_t interpret(Interpreter::State &) override
Returns the value in this register (when interpreting the AST).
int16_t x
The x coordinate of the current cell.
A list of statements that will be executed sequentially.
pegmatite::ASTPtr< Register > value
The register that is being compared against one or more ranges.
int16_t v
The current cell value.
int16_t y
The y coordinate of the current cell.
The current state for the interpreter.
int16_t * grid
The grid itself (non-owning pointer)
int16_t a[10]
The local registers.
pegmatite::ASTList< Range > ranges
The ranges in this range map.
int16_t height
The height of the grid.
virtual uint16_t interpret(Interpreter::State &) override
Interpret this node, updating the given interpreter step and returning the value (if there is one)...
int registerNumber
The number of the global register that this references.
pegmatite::ASTPtr< Register > target
The target register.
int16_t width
The width of the grid.
pegmatite::ASTList< Statement > statements
The ordered list of statements.
pegmatite::ASTPtr< StatementList > statements
The statements contained within this neighbours block.
virtual void assign(Interpreter::State &, uint16_t) override
Assigns a value to the register (when interpreting the AST).
int registerNumber
The number of the local register that this references.
virtual uint16_t interpret(Interpreter::State &) override
Interpret this node, updating the given interpreter step and returning the value (if there is one)...
virtual uint16_t interpret(Interpreter::State &) override
Returns the value in this register (when interpreting the AST).
uint16_t interpret(Interpreter::State &) override
Interpret this node, updating the given interpreter step and returning the value (if there is one)...
virtual void assign(Interpreter::State &, uint16_t) override
Assigns a value to the register (when interpreting the AST).
virtual uint16_t interpret(Interpreter::State &) override
Returns the value in this register (when interpreting the AST).
virtual void assign(Interpreter::State &, uint16_t) override
Assigns a value to the register (when interpreting the AST).