| 8038 | } |
| 8039 | |
| 8040 | BfMethodRefType* BfModule::CreateMethodRefType(BfMethodInstance* methodInstance, bool mustAlreadyExist) |
| 8041 | { |
| 8042 | // Make sure we don't have a partially-formed local method or lambda coming in, because those may be replaced |
| 8043 | // after the capture phase |
| 8044 | BF_ASSERT(!methodInstance->mDisallowCalling); |
| 8045 | |
| 8046 | auto methodRefType = new BfMethodRefType(); |
| 8047 | methodRefType->mContext = mContext; |
| 8048 | //methodRefType->mCaptureType = NULL; |
| 8049 | methodRefType->mMethodRef = methodInstance; |
| 8050 | methodRefType->mOwner = methodInstance->GetOwner(); |
| 8051 | methodRefType->mOwnerRevision = methodRefType->mOwner->mRevision; |
| 8052 | //methodRefType->mMangledName = BfMangler::Mangle(mCompiler->GetMangleKind(), methodInstance); |
| 8053 | methodRefType->mIsAutoCompleteMethod = methodInstance->mIsAutocompleteMethod; |
| 8054 | methodRefType->mIsUnspecialized = methodInstance->mIsUnspecialized; |
| 8055 | methodRefType->mIsUnspecializedVariation = methodInstance->mIsUnspecializedVariation; |
| 8056 | methodRefType->mSize = 0; |
| 8057 | |
| 8058 | BfResolvedTypeSet::LookupContext lookupCtx; |
| 8059 | lookupCtx.mModule = this; |
| 8060 | BfResolvedTypeSet::EntryRef typeEntry; |
| 8061 | auto inserted = mContext->mResolvedTypes.Insert(methodRefType, &lookupCtx, &typeEntry); |
| 8062 | if (typeEntry->mValue == NULL) |
| 8063 | { |
| 8064 | BF_ASSERT(!mustAlreadyExist); |
| 8065 | BF_ASSERT(!methodInstance->mHasMethodRefType); |
| 8066 | |
| 8067 | InitType(methodRefType, BfPopulateType_Identity); |
| 8068 | methodRefType->mDefineState = BfTypeDefineState_DefinedAndMethodsSlotted; |
| 8069 | |
| 8070 | methodInstance->mHasMethodRefType = true; |
| 8071 | methodInstance->mMethodInstanceGroup->mRefCount++; |
| 8072 | typeEntry->mValue = methodRefType; |
| 8073 | BfLogSysM("Create MethodRefType %p MethodInstance: %p\n", methodRefType, methodInstance); |
| 8074 | methodRefType->mRevision = 0; |
| 8075 | AddDependency(methodInstance->GetOwner(), methodRefType, BfDependencyMap::DependencyFlag_Calls); |
| 8076 | |
| 8077 | BfTypeVector tupleTypes; |
| 8078 | Array<String> tupleNames; |
| 8079 | |
| 8080 | int offset = 0; |
| 8081 | |
| 8082 | methodRefType->mAlign = 1; |
| 8083 | |
| 8084 | int dataIdx = 0; |
| 8085 | |
| 8086 | // CRepr, just because we're lazy (for now) |
| 8087 | int implicitParamCount = methodInstance->GetImplicitParamCount(); |
| 8088 | for (int implicitParamIdx = methodInstance->HasThis() ? -1 : 0; implicitParamIdx < implicitParamCount; implicitParamIdx++) |
| 8089 | { |
| 8090 | auto paramType = methodInstance->GetParamType(implicitParamIdx); |
| 8091 | if (!paramType->IsValuelessType()) |
| 8092 | { |
| 8093 | methodRefType->mDataToParamIdx.Add(implicitParamIdx); |
| 8094 | if (implicitParamIdx >= 0) |
| 8095 | methodRefType->mParamToDataIdx.Add(dataIdx); |
| 8096 | |
| 8097 | offset = BF_ALIGN(offset, paramType->mAlign); |
no test coverage detected