示例#1
0
 public static LLGlobal Create(LLType pType, string pIdentifier)
 {
     LLGlobal global = new LLGlobal();
     global.mType = pType;
     global.mIdentifier = pIdentifier;
     return global;
 }
示例#2
0
        public static LLGlobal CreateGlobal(LLType pType, string pIdentifier)
        {
            LLGlobal global = LLGlobal.Create(pType, pIdentifier);

            sGlobals.Add(global.Identifier, global);
            return(global);
        }
示例#3
0
        public static LLGlobal GetGlobal(string pIdentifier)
        {
            LLGlobal global = null;

            sGlobals.TryGetValue(pIdentifier, out global);
            return(global);
        }
示例#4
0
        public static LLGlobal Create(LLType pType, string pIdentifier)
        {
            LLGlobal global = new LLGlobal();

            global.mType       = pType;
            global.mIdentifier = pIdentifier;
            return(global);
        }
示例#5
0
        private static void BuildRuntimeMethodData(HLStringTable pStringTable)
        {
            List<LLType> fieldsRuntimeMethodData = sSystemRuntimeMethodData.Fields.Where(f => !f.IsStatic).ToList().ConvertAll(f => f.Type.LLType);
            LLType typePointer = LLModule.GetOrCreatePointerType(LLModule.GetOrCreateUnsignedType(8), 1);
            LLType typeRuntimeMethodData = LLModule.GetOrCreateStructureType("RuntimeMethodData", true, fieldsRuntimeMethodData);
            LLType typeRuntimeMethodDataTable = LLModule.GetOrCreateArrayType(typeRuntimeMethodData, sMethods.Values.Count);
            LLGlobal globalRuntimeMethodDataTable = LLModule.CreateGlobal(typeRuntimeMethodDataTable.PointerDepthPlusOne, "RuntimeMethodDataTable");
            List<LLLiteral> literalsRuntimeMethodDataTable = new List<LLLiteral>();
            List<LLFunction> functionsRuntimeMethodDataFunctionTable = new List<LLFunction>();
            List<LLLiteral> literalsRuntimeMethodDataFunctionTable = new List<LLLiteral>();

            foreach (HLMethod method in sMethods.Values.OrderBy(m => m.RuntimeMethodHandle))
            {
                int flags = 0;
                if (method.IsStatic) flags |= 1 << 0;

                string definitionName = method.Definition.Name.Value;
                int offsetName = pStringTable.Include(definitionName);

                literalsRuntimeMethodDataTable.Add(typeRuntimeMethodData.ToLiteral(method.RuntimeMethodHandle.ToString(), flags.ToString(), offsetName.ToString()));

                LLFunction function = method.LLFunction;
                functionsRuntimeMethodDataFunctionTable.Add(function);
                string literalAddress = null;
                if (method.LLFunction.Abstract) literalAddress = "null";
                else literalAddress = string.Format("bitcast({0} {1} to {2})", LLModule.GetOrCreatePointerType(function.FunctionType, 1), function, typePointer);
                literalsRuntimeMethodDataFunctionTable.Add(LLLiteral.Create(typePointer, literalAddress));
            }
            globalRuntimeMethodDataTable.InitialValue = typeRuntimeMethodDataTable.ToLiteral(literalsRuntimeMethodDataTable.ConvertAll(l => l.Value).ToArray());
            LLGlobal globalRuntimeMethodDataTableCount = LLModule.CreateGlobal(LLModule.GetOrCreateSignedType(32), "RuntimeMethodDataTableCount");
            globalRuntimeMethodDataTableCount.InitialValue = LLLiteral.Create(LLModule.GetOrCreateSignedType(32), sMethods.Values.Count.ToString());

            LLType typeRuntimeMethodDataFunctionTable = LLModule.GetOrCreateArrayType(typePointer, functionsRuntimeMethodDataFunctionTable.Count);
            LLGlobal globalRuntimeMethodDataFunctionTable = LLModule.CreateGlobal(typeRuntimeMethodDataFunctionTable.PointerDepthPlusOne, "RuntimeMethodDataFunctionTable");
            globalRuntimeMethodDataFunctionTable.InitialValue = typeRuntimeMethodDataFunctionTable.ToLiteral(literalsRuntimeMethodDataFunctionTable.ConvertAll(l => l.Value).ToArray());
            LLGlobal globalRuntimeMethodDataFunctionTableCount = LLModule.CreateGlobal(LLModule.GetOrCreateSignedType(32), "RuntimeMethodDataFunctionTableCount");
            globalRuntimeMethodDataFunctionTableCount.InitialValue = LLLiteral.Create(LLModule.GetOrCreateSignedType(32), functionsRuntimeMethodDataFunctionTable.Count.ToString());

            sRuntimeMethodDataFunctionTable = globalRuntimeMethodDataFunctionTable;
        }