Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LoreLLVMCompiler"/> class.
        /// </summary>
        /// <param name="root">The AST root.</param>
        LoreLLVMCompiler(AstRoot root, LoreModule module, SymbolTable table = null)
        {
            // Initialize x86 target
            LLVM.InitializeX86Target();
            LLVM.InitializeX86TargetInfo();
            LLVM.InitializeX86AsmPrinter();
            LLVM.InitializeX86TargetMC();
            LLVM.LinkInMCJIT();

            // Assign parameters
            Root       = root;
            LoreModule = module;
            Table      = table ?? SymbolTable.Create();

            // Create the type helper
            Helper = TypeHelper.Create(this);

            // Create the stack
            Stack = new Stack <Symbol> (capacity: 512);

            // Create LLVM constants
            LLVMFalse = new LLVMBool(0);
            LLVMTrue  = new LLVMBool(1);
            LLVMNull  = new LLVMValueRef(IntPtr.Zero);

            // Create the LLVM IR builder
            Builder = LLVM.CreateBuilder();

            // Create the LLVM module
            LLVMModule = LLVM.ModuleCreateWithName(module.Name);
        }
Пример #2
0
 // TODO: Implement this
 public static bool ResolveModule(string id, out LoreModule module)
 {
     module = null;
     return(false);
 }
Пример #3
0
 public static LoreLLVMCompiler Create(AstRoot root, LoreModule module)
 {
     return(new LoreLLVMCompiler(root, module));
 }
Пример #4
0
 public static LoreLLVMCompiler Create(SymbolTable symbols, AstRoot root, LoreModule module)
 {
     return(new LoreLLVMCompiler(root, module, symbols));
 }