MysoreScript
Public Member Functions | Public Attributes | List of all members
Compiler::Context Class Reference

The compiler context. More...

#include <compiler.hh>

Collaboration diagram for Compiler::Context:
Collaboration graph
[legend]

Public Member Functions

llvm::FunctionType * getClosureType (int bound, int args)
 Get the type of a closure invoke function, for a closure with the specified number of instance variables and arguments. More...
 
llvm::FunctionType * getMethodType (int ivars, int args)
 Get the type of a method with the specified number of arguments, for an object with the specified number of instance variables. More...
 
llvm::Value * lookupSymbolAddr (const std::string &str)
 Returns the address of the specified symbol. More...
 
 Context (Interpreter::SymbolTable &g)
 Construct a context, given a global symbol table from the interpreter. More...
 
MysoreScript::ClosureInvoke compile ()
 At the end of compilation, generate code and return a function pointer. More...
 

Public Attributes

llvm::LLVMContext C
 The LLVM context. More...
 
std::unique_ptr< llvm::Module > M
 The current module. More...
 
llvm::Function * F
 The function being compiled. More...
 
llvm::IRBuilder B
 The IR builder, always set to the current insert point. More...
 
std::unordered_map< std::string, llvm::Value * > symbols
 Symbols within this compilation context. More...
 
llvm::PointerType * ObjPtrTy
 The type of a pointer to a MysoreScript object. More...
 
llvm::Type * ObjIntTy
 The type of an integer the same size as an object pointer. More...
 
llvm::Type * SelTy
 The type used for selectors. More...
 

Detailed Description

The compiler context.

Contains everything that AST nodes need to be able to compile themselves.

Definition at line 16 of file compiler.hh.

Constructor & Destructor Documentation

§ Context()

Compiler::Context::Context ( Interpreter::SymbolTable g)

Construct a context, given a global symbol table from the interpreter.

Compilation is always triggered from the interpreter.

Definition at line 73 of file compiler.cc.

Member Function Documentation

§ compile()

ClosureInvoke Compiler::Context::compile ( )

At the end of compilation, generate code and return a function pointer.

Definition at line 107 of file compiler.cc.

Here is the caller graph for this function:

§ getClosureType()

llvm::FunctionType * Compiler::Context::getClosureType ( int  bound,
int  args 
)

Get the type of a closure invoke function, for a closure with the specified number of instance variables and arguments.

Definition at line 174 of file compiler.cc.

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

§ getMethodType()

llvm::FunctionType * Compiler::Context::getMethodType ( int  ivars,
int  args 
)

Get the type of a method with the specified number of arguments, for an object with the specified number of instance variables.

Definition at line 151 of file compiler.cc.

Here is the caller graph for this function:

§ lookupSymbolAddr()

Value * Compiler::Context::lookupSymbolAddr ( const std::string &  str)

Returns the address of the specified symbol.

Definition at line 89 of file compiler.cc.

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

Member Data Documentation

§ B

llvm::IRBuilder Compiler::Context::B

The IR builder, always set to the current insert point.

Definition at line 41 of file compiler.hh.

§ C

llvm::LLVMContext Compiler::Context::C

The LLVM context.

The current implementation uses the global context, but it would be possible to extend MysoreScript to compile different functions in the background in different threads by changing this.

Definition at line 29 of file compiler.hh.

§ F

llvm::Function* Compiler::Context::F

The function being compiled.

Definition at line 37 of file compiler.hh.

§ M

std::unique_ptr<llvm::Module> Compiler::Context::M

The current module.

Each function is compiled in a separate module.

Definition at line 33 of file compiler.hh.

§ ObjIntTy

llvm::Type* Compiler::Context::ObjIntTy

The type of an integer the same size as an object pointer.

Definition at line 55 of file compiler.hh.

§ ObjPtrTy

llvm::PointerType* Compiler::Context::ObjPtrTy

The type of a pointer to a MysoreScript object.

Definition at line 51 of file compiler.hh.

§ SelTy

llvm::Type* Compiler::Context::SelTy

The type used for selectors.

Definition at line 59 of file compiler.hh.

§ symbols

std::unordered_map<std::string, llvm::Value*> Compiler::Context::symbols

Symbols within this compilation context.

This includes bound variables. The Values in this map are pointers to the storage for the variables.

Definition at line 47 of file compiler.hh.


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