From 5bed292e87201a33869f5cf7453cad50c557b644 Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Fri, 28 Feb 2020 13:58:12 -0800 Subject: [PATCH] Removed sized array initialization from tuples --- BeefLibs/corlib/src/NumberFormatter.bf | 14 +++++++------- .../src/Security/Cryptography/SHA256.bf | 2 +- IDE/src/ui/OutputWidget.bf | 7 +++---- IDEHelper/Compiler/BfExprEvaluator.cpp | 11 +---------- IDEHelper/Compiler/BfIRBuilder.cpp | 5 +++-- IDEHelper/Compiler/BfResolvedTypeUtils.cpp | 19 ++++++------------- IDEHelper/Compiler/BfResolvedTypeUtils.h | 6 +++--- 7 files changed, 24 insertions(+), 40 deletions(-) diff --git a/BeefLibs/corlib/src/NumberFormatter.bf b/BeefLibs/corlib/src/NumberFormatter.bf index 97450917..b52e15fc 100644 --- a/BeefLibs/corlib/src/NumberFormatter.bf +++ b/BeefLibs/corlib/src/NumberFormatter.bf @@ -109,7 +109,7 @@ namespace System 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 };*/ - private static uint64[2048] MantissaBitsTable = ( + private static uint64[2048] MantissaBitsTable = .( 4556951262222748432UL, 9113902524445496865UL, 1822780504889099373UL, 3645561009778198746UL, 7291122019556397492UL, 14582244039112794984UL, 2916448807822558996UL, 5832897615645117993UL, 11665795231290235987UL, @@ -794,7 +794,7 @@ namespace System 4602094425247528723UL, 9204188850495057447UL, 1840837770099011489UL, 3681675540198022979UL, 7363351080396045958UL); - private static int32[2048] TensExponentTable = ( + private static int32[2048] TensExponentTable = .( -323, -323, -322, -322, -322, -322, -321, -321, -321, -320, -320, -320, -319, -319, -319, -319, -318, -318, -318, -317, -317, -317, -316, -316, -316, -316, -315, -315, -315, -314, -314, -314, -313, -313, -313, -313, @@ -966,9 +966,9 @@ namespace System 284, 284, 284, 285, 285, 285, 286, 286, 286, 286, 287, 287, 287, 288, 288, 288, 289, 289, 289, 289, 290, 290, 290, 291, 291, 291, 292, 292, 292, 293, 293, 293 ); - private static char8[16] DigitLowerTable = ('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'); - private static char8[16] DigitUpperTable = ('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'); - private static int64[19] TenPowersList = ( + private static char8[16] DigitLowerTable = .('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'); + private static char8[16] DigitUpperTable = .('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'); + private static int64[19] TenPowersList = .( 1L, 10L, 100L, @@ -991,7 +991,7 @@ namespace System // DecHexDigits s a translation table from a decimal number to its // digits hexadecimal representation (e.g. DecHexDigits [34] = 0x34). - private static int32[100] DecHexDigits = ( + private static int32[100] DecHexDigits = .( 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, @@ -2749,7 +2749,7 @@ namespace System public static void GetActiveSection (StringView format, ref bool positive, bool zero, ref int32 offset, ref int32 length) { - int32[3] lens = (0,); + int32[3] lens = .(0,); int32 index = 0; int32 lastPos = 0; bool quoted = false; diff --git a/BeefLibs/corlib/src/Security/Cryptography/SHA256.bf b/BeefLibs/corlib/src/Security/Cryptography/SHA256.bf index 5a78c64e..c349bb19 100644 --- a/BeefLibs/corlib/src/Security/Cryptography/SHA256.bf +++ b/BeefLibs/corlib/src/Security/Cryptography/SHA256.bf @@ -86,7 +86,7 @@ namespace System.Security.Cryptography (ROTRIGHT!(x,17) ^ ROTRIGHT!(x,19) ^ ((x) >> 10)) } - const uint32[64] k = ( + const uint32[64] k = .( 0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5,0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5, 0xd807aa98,0x12835b01,0x243185be,0x550c7dc3,0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174, 0xe49b69c1,0xefbe4786,0x0fc19dc6,0x240ca1cc,0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da, diff --git a/IDE/src/ui/OutputWidget.bf b/IDE/src/ui/OutputWidget.bf index 0480b6be..f4f3735b 100644 --- a/IDE/src/ui/OutputWidget.bf +++ b/IDE/src/ui/OutputWidget.bf @@ -31,10 +31,9 @@ namespace IDE.ui mSelection = EditSelection(lineStart, lineEnd); var selectionText = scope String(); GetSelectionText(selectionText); - //if (selectionText.Length > 512) - //return false; - //int idx = selectionText.IndexOf("line "); + if (selectionText.Length > 1024) // Remove middle + selectionText.Remove(1024/2, selectionText.Length - 1024); int32 errLine = 0; int32 errLineChar = 0; @@ -50,7 +49,7 @@ namespace IDE.ui int32 inTextPos = -1; - for (int32 i = 1; i < Math.Min(512, selectionText.Length); i++) + for (int32 i = 1; i < selectionText.Length; i++) { if (success) break; diff --git a/IDEHelper/Compiler/BfExprEvaluator.cpp b/IDEHelper/Compiler/BfExprEvaluator.cpp index 296b741e..ab3e38cd 100644 --- a/IDEHelper/Compiler/BfExprEvaluator.cpp +++ b/IDEHelper/Compiler/BfExprEvaluator.cpp @@ -15554,16 +15554,7 @@ void BfExprEvaluator::InitializedSizedArray(BfSizedArrayType* arrayType, BfToken } void BfExprEvaluator::Visit(BfTupleExpression* tupleExpr) -{ - if (mExpectingType != NULL) - { - if (mExpectingType->IsSizedArray()) - { - InitializedSizedArray((BfSizedArrayType*)mExpectingType, tupleExpr->mOpenParen, tupleExpr->mValues, tupleExpr->mCommas, tupleExpr->mCloseParen); - return; - } - } - +{ BfTupleType* tupleType = NULL; bool hadFullMatch = false; if ((mExpectingType != NULL) && (mExpectingType->IsTuple())) diff --git a/IDEHelper/Compiler/BfIRBuilder.cpp b/IDEHelper/Compiler/BfIRBuilder.cpp index d6392e74..a662d5c4 100644 --- a/IDEHelper/Compiler/BfIRBuilder.cpp +++ b/IDEHelper/Compiler/BfIRBuilder.cpp @@ -2415,7 +2415,7 @@ void BfIRBuilder::CreateDbgTypeDefinition(BfType* type) bool useIntConstant = false; bool wasMadeAddr = false; - + String fieldName = fieldDef->mName; BfIRValue intConstant; if (constant != NULL) @@ -2424,7 +2424,8 @@ void BfIRBuilder::CreateDbgTypeDefinition(BfType* type) if (isOptimized) continue; - if (constant->mConstType == BfConstType_Array) + if ((constant->mConstType == BfConstType_Array) || + (constant->mConstType == BfConstType_AggZero)) { staticValue = ConstToMemory(staticValue); wasMadeAddr = true; diff --git a/IDEHelper/Compiler/BfResolvedTypeUtils.cpp b/IDEHelper/Compiler/BfResolvedTypeUtils.cpp index 65808f4a..606a39d6 100644 --- a/IDEHelper/Compiler/BfResolvedTypeUtils.cpp +++ b/IDEHelper/Compiler/BfResolvedTypeUtils.cpp @@ -2436,7 +2436,8 @@ int BfResolvedTypeSet::Hash(BfTypeReference* typeRef, LookupContext* ctx, BfHash { if ((arrayType->mDimensions == 1) && (arrayType->mParams.size() != 0)) { - int elemHash = Hash(arrayType->mElementType, ctx) ^ HASH_SIZED_ARRAY; + int rawElemHash = Hash(arrayType->mElementType, ctx); + int elemHash = rawElemHash ^ HASH_SIZED_ARRAY; int hashVal = (elemHash << 5) - elemHash; // Sized array @@ -2460,25 +2461,15 @@ int BfResolvedTypeSet::Hash(BfTypeReference* typeRef, LookupContext* ctx, BfHash if (typedVal.mKind == BfTypedValueKind_GenericConstValue) { int elemHash = Hash(typedVal.mType, ctx); - - /*BF_ASSERT(typedVal.mType->IsGenericParam()); - auto genericParamInstance = ctx->mModule->GetGenericParamInstance((BfGenericParamType*)typedVal.mType); - if ((genericParamInstance->mTypeConstraint == NULL) || - (!ctx->mModule->CanCast(BfTypedValue(ctx->mModule->mBfIRBuilder->GetFakeVal(), genericParamInstance->mTypeConstraint), - ctx->mModule->GetPrimitiveType(BfTypeCode_IntPtr)))) - { - ctx->mModule->Fail(StrFormat("Generic constraint '%s' is not convertible to 'int'", ctx->mModule->TypeToString(typedVal.mType).c_str()), sizeExpr); - }*/ - hashVal = ((hashVal ^ elemHash) << 5) - hashVal; return hashVal; } if (!typedVal) - ctx->mFailed = true; + ctx->mFailed = true; if (typedVal) typedVal = ctx->mModule->Cast(sizeExpr, typedVal, intType); if (typedVal) - { + { auto constant = ctx->mModule->mBfIRBuilder->GetConstant(typedVal.mValue); if (constant->mConstType == BfConstType_Undef) { @@ -3133,6 +3124,8 @@ bool BfResolvedTypeSet::Equals(BfType* lhs, BfTypeReference* rhs, LookupContext* auto rhsArrayTypeRef = BfNodeDynCastExact(rhs); if (rhsArrayTypeRef == NULL) return false; + if (!rhsArrayTypeRef->mParams.IsEmpty()) + return false; BfArrayType* lhsArrayType = (BfArrayType*) lhs; if (lhsArrayType->mDimensions != rhsArrayTypeRef->mDimensions) return false; diff --git a/IDEHelper/Compiler/BfResolvedTypeUtils.h b/IDEHelper/Compiler/BfResolvedTypeUtils.h index e35b0d05..8c73704b 100644 --- a/IDEHelper/Compiler/BfResolvedTypeUtils.h +++ b/IDEHelper/Compiler/BfResolvedTypeUtils.h @@ -2247,15 +2247,15 @@ public: BfHashFlag_AllowRef = 1, BfHashFlag_AllowGenericParamConstValue = 2 }; - + class LookupContext - { + { public: BfModule* mModule; BfTypeReference* mRootTypeRef; BfTypeDef* mRootTypeDef; BfType* mResolvedType; - bool mFailed; + bool mFailed; public: LookupContext()