MysoreScript
|
A closure declaration. More...
#include <ast.hh>
Public Member Functions | |
Obj | interpretClosure (Interpreter::Context &c, MysoreScript::Closure *self, Obj *args) |
Interprets the closure in the current context. More... | |
Obj | interpretMethod (Interpreter::Context &c, MysoreScript::Method *mth, Obj self, MysoreScript::Selector sel, Obj *args) |
Interprets the closure, assuming that it is a method. More... | |
Public Member Functions inherited from AST::Expression | |
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... | |
Public Attributes | |
ASTChild< Identifier > | name |
The name of this closure. More... | |
ASTPtr< ParamList > | parameters |
The parameter list. More... | |
ASTPtr< Statements > | body |
The statements that make up the body of the closure. More... | |
Protected Member Functions | |
Obj | evaluateExpr (Interpreter::Context &c) override |
Evaluate this closure, returning the closure object representing it. More... | |
llvm::Value * | compileExpression (Compiler::Context &c) override |
Compile the closure declaration. More... | |
Additional Inherited Members | |
Protected Attributes inherited from AST::Expression | |
Interpreter::Value | cache |
Cached result for constant expression. More... | |
A closure declaration.
Closures in MysoreScript represent methods, functions, or true closures.
|
overrideprotectedvirtual |
Compile the closure declaration.
This does not compile the closure itself, it merely generates code that constructs a Closure
object with the correct bound variables.
Implements AST::Expression.
Definition at line 377 of file compiler.cc.
|
overrideprotectedvirtual |
Evaluate this closure, returning the closure object representing it.
This is not invoked for methods, because classes are responsible for creating the method table entries corresponding to their methods.
Implements AST::Expression.
Definition at line 492 of file interpreter.cc.
Obj ClosureDecl::interpretClosure | ( | Interpreter::Context & | c, |
MysoreScript::Closure * | self, | ||
Obj * | args | ||
) |
Interprets the closure in the current context.
When closures are created, one of their instance variables is the AST for that closure, the remaining fields are the bound variables
Definition at line 571 of file interpreter.cc.
Obj ClosureDecl::interpretMethod | ( | Interpreter::Context & | c, |
MysoreScript::Method * | mth, | ||
Obj | self, | ||
MysoreScript::Selector | sel, | ||
Obj * | args | ||
) |
Interprets the closure, assuming that it is a method.
The AST is stored in the class, so can be looked up when the method must be executed.
Definition at line 521 of file interpreter.cc.
ASTPtr<Statements> AST::ClosureDecl::body |
ASTChild<Identifier> AST::ClosureDecl::name |
ASTPtr<ParamList> AST::ClosureDecl::parameters |