21 #ifndef CELLATOM_AST_H_INCLUDED
22 #define CELLATOM_AST_H_INCLUDED
24 #include "Pegmatite/pegmatite.hh"
40 void runOneStep(int16_t *oldgrid,
57 typedef void(*automaton)(int16_t *oldgrid,
114 virtual void construct(
const pegmatite::InputRange &r,
115 pegmatite::ASTStack &st)
override;
165 virtual void construct(
const pegmatite::InputRange &r,
166 pegmatite::ASTStack &st)
override;
183 virtual void construct(
const pegmatite::InputRange &r,
184 pegmatite::ASTStack &st)
override;
194 struct Op: pegmatite::ASTNode
209 virtual void construct(
const pegmatite::InputRange &r,
210 pegmatite::ASTStack &st)
override;
221 pegmatite::ASTPtr<Op>
op;
239 struct Range :
public pegmatite::ASTContainer
249 pegmatite::ASTPtr<Literal>
end;
291 #endif // CELLATOM_AST_H_INCLUDED
AST node for a neighbours expression.
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.
pegmatite::ASTPtr< Statement > value
The value to use when if this range is matched.
virtual uint16_t interpret(Interpreter::State &)=0
Returns the value in this register (when interpreting the AST).
virtual llvm::Value * compile(Compiler::State &)=0
Compile this node, returning the LLVM value representing the result, if there is one.
Abstract base class for all register types in the AST.
A range within a range expression.
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).
Arithmetic nodes, for example '+ a0 12' (add the value 12 to register a0).
virtual void assign(Interpreter::State &, uint16_t)=0
Assigns a value to the register (when interpreting the AST).
virtual llvm::Value * compile(Compiler::State &) override
Returns an LLVM value representing an access to this register (when compiling).
A list of statements that will be executed sequentially.
A range expression, for example [ a0 | (2,3) => 1] (if the value of register a0 is 2-3 inclusive...
Value representing the operation to use in an arithmetic / assignment statement.
pegmatite::ASTPtr< Register > value
The register that is being compared against one or more ranges.
virtual llvm::Value * compile(Compiler::State &) override
Returns an LLVM value representing an access to this register (when compiling).
virtual llvm::Value * compile(Compiler::State &) override
Compile this node, returning the LLVM value representing the result, if there is one.
virtual uint16_t interpret(Interpreter::State &)=0
Interpret this node, updating the given interpreter step and returning the value (if there is one)...
The current state for the interpreter.
pegmatite::ASTPtr< Literal, true > start
The start value for expressions of the form (start, end) =>
virtual llvm::Value * compile(Compiler::State &) override
Compile this node, returning the LLVM value representing the result, if there is one.
pegmatite::ASTList< Range > ranges
The ranges in this range map.
OpKind
The type of operation to perform.
virtual uint16_t interpret(Interpreter::State &) override
Interpret this node, updating the given interpreter step and returning the value (if there is one)...
The v register, which represents the current value in the grid.
virtual llvm::Value * compile(Compiler::State &) override
Returns an LLVM value representing an access to this register (when compiling).
int registerNumber
The number of the global register that this references.
pegmatite::ASTPtr< Register > target
The target register.
virtual llvm::Value * compile(Compiler::State &) override
Compile this node, returning the LLVM value representing the result, if there is one.
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.
A reference to one of the ten local registers, whose values are initially zero on entry into the cell...
Root class for all statement AST nodes in the Cellular Automata grammar.
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< Literal > end
The end value for values that have a start and end, or the single value where only one is given...
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)...
A reference to one of the ten global registers, whose values are only reset after updating an entire ...
virtual void assign(Interpreter::State &, uint16_t) override
Assigns a value to the register (when interpreting the AST).
virtual llvm::Value * compile(Compiler::State &) override
Compile this node, returning the LLVM value representing the result, if there is one.
virtual llvm::Value * compile(Compiler::State &) override
Compile this node, returning the LLVM value representing the result, if there is one.
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).
virtual llvm::Value * compile(Compiler::State &)=0
Returns an LLVM value representing an access to this register (when compiling).