MysoreScript
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
AST::ClosureDecl Struct Reference

A closure declaration. More...

#include <ast.hh>

Inheritance diagram for AST::ClosureDecl:
Inheritance graph
[legend]
Collaboration diagram for AST::ClosureDecl:
Collaboration graph
[legend]

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< Identifiername
 The name of this closure. More...
 
ASTPtr< ParamListparameters
 The parameter list. More...
 
ASTPtr< Statementsbody
 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...
 

Detailed Description

A closure declaration.

Closures in MysoreScript represent methods, functions, or true closures.

Definition at line 473 of file ast.hh.

Member Function Documentation

§ compileExpression()

Value * ClosureDecl::compileExpression ( Compiler::Context c)
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.

Here is the call graph for this function:

§ evaluateExpr()

Obj ClosureDecl::evaluateExpr ( Interpreter::Context c)
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.

Here is the call graph for this function:

§ interpretClosure()

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.

Here is the call graph for this function:
Here is the caller graph for this function:

§ interpretMethod()

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.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

§ body

ASTPtr<Statements> AST::ClosureDecl::body

The statements that make up the body of the closure.

Definition at line 486 of file ast.hh.

§ name

ASTChild<Identifier> AST::ClosureDecl::name

The name of this closure.

Definition at line 478 of file ast.hh.

§ parameters

ASTPtr<ParamList> AST::ClosureDecl::parameters

The parameter list.

Definition at line 482 of file ast.hh.


The documentation for this struct was generated from the following files: