MysoreScript
|
The compiler context. More...
#include <compiler.hh>
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... | |
The compiler context.
Contains everything that AST nodes need to be able to compile themselves.
Definition at line 16 of file compiler.hh.
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.
ClosureInvoke Compiler::Context::compile | ( | ) |
At the end of compilation, generate code and return a function pointer.
Definition at line 107 of file compiler.cc.
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.
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.
Value * Compiler::Context::lookupSymbolAddr | ( | const std::string & | str | ) |
Returns the address of the specified symbol.
Definition at line 89 of file compiler.cc.
llvm::IRBuilder Compiler::Context::B |
The IR builder, always set to the current insert point.
Definition at line 41 of file compiler.hh.
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.
llvm::Function* Compiler::Context::F |
The function being compiled.
Definition at line 37 of file compiler.hh.
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.
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.
llvm::PointerType* Compiler::Context::ObjPtrTy |
The type of a pointer to a MysoreScript object.
Definition at line 51 of file compiler.hh.
llvm::Type* Compiler::Context::SelTy |
The type used for selectors.
Definition at line 59 of file compiler.hh.
std::unordered_map<std::string, llvm::Value*> Compiler::Context::symbols |
Symbols within this compilation context.
This includes bound variables. The Value
s in this map are pointers to the storage for the variables.
Definition at line 47 of file compiler.hh.