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

A class declaration. More...

#include <ast.hh>

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

Public Member Functions

void interpret (Interpreter::Context &c) override
 Interpret, but constructing the class. More...
 
void collectVarUses (std::unordered_set< std::string > &decls, std::unordered_set< std::string > &uses) override
 Classes are not allowed to be declared inside closures, so there is never a need to collect their declarations. More...
 
- Public Member Functions inherited from AST::Statement
virtual void compile (Compiler::Context &c)
 Compile this statement to LLVM IR. More...
 

Public Attributes

ASTPtr< Identifier, true > name
 The name of the class. More...
 
ASTChild< IdentifiersuperclassName
 The superclass name (or class name if there is no superclass). More...
 
ASTList< Declivars
 The instance variables declared in this class. More...
 
ASTList< ClosureDeclmethods
 The methods declared in this class. More...
 

Detailed Description

A class declaration.

Classes contain instance variables and methods.

Definition at line 813 of file ast.hh.

Member Function Documentation

§ collectVarUses()

void AST::ClassDecl::collectVarUses ( std::unordered_set< std::string > &  decls,
std::unordered_set< std::string > &  uses 
)
inlineoverridevirtual

Classes are not allowed to be declared inside closures, so there is never a need to collect their declarations.

Implements AST::Statement.

Definition at line 847 of file ast.hh.

§ interpret()

void ClassDecl::interpret ( Interpreter::Context c)
overridevirtual

Interpret, but constructing the class.

Note that there is no compile method for classes. They are always interpreted, although their methods may be compiled.

Implements AST::Statement.

Definition at line 698 of file interpreter.cc.

Here is the call graph for this function:

Member Data Documentation

§ ivars

ASTList<Decl> AST::ClassDecl::ivars

The instance variables declared in this class.

Definition at line 832 of file ast.hh.

§ methods

ASTList<ClosureDecl> AST::ClassDecl::methods

The methods declared in this class.

Definition at line 836 of file ast.hh.

§ name

ASTPtr<Identifier, true> AST::ClassDecl::name

The name of the class.

AST construction happens depth-first, so this is optional even though it is really the superclass name that is optional. If a superclass is not specified, then the class name is in the superclassName field. This is because the first identifier will be popped off the AST stack when constructing superclassName, even if it were marked as optional, because the two identifiers can't be distinguished.

Definition at line 824 of file ast.hh.

§ superclassName

ASTChild<Identifier> AST::ClassDecl::superclassName

The superclass name (or class name if there is no superclass).

Definition at line 828 of file ast.hh.


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