Example #1
0
        internal EmittingContext(LLVMModuleRef pModule, LLVMPassManagerRef pPass, bool pEmitDebug)
        {
            CurrentModule       = pModule;
            _passManager        = pPass;
            _context            = LLVM.GetGlobalContext();
            _deferredStatements = new Stack <List <Syntax.SyntaxNode> >();
            Builder             = LLVM.CreateBuilder();
            _emitDebug          = pEmitDebug;
            Locals         = new ScopeCache <LocalDefinition>();
            AccessStack    = new AccessStack <MemberAccess>();
            BreakLocations = new AccessStack <LLVMValueRef>(1);

            if (_emitDebug)
            {
                _debugLocations = new Stack <LLVMMetadataRef>();
                _debugInfo      = Utils.LlvmPInvokes.LLVMCreateDIBuilder(CurrentModule);
                _debugFile      = Utils.LlvmPInvokes.LLVMDIBuilderCreateFile(_debugInfo, "debug", 5, ".", 1);

                //Set debug version
                var version = LLVM.MDNode(new LLVMValueRef[] { GetInt(1),                               //Error on mismatch
                                                               LLVM.MDString("Debug Info Version", 18), //Constant string. Cannot change.
                                                               GetInt(3) });                            //Debug version
                LLVM.AddNamedMetadataOperand(CurrentModule, "llvm.module.flags", version);
            }
        }
Example #2
0
        public ScopeCache <T> Copy()
        {
            var copy = new ScopeCache <T>()
            {
                _scopeCount = _scopeCount
            };

            Array.Copy(_variables, copy._variables, _variables.Length);
            return(copy);
        }