コード例 #1
0
 private LLVMBasicBlockRef WriteReturnBlock(
     LLVMType Type,
     LLVMMethod Implementation,
     LLVMModuleBuilder Module)
 {
     return(WriteReturnBlock(Type.Name.ToString(), Module.DeclareVirtual(Implementation)));
 }
コード例 #2
0
ファイル: LLVMType.cs プロジェクト: jonathanvdc/flame-llvm
        /// <summary>
        /// Creates a relative vtable slot for the given method.
        /// </summary>
        /// <param name="Method">The method to create a vtable slot for.</param>
        /// <returns>A vtable slot.</returns>
        public int CreateRelativeSlot(LLVMMethod Method)
        {
            int slot = contents.Count;

            contents.Add(Method);
            slots.Add(Method, slot);
            return(slot);
        }
コード例 #3
0
ファイル: LLVMType.cs プロジェクト: jonathanvdc/flame-llvm
        /// <summary>
        /// Gets the absolute vtable slot for the given method.
        /// </summary>
        /// <param name="Method">The method to get the absolute vtable slot for.</param>
        /// <returns>An absolute vtable slot.</returns>
        public int GetAbsoluteSlot(LLVMMethod Method)
        {
            int slot;

            if (!absSlots.TryGetValue(Method, out slot))
            {
                slot             = GetAbsoluteSlot(Method.ParentMethod);
                absSlots[Method] = slot;
            }
            return(slot);
        }
コード例 #4
0
ファイル: LLVMType.cs プロジェクト: jonathanvdc/flame-llvm
        public IMethodBuilder DeclareMethod(IMethodSignatureTemplate Template)
        {
            var methodDef = new LLVMMethod(this, Template);

            declaredMethods.Add(methodDef);
            if (methodDef.IsStatic && methodDef.IsConstructor)
            {
                declaredStaticCtors.Add(methodDef);
            }
            return(methodDef);
        }
コード例 #5
0
 public void Initialize()
 {
     this.codeGenerator = new LLVMCodeGenerator(this);
     ParentMethod       = GetParentMethod(this);
     if (ParentMethod == this &&
         this.GetIsVirtual() &&
         !DeclaringType.GetIsInterface())
     {
         ParentType.RelativeVTable.CreateRelativeSlot(this);
     }
 }
コード例 #6
0
        private static LLVMMethod GetParentMethod(LLVMMethod Method)
        {
            var result = Method;

            foreach (var baseMethod in Method.BaseMethods)
            {
                if (baseMethod is LLVMMethod && !baseMethod.DeclaringType.GetIsInterface())
                {
                    result = (LLVMMethod)baseMethod;
                    break;
                }
            }
            return(result);
        }
コード例 #7
0
        /// <summary>
        /// Gets the interface stub for the given method.
        /// </summary>
        /// <param name="Method">The method to get the interface stub of.</param>
        /// <returns>An interface stub.</returns>
        public InterfaceStub GetInterfaceStub(LLVMMethod Method)
        {
            InterfaceStub stub;

            if (!interfaceStubs.TryGetValue(Method, out stub))
            {
                var retType    = PointerType(DeclarePrototype(Method), 0);
                var paramTypes = new LLVMTypeRef[] { Int64Type() };
                var stubFunc   = AddFunction(
                    module,
                    Method.Abi.Mangler.Mangle(Method, true) + "_stub",
                    FunctionType(retType, paramTypes, false));
                stubFunc.SetLinkage(LLVMLinkage.LLVMInternalLinkage);

                stub = new InterfaceStub(stubFunc);
                interfaceStubs[Method] = stub;
            }
            return(stub);
        }
コード例 #8
0
ファイル: LLVMType.cs プロジェクト: jonathanvdc/flame-llvm
 /// <summary>
 /// Gets the relative vtable slot for the given method.
 /// </summary>
 /// <param name="Method">The method to get a vtable slot for.</param>
 /// <returns>A vtable slot.</returns>
 public int GetRelativeSlot(LLVMMethod Method)
 {
     return(slots[Method]);
 }
コード例 #9
0
 /// <summary>
 /// Registers the given method as the implementation for the given type.
 /// </summary>
 /// <param name="Type">The type that implements the method.</param>
 /// <param name="Method">The implementation method.</param>
 public void Implement(LLVMType Type, LLVMMethod Method)
 {
     impls.Add(Type, Method);
 }