MysoreScript
|
Abstract superclass for expressions (statements that evaluate to something). More...
#include <ast.hh>
Public Member Functions | |
virtual bool | isConstantExpression () |
Returns true if the expression is constant and therefore doesn't need interpreting every time. More... | |
Obj | evaluate (Interpreter::Context &c) |
Evaluate the expression, caching the result if it's a constant expression. More... | |
void | interpret (Interpreter::Context &c) override final |
Interpret this expression as if it were a statement. More... | |
void | compile (Compiler::Context &c) override final |
Compile this expression as if it were a statement. More... | |
virtual llvm::Value * | compileExpression (Compiler::Context &c)=0 |
Compile the expression, returning the LLVM value that represents the result of the expression. More... | |
Public Member Functions inherited from AST::Statement | |
virtual void | collectVarUses (std::unordered_set< std::string > &decls, std::unordered_set< std::string > &uses)=0 |
Recursively visit all of the children of this statement, collecting variables that are declared and used in it. More... | |
Protected Member Functions | |
virtual Obj | evaluateExpr (Interpreter::Context &c)=0 |
Evaluate the expression. More... | |
Protected Attributes | |
Interpreter::Value | cache |
Cached result for constant expression. More... | |
Abstract superclass for expressions (statements that evaluate to something).
|
inlinefinaloverridevirtual |
Compile this expression as if it were a statement.
Reimplemented from AST::Statement.
|
pure virtual |
Compile the expression, returning the LLVM value that represents the result of the expression.
Implemented in AST::Call, AST::VarRef, AST::ClosureDecl, AST::BinOpBase, AST::StringLiteral, and AST::Number.
Obj Expression::evaluate | ( | Interpreter::Context & | c | ) |
Evaluate the expression, caching the result if it's a constant expression.
Definition at line 398 of file interpreter.cc.
|
protectedpure virtual |
Evaluate the expression.
Implemented in AST::Call, AST::VarRef, AST::ClosureDecl, AST::BinOpBase, AST::StringLiteral, and AST::Number.
|
inlinefinaloverridevirtual |
Interpret this expression as if it were a statement.
Implements AST::Statement.
|
inlinevirtual |
Returns true if the expression is constant and therefore doesn't need interpreting every time.
The result will be cached after the first time.
Reimplemented in AST::BinOpBase, AST::StringLiteral, and AST::Number.
|
protected |