Browse Source

More methodref fixes

Brian Fiete 4 years ago
parent
commit
4449952235

+ 18 - 8
IDEHelper/Compiler/BfExprEvaluator.cpp

@@ -1069,7 +1069,6 @@ BfTypedValue BfMethodMatcher::ResolveArgTypedValue(BfResolvedArg& resolvedArg, B
 	BfTypedValue argTypedValue = resolvedArg.mTypedValue;
 	BfTypedValue argTypedValue = resolvedArg.mTypedValue;
 	if ((resolvedArg.mArgFlags & BfArgFlag_DelegateBindAttempt) != 0)
 	if ((resolvedArg.mArgFlags & BfArgFlag_DelegateBindAttempt) != 0)
 	{
 	{
-		//TODO: See if we can bind it to a delegate type		
 		BfExprEvaluator exprEvaluator(mModule);		
 		BfExprEvaluator exprEvaluator(mModule);		
 		exprEvaluator.mExpectingType = checkType;
 		exprEvaluator.mExpectingType = checkType;
 		BF_ASSERT(resolvedArg.mExpression->IsA<BfDelegateBindExpression>());
 		BF_ASSERT(resolvedArg.mExpression->IsA<BfDelegateBindExpression>());
@@ -1078,11 +1077,15 @@ BfTypedValue BfMethodMatcher::ResolveArgTypedValue(BfResolvedArg& resolvedArg, B
 		if (exprEvaluator.CanBindDelegate(delegateBindExpr, &boundMethodInstance, origCheckType, genericArgumentsSubstitute))
 		if (exprEvaluator.CanBindDelegate(delegateBindExpr, &boundMethodInstance, origCheckType, genericArgumentsSubstitute))
 		{
 		{
 			if (delegateBindExpr->mNewToken == NULL)
 			if (delegateBindExpr->mNewToken == NULL)
-			{
+			{				
 				if (boundMethodInstance->GetOwner()->IsFunction())
 				if (boundMethodInstance->GetOwner()->IsFunction())
 				{
 				{
 					return BfTypedValue(mModule->mBfIRBuilder->GetFakeVal(), boundMethodInstance->GetOwner());
 					return BfTypedValue(mModule->mBfIRBuilder->GetFakeVal(), boundMethodInstance->GetOwner());
 				}
 				}
+				else if (boundMethodInstance->mDisallowCalling)
+				{
+					argTypedValue = BfTypedValue(mModule->mBfIRBuilder->GetFakeVal(), checkType);
+				}
 				else
 				else
 				{
 				{
 					resolvedArg.mExpectedType = checkType;
 					resolvedArg.mExpectedType = checkType;
@@ -10378,6 +10381,13 @@ void BfExprEvaluator::Visit(BfDelegateBindExpression* delegateBindExpr)
 			return;
 			return;
 		}
 		}
 
 
+		if (bindResult.mMethodInstance->mDisallowCalling)
+		{
+			BF_ASSERT(mModule->mBfIRBuilder->mIgnoreWrites);
+			mResult = mModule->GetDefaultTypedValue(mExpectingType, false, BfDefaultValueKind_Addr);
+			return;
+		}
+
 		auto methodRefType = mModule->CreateMethodRefType(bindResult.mMethodInstance);
 		auto methodRefType = mModule->CreateMethodRefType(bindResult.mMethodInstance);
 		mModule->AddDependency(methodRefType, mModule->mCurTypeInstance, BfDependencyMap::DependencyFlag_Calls);
 		mModule->AddDependency(methodRefType, mModule->mCurTypeInstance, BfDependencyMap::DependencyFlag_Calls);
 		mModule->AddCallDependency(bindResult.mMethodInstance);
 		mModule->AddCallDependency(bindResult.mMethodInstance);
@@ -10931,12 +10941,6 @@ BfLambdaInstance* BfExprEvaluator::GetLambdaInstance(BfLambdaBindExpression* lam
 
 
 		if (invokeMethodInstance != NULL)
 		if (invokeMethodInstance != NULL)
 		{
 		{
-			if (mModule->mBfIRBuilder->mIgnoreWrites)
-			{
-				mResult = mModule->GetDefaultTypedValue(mExpectingType, false, BfDefaultValueKind_Addr);
-				return NULL;
-			}
-			
 			BfLocalMethod* localMethod = new BfLocalMethod();
 			BfLocalMethod* localMethod = new BfLocalMethod();
 			localMethod->mMethodName = "anon";
 			localMethod->mMethodName = "anon";
 			localMethod->mSystem = mModule->mSystem;
 			localMethod->mSystem = mModule->mSystem;
@@ -10951,6 +10955,12 @@ BfLambdaInstance* BfExprEvaluator::GetLambdaInstance(BfLambdaBindExpression* lam
 
 
 			auto moduleMethodInstance = mModule->GetLocalMethodInstance(localMethod, BfTypeVector());
 			auto moduleMethodInstance = mModule->GetLocalMethodInstance(localMethod, BfTypeVector());
 
 
+			if (moduleMethodInstance.mMethodInstance->mDisallowCalling)
+			{
+				mResult = mModule->GetDefaultTypedValue(mExpectingType, false, BfDefaultValueKind_Addr);
+				return NULL;
+			}
+
 			auto methodRefType = mModule->CreateMethodRefType(moduleMethodInstance.mMethodInstance);
 			auto methodRefType = mModule->CreateMethodRefType(moduleMethodInstance.mMethodInstance);
 			mModule->AddDependency(methodRefType, mModule->mCurTypeInstance, BfDependencyMap::DependencyFlag_Calls);			
 			mModule->AddDependency(methodRefType, mModule->mCurTypeInstance, BfDependencyMap::DependencyFlag_Calls);			
 			mModule->AddCallDependency(moduleMethodInstance.mMethodInstance);
 			mModule->AddCallDependency(moduleMethodInstance.mMethodInstance);

+ 5 - 2
IDEHelper/Compiler/BfModule.cpp

@@ -17141,7 +17141,7 @@ void BfModule::EmitGCFindTLSMembers()
 void BfModule::ProcessMethod(BfMethodInstance* methodInstance, bool isInlineDup)
 void BfModule::ProcessMethod(BfMethodInstance* methodInstance, bool isInlineDup)
 {
 {
 	BP_ZONE_F("BfModule::ProcessMethod %s", BP_DYN_STR(methodInstance->mMethodDef->mName.c_str()));
 	BP_ZONE_F("BfModule::ProcessMethod %s", BP_DYN_STR(methodInstance->mMethodDef->mName.c_str()));
-	
+
 	if (mAwaitingInitFinish)
 	if (mAwaitingInitFinish)
 		FinishInit();
 		FinishInit();
 
 
@@ -19694,6 +19694,8 @@ BfModuleMethodInstance BfModule::GetLocalMethodInstance(BfLocalMethod* localMeth
 		BfDeferredLocalAssignData deferredLocalAssignData(rootMethodState->mCurScope);				
 		BfDeferredLocalAssignData deferredLocalAssignData(rootMethodState->mCurScope);				
 		deferredLocalAssignData.mVarIdBarrier = rootMethodState->mCurLocalVarId;
 		deferredLocalAssignData.mVarIdBarrier = rootMethodState->mCurLocalVarId;
 		SetAndRestoreValue<BfDeferredLocalAssignData*> prevDLA(rootMethodState->mDeferredLocalAssignData, &deferredLocalAssignData);
 		SetAndRestoreValue<BfDeferredLocalAssignData*> prevDLA(rootMethodState->mDeferredLocalAssignData, &deferredLocalAssignData);
+		if (!mIgnoreErrors)
+			localMethod->mDidBodyErrorPass = true;
 
 
 		_VisitLambdaBody();
 		_VisitLambdaBody();
 		RestoreScopeState();
 		RestoreScopeState();
@@ -19907,7 +19909,8 @@ BfModuleMethodInstance BfModule::GetLocalMethodInstance(BfLocalMethod* localMeth
 
 
 	// Since we handle errors & warnings in the capture phase, we don't need to process any local methods for resolve-only (unless we're doing a mDbgVerifyCodeGen)
 	// Since we handle errors & warnings in the capture phase, we don't need to process any local methods for resolve-only (unless we're doing a mDbgVerifyCodeGen)
 	if ((!localMethod->mDeclOnly) && (!methodInstance->IsOrInUnspecializedVariation()) &&
 	if ((!localMethod->mDeclOnly) && (!methodInstance->IsOrInUnspecializedVariation()) &&
-		(!mWantsIRIgnoreWrites) && (methodDef->mMethodType != BfMethodType_Mixin))
+		(methodDef->mMethodType != BfMethodType_Mixin) &&
+		((!mWantsIRIgnoreWrites) || (!localMethod->mDidBodyErrorPass)))
 	{
 	{
 		BP_ZONE("BfDeferredLocalMethod:create");
 		BP_ZONE("BfDeferredLocalMethod:create");
 
 

+ 2 - 0
IDEHelper/Compiler/BfModule.h

@@ -220,6 +220,7 @@ public:
 	BfMixinState* mDeclMixinState;		
 	BfMixinState* mDeclMixinState;		
 	OwnedVector<BfDirectTypeReference> mDirectTypeRefs;
 	OwnedVector<BfDirectTypeReference> mDirectTypeRefs;
 	bool mDeclOnly;
 	bool mDeclOnly;
+	bool mDidBodyErrorPass;
 	BfLocalMethod* mNextWithSameName;
 	BfLocalMethod* mNextWithSameName;
 
 
 public:
 public:
@@ -237,6 +238,7 @@ public:
 		mDeclMethodState = NULL;
 		mDeclMethodState = NULL;
 		mDeclMixinState = NULL;		
 		mDeclMixinState = NULL;		
 		mDeclOnly = false;
 		mDeclOnly = false;
+		mDidBodyErrorPass = false;
 		mNextWithSameName = NULL;
 		mNextWithSameName = NULL;
 	}
 	}
 	~BfLocalMethod();
 	~BfLocalMethod();