public LinkBindPtr Register(DllFunction function) { if (this.m_dllNameLookup.TryGetValue($"{function}@{function.Source}", out ulong ptr)) { return(new LinkBindPtr(function.Source, ptr)); } else { BindValue bv = new BindValue(function.Source, function.ToString()); this.m_boundMethods.Add(this.m_nextPtr, bv); this.m_dllNameLookup.Add($"{function}@{function.Source}", this.m_nextPtr); LinkBindPtr nPtr = new LinkBindPtr(function.Source, this.m_nextPtr); this.m_nextPtr++; return(nPtr); } }
private LinkerResult LinkExternalMethod(ClassType klass, FuncDeclNode funcDecl, ExternalFunctionType type, LinkingType lnkType) { // Get best external match var external = klass is null?this.GetDllFunction(type.Name) : this.GetDllFunction(klass.Name, type.Name); // Make sure there's an external to bind to if (!external.HasValue) { return(new LinkerResult(false)); } else { DllFunction func = external.Value; if (lnkType is not null) { lnkType.MethodPtrs.Add(type.Name, this.m_bindings.Register(func)); } } // Return true (Fails by following bail-out-fast, so when reaching this point it's always success) return(new LinkerResult(true)); }