private LLVMBasicBlockRef WriteReturnBlock( LLVMType Type, LLVMMethod Implementation, LLVMModuleBuilder Module) { return(WriteReturnBlock(Type.Name.ToString(), Module.DeclareVirtual(Implementation))); }
/// <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); }
/// <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); }
public IMethodBuilder DeclareMethod(IMethodSignatureTemplate Template) { var methodDef = new LLVMMethod(this, Template); declaredMethods.Add(methodDef); if (methodDef.IsStatic && methodDef.IsConstructor) { declaredStaticCtors.Add(methodDef); } return(methodDef); }
public void Initialize() { this.codeGenerator = new LLVMCodeGenerator(this); ParentMethod = GetParentMethod(this); if (ParentMethod == this && this.GetIsVirtual() && !DeclaringType.GetIsInterface()) { ParentType.RelativeVTable.CreateRelativeSlot(this); } }
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); }
/// <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); }
/// <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]); }
/// <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); }