From 38dd2cc18310908849ef030f0f785aed78381972 Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Wed, 27 Nov 2019 08:02:15 -0800 Subject: [PATCH] Fixed typealias dependencies --- IDE/mintest/minlib/src/System/Object.bf | 4 ++ IDE/mintest/mintest2/src/main4.bf | 28 +----------- IDE/mintest/src/main2.bf | 25 ++++++++-- IDE/mintest/src/main3.bf | 61 +++++++++++++++++++++---- IDEHelper/Compiler/BfAst.h | 1 + IDEHelper/Compiler/BfContext.cpp | 3 +- IDEHelper/Compiler/BfReducer.cpp | 25 +++++++--- 7 files changed, 100 insertions(+), 47 deletions(-) diff --git a/IDE/mintest/minlib/src/System/Object.bf b/IDE/mintest/minlib/src/System/Object.bf index 0e90653e..1a629c4e 100644 --- a/IDE/mintest/minlib/src/System/Object.bf +++ b/IDE/mintest/minlib/src/System/Object.bf @@ -15,7 +15,11 @@ namespace System void Print(String outString); } +#if BF_LARGE_COLLECTIONS + typealias int_cosize = int64; +#else typealias int_cosize = int32; +#endif [AlwaysInclude] static class CompilerSettings diff --git a/IDE/mintest/mintest2/src/main4.bf b/IDE/mintest/mintest2/src/main4.bf index 4e230658..a990952a 100644 --- a/IDE/mintest/mintest2/src/main4.bf +++ b/IDE/mintest/mintest2/src/main4.bf @@ -1,35 +1,9 @@ using System; // Zapples -struct StructA -{ - public T mVal; - public static bool operator< (StructA lhs, TOther rhs) where bool : operator T < TOther - { - return true; - } - /*public static TResult operator+(StructA lhs, TOther rhs) - where TResult = operator T * TOther - { - return lhs.mVal * rhs; - }*/ -} -class TestA -{ - - - public void Bloop() - { - StructA sa; - sa.mVal = 1.23f; - let res = sa < 100; - - int a = 1 * 2; - } -} /*class Mintest2 { @@ -59,4 +33,4 @@ class TestA 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 + 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 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1; } -}*/ \ No newline at end of file +}*/ diff --git a/IDE/mintest/src/main2.bf b/IDE/mintest/src/main2.bf index a789c4d5..4a784182 100644 --- a/IDE/mintest/src/main2.bf +++ b/IDE/mintest/src/main2.bf @@ -1,9 +1,24 @@ -class Snorf -{ - int mA; +using System; - struct Bloog +#define SMz + +#if SM +typealias int_test = int32; +#else +typealias int_test = int64; +#endif + +struct Floof +{ + public static int32 Hey() { - int mA; + Result res = 123; + switch (res) + { + case .Ok(let val): + default: + } + + return 123; } } diff --git a/IDE/mintest/src/main3.bf b/IDE/mintest/src/main3.bf index d6345046..c1d30376 100644 --- a/IDE/mintest/src/main3.bf +++ b/IDE/mintest/src/main3.bf @@ -143,22 +143,67 @@ struct Blurg return 0; } + static mixin ScopedAlloc(int size, int align) + { + //(void*)scope:mixin [Align(align)] uint8[size]* { ? } + } + + public static void TestAlloc() + { + int i = 1; + if (i == 1) + { + int size = 128; + scope:: int[size]*; + } + } + + struct StructA + { + public int[10] mA; + } + + enum EnumA + { + case None; + case A(StructA sa); + } + + enum EnumB + { + case A; + case B(int a, int b); + } + public static int32 Hey() { - TypeCode tc = .Boolean; - //int h = GetHash(tc); + //int_test val = 123; - var val = tc.Underlying; - var valRef = ref tc.UnderlyingRef; + (int, int) tup = (1, 3); - let maxVal = typeof(TypeCode).MaxValue; + switch (tup) + { + case (1, var ref a): + a++; + PrintF("A\n"); + default: + PrintF("B\n"); + } - int a = 100; + + if (tup case (1, var ref aa)) + { + aa += 100; + } - String str = new:gCRTAlloc String(a); + /*EnumB eb = .B(1, 2); - delete:gCRTAlloc str; + if (eb case .B(1, var ref bb)) + { + }*/ + + return 123; } diff --git a/IDEHelper/Compiler/BfAst.h b/IDEHelper/Compiler/BfAst.h index 17125456..9fb75587 100644 --- a/IDEHelper/Compiler/BfAst.h +++ b/IDEHelper/Compiler/BfAst.h @@ -1000,6 +1000,7 @@ public: //mParent = NULL; mTriviaStart = -1; mSrcStart = 0x7FFFFFFF; + mSrcEnd = 0; //mSrcEnd = 0; #endif } diff --git a/IDEHelper/Compiler/BfContext.cpp b/IDEHelper/Compiler/BfContext.cpp index d85196e7..f3aa060d 100644 --- a/IDEHelper/Compiler/BfContext.cpp +++ b/IDEHelper/Compiler/BfContext.cpp @@ -1090,7 +1090,8 @@ void BfContext::TypeDataChanged(BfDependedType* dType, bool isNonStaticDataChang bool hadChange = false; if ((dependencyFlags & BfDependencyMap::DependencyFlag_DerivedFrom) || - (dependencyFlags & BfDependencyMap::DependencyFlag_ValueTypeMemberData)) + (dependencyFlags & BfDependencyMap::DependencyFlag_ValueTypeMemberData) || + (dependencyFlags & BfDependencyMap::DependencyFlag_NameReference)) { hadChange = true; } diff --git a/IDEHelper/Compiler/BfReducer.cpp b/IDEHelper/Compiler/BfReducer.cpp index d61abf9e..065d0bc1 100644 --- a/IDEHelper/Compiler/BfReducer.cpp +++ b/IDEHelper/Compiler/BfReducer.cpp @@ -367,6 +367,7 @@ bool BfReducer::IsTypeReference(BfAstNode* checkNode, BfToken successToken, int* bool hadTupleComma = false; bool hadIdentifier = false; bool foundSuccessToken = false; + bool hadUnexpectedIdentifier = false; BfTokenNode* lastToken = NULL; //while (checkNode != NULL) @@ -425,6 +426,12 @@ bool BfReducer::IsTypeReference(BfAstNode* checkNode, BfToken successToken, int* success = (chevronDepth == 0) && (bracketDepth == 0) && (parenDepth == 0); } + if ((success) || (doEnding)) + { + if ((!hadTupleComma) && (hadUnexpectedIdentifier)) // Looked like a tuple but wasn't + return false; + } + if (success) { if (outEndNode != NULL) @@ -811,13 +818,17 @@ bool BfReducer::IsTypeReference(BfAstNode* checkNode, BfToken successToken, int* // Identifier is always allowed in tuple (parenDepth == 0), because it's potentially the field name // (successToken == BfToken_RParen) infers we are already checking inside parentheses, such as // when we see a potential cast expression - if ((!identifierExpected) && (parenDepth == 0) && (successToken != BfToken_RParen)) + if (!identifierExpected) { - if (outEndNode != NULL) - *outEndNode = checkIdx; - if (successToken == BfToken_None) - return chevronDepth == 0; - return false; + if ((parenDepth == 0) && (successToken != BfToken_RParen)) + { + if (outEndNode != NULL) + *outEndNode = checkIdx; + if (successToken == BfToken_None) + return chevronDepth == 0; + return false; + } + hadUnexpectedIdentifier = true; } hadIdentifier = true; @@ -847,6 +858,8 @@ bool BfReducer::IsTypeReference(BfAstNode* checkNode, BfToken successToken, int* } if (outEndNode != NULL) *outEndNode = checkIdx; + if ((!hadTupleComma) && (hadUnexpectedIdentifier)) // Looked like a tuple but wasn't + return false; return (hadIdentifier) && (chevronDepth == 0) && (bracketDepth == 0) && (parenDepth == 0) && ((successToken == BfToken_None) || (foundSuccessToken)); }