示例#1
0
        private static void BuildDelegateInstance()
        {
            List <LLParameter> parametersFunction = new List <LLParameter>();

            parametersFunction.Add(LLParameter.Create(LLModule.GetOrCreatePointerType(LLModule.GetOrCreateUnsignedType(8), 1), "this"));
            sDelegateInstance = LLModule.GetOrCreateFunction("DelegateInstance", true, true, false, LLModule.GetOrCreatePointerType(LLModule.GetOrCreateUnsignedType(8), 1), parametersFunction);
        }
示例#2
0
        internal void BuildFunction()
        {
            // DONE: Convert HLMethods to LLFunctions
            List <LLParameter> parameters = new List <LLParameter>();

            foreach (HLParameter parameter in Parameters)
            {
                LLType typeParameter = parameter.Type.LLType;
                // DONE: Adjust first parameter for string constructors to additional pointer depth plus one
                if (parameter == Parameters.First() && Container == HLDomain.SystemString && !IsStatic && IsConstructor)
                {
                    typeParameter = typeParameter.PointerDepthPlusOne;
                }
                parameters.Add(LLParameter.Create(typeParameter, parameter.Name));
            }
            bool entryFunction = HLDomain.EntryMethod == this;

            mLLFunction            = LLModule.GetOrCreateFunction(entryFunction ? "main" : (Container.ToString() + "." + ToString()), entryFunction, IsExternal, IsAbstract || IsRuntimeImplemented, ReturnType.LLType, parameters);
            LLFunction.Description = Signature;
            foreach (HLParameter parameter in Parameters.Where(p => p.RequiresAddressing))
            {
                parameter.AddressableLocal = LLFunction.CreateLocal(parameter.Type.LLType, "local_" + parameter.Name);
            }
            foreach (HLLocal local in Locals)
            {
                LLFunction.CreateLocal(local.Type.LLType, local.Name);
            }
            foreach (HLTemporary temporary in Temporaries)
            {
                LLFunction.CreateLocal(temporary.Type.LLType, temporary.Name);
            }
        }
示例#3
0
        private static void BuildVTableFunctionLookup()
        {
            List <LLParameter> parametersFunction = new List <LLParameter>();

            parametersFunction.Add(LLParameter.Create(LLModule.GetOrCreatePointerType(LLModule.GetOrCreateUnsignedType(8), 1), "this"));
            parametersFunction.Add(LLParameter.Create(LLModule.GetOrCreateSignedType(32), "index"));
            sVTableFunctionLookup = LLModule.GetOrCreateFunction("VTableFunctionLookup", true, true, false, LLModule.GetOrCreatePointerType(LLModule.GetOrCreateUnsignedType(8), 1), parametersFunction);
        }
示例#4
0
        private static void BuildGCRoot()
        {
            List <LLParameter> parametersFunction = new List <LLParameter>();

            parametersFunction.Add(LLParameter.Create(LLModule.GetOrCreatePointerType(LLModule.GetOrCreateUnsignedType(8), 2), "ptrloc"));
            parametersFunction.Add(LLParameter.Create(LLModule.GetOrCreatePointerType(LLModule.GetOrCreateUnsignedType(8), 1), "metadata"));
            sGCRoot = LLModule.GetOrCreateFunction("llvm.gcroot", true, true, false, LLModule.VoidType, parametersFunction);
        }
示例#5
0
        private static void BuildGCAllocate()
        {
            List <LLParameter> parametersFunction = new List <LLParameter>();

            parametersFunction.Add(LLParameter.Create(LLModule.GetOrCreatePointerType(LLModule.GetOrCreateUnsignedType(8), 2), "this"));
            parametersFunction.Add(LLParameter.Create(LLModule.GetOrCreateUnsignedType(32), "size"));
            parametersFunction.Add(LLParameter.Create(LLModule.GetOrCreateSignedType(32), "handle"));
            sGCAllocate = LLModule.GetOrCreateFunction("GCAllocate", true, true, false, LLModule.VoidType, parametersFunction);
        }