瀏覽代碼

Fixed some nullable splat cases

Brian Fiete 2 月之前
父節點
當前提交
192c9d8f33
共有 2 個文件被更改,包括 8 次插入1 次删除
  1. 2 0
      IDEHelper/Compiler/BfModule.cpp
  2. 6 1
      IDEHelper/Compiler/BfStmtEvaluator.cpp

+ 2 - 0
IDEHelper/Compiler/BfModule.cpp

@@ -14159,6 +14159,8 @@ BfIRValue BfModule::ExtractValue(BfTypedValue typedValue, int dataIdx)
 		auto addrVal = mBfIRBuilder->CreateInBoundsGEP(typedValue.mValue, 0, dataIdx);
 		return mBfIRBuilder->CreateAlignedLoad(addrVal, typedValue.mType->mAlign);
 	}
+	if (typedValue.IsSplat())
+		typedValue = LoadOrAggregateValue(typedValue);
 	return mBfIRBuilder->CreateExtractValue(typedValue.mValue, dataIdx);
 }
 

+ 6 - 1
IDEHelper/Compiler/BfStmtEvaluator.cpp

@@ -1519,9 +1519,14 @@ BfLocalVariable* BfModule::HandleVariableDeclaration(BfVariableDeclaration* varD
 			if (!resolvedType->IsNullable())
 			{
 				if (initValue.IsAddr())
+				{
 					initValue = BfTypedValue(mBfIRBuilder->CreateInBoundsGEP(initValue.mValue, 0, 1), initValue.mType->GetUnderlyingType(), true);
+				}
 				else
+				{
+					initValue = LoadOrAggregateValue(initValue);
 					initValue = BfTypedValue(mBfIRBuilder->CreateExtractValue(initValue.mValue, 1), initValue.mType->GetUnderlyingType());
+				}
 			}
 
 			if ((initValue) && (!initValue.mType->IsValuelessType()))
@@ -1600,7 +1605,7 @@ BfLocalVariable* BfModule::HandleVariableDeclaration(BfVariableDeclaration* varD
 					{
 						auto nullableElementType = initValue.mType->GetUnderlyingType();
 						auto boolType = GetPrimitiveType(BfTypeCode_Boolean);
-						initValue = LoadValue(initValue);
+						initValue = LoadOrAggregateValue(initValue);
 						exprEvaluator->mResult = BfTypedValue(mBfIRBuilder->CreateExtractValue(initValue.mValue, nullableElementType->IsValuelessType() ? 1 : 2), boolType);
 						handledExprBoolResult = true;
 						if (!nullableElementType->IsValuelessType())