瀏覽代碼

Allowing allocation of arrays by uint size instead of just int

Brian Fiete 6 年之前
父節點
當前提交
fbd4e14fb6
共有 1 個文件被更改,包括 14 次插入1 次删除
  1. 14 1
      IDEHelper/Compiler/BfExprEvaluator.cpp

+ 14 - 1
IDEHelper/Compiler/BfExprEvaluator.cpp

@@ -10326,7 +10326,20 @@ void BfExprEvaluator::Visit(BfObjectCreateExpression* objCreateExpr)
 						}
 						}
 
 
 						if (arg != NULL)
 						if (arg != NULL)
-							dimLength = mModule->CreateValueFromExpression(expr, intType);
+						{							
+							dimLength = mModule->CreateValueFromExpression(expr, intType, BfEvalExprFlags_NoCast);
+							
+							BfCastFlags castFlags = BfCastFlags_None;
+							if (dimLength.mType->IsInteger())
+							{
+								// Allow uint for size - just force to int
+								if (!((BfPrimitiveType*)dimLength.mType)->IsSigned())
+									castFlags = BfCastFlags_Explicit;
+							}
+							if (dimLength)
+								dimLength = mModule->Cast(expr, dimLength, intType, castFlags);
+						}
+
 						if (!dimLength)
 						if (!dimLength)
 						{
 						{
 							dimLength = mModule->GetDefaultTypedValue(intType);
 							dimLength = mModule->GetDefaultTypedValue(intType);