From 7b8251c31113cce26c1ef35731cf4fd3f6d1db58 Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Fri, 22 Nov 2019 12:28:24 -0800 Subject: [PATCH] Fixed enums in debugger, reformatting of operator constraints --- IDEHelper/Backend/BeIRCodeGen.cpp | 3 +++ IDEHelper/Compiler/BfExprEvaluator.cpp | 1 + IDEHelper/Compiler/BfIRBuilder.h | 1 + IDEHelper/Compiler/BfIRCodeGen.cpp | 1 + IDEHelper/Compiler/BfModule.cpp | 4 +++- IDEHelper/Compiler/BfModuleTypeUtils.cpp | 6 +++--- IDEHelper/Compiler/BfPrinter.cpp | 22 ++++++++++++++++++++-- IDEHelper/Compiler/BfPrinter.h | 1 + IDEHelper/DbgModule.cpp | 23 +++++++++++++++++++++-- IDEHelper/DbgModule.h | 1 + IDEHelper/WinDebugger.cpp | 24 ++++++++++-------------- 11 files changed, 65 insertions(+), 22 deletions(-) diff --git a/IDEHelper/Backend/BeIRCodeGen.cpp b/IDEHelper/Backend/BeIRCodeGen.cpp index 39e87ab4..f9b6f765 100644 --- a/IDEHelper/Backend/BeIRCodeGen.cpp +++ b/IDEHelper/Backend/BeIRCodeGen.cpp @@ -2168,6 +2168,9 @@ void BeIRCodeGen::HandleNextCmd() func->mIsDLLExport = true; else if (attribute == BFIRAttribute_DllImport) func->mIsDLLImport = true; + else if (attribute == BFIRAttribute_NoRecurse) + { + } else BF_FATAL("Unhandled"); } diff --git a/IDEHelper/Compiler/BfExprEvaluator.cpp b/IDEHelper/Compiler/BfExprEvaluator.cpp index 1c61a8b3..b5e1dbec 100644 --- a/IDEHelper/Compiler/BfExprEvaluator.cpp +++ b/IDEHelper/Compiler/BfExprEvaluator.cpp @@ -17981,3 +17981,4 @@ void BfExprEvaluator::Visit(BfBinaryOperatorExpression* binOpExpr) PerformBinaryOperation(binOpExpr->mLeft, binOpExpr->mRight, binOpExpr->mOp, binOpExpr->mOpToken, BfBinOpFlag_None); } +// \ No newline at end of file diff --git a/IDEHelper/Compiler/BfIRBuilder.h b/IDEHelper/Compiler/BfIRBuilder.h index 03ed8612..ef63d58c 100644 --- a/IDEHelper/Compiler/BfIRBuilder.h +++ b/IDEHelper/Compiler/BfIRBuilder.h @@ -593,6 +593,7 @@ enum BfIRAttribute BFIRAttribute_NoFramePointerElim, BFIRAttribute_DllImport, BFIRAttribute_DllExport, + BFIRAttribute_NoRecurse }; struct BfIRFunctionType diff --git a/IDEHelper/Compiler/BfIRCodeGen.cpp b/IDEHelper/Compiler/BfIRCodeGen.cpp index bfec3e79..1569b202 100644 --- a/IDEHelper/Compiler/BfIRCodeGen.cpp +++ b/IDEHelper/Compiler/BfIRCodeGen.cpp @@ -201,6 +201,7 @@ static llvm::Attribute::AttrKind LLVMMapAttribute(BfIRAttribute attr) case BFIRAttribute_NoUnwind: return llvm::Attribute::NoUnwind; case BFIRAttribute_UWTable: return llvm::Attribute::UWTable; case BFIRAttribute_AlwaysInline: return llvm::Attribute::AlwaysInline; + case BFIRAttribute_NoRecurse: return llvm::Attribute::NoRecurse; default: break; } return llvm::Attribute::None; diff --git a/IDEHelper/Compiler/BfModule.cpp b/IDEHelper/Compiler/BfModule.cpp index 1722055a..9e9e19d4 100644 --- a/IDEHelper/Compiler/BfModule.cpp +++ b/IDEHelper/Compiler/BfModule.cpp @@ -13877,7 +13877,9 @@ void BfModule::SetupIRMethod(BfMethodInstance* methodInstance, BfIRFunction func mBfIRBuilder->SetFuncCallingConv(func, callingConv); if (isInlined) - mBfIRBuilder->Func_AddAttribute(func, -1, BFIRAttribute_AlwaysInline); + { + mBfIRBuilder->Func_AddAttribute(func, -1, BFIRAttribute_AlwaysInline); + } int argIdx = 0; int paramIdx = 0; diff --git a/IDEHelper/Compiler/BfModuleTypeUtils.cpp b/IDEHelper/Compiler/BfModuleTypeUtils.cpp index 0ff2afef..246b4747 100644 --- a/IDEHelper/Compiler/BfModuleTypeUtils.cpp +++ b/IDEHelper/Compiler/BfModuleTypeUtils.cpp @@ -7895,7 +7895,7 @@ BfIRValue BfModule::CastToValue(BfAstNode* srcNode, BfTypedValue typedVal, BfTyp } // * -> Valueless - if (toType->IsValuelessType()) + if (toType->IsVoid()) return mBfIRBuilder->GetFakeVal(); // void* -> intptr @@ -9284,10 +9284,10 @@ BfTypedValue BfModule::Cast(BfAstNode* srcNode, const BfTypedValue& typedVal, Bf } } - if ((explicitCast) && (toType->IsValuelessType())) + /*if ((explicitCast) && (toType->IsValuelessType())) { return BfTypedValue(mBfIRBuilder->GetFakeVal(), toType); - } + }*/ BfCastResultFlags castResultFlags = BfCastResultFlags_None; auto castedValue = CastToValue(srcNode, typedVal, toType, castFlags, &castResultFlags); diff --git a/IDEHelper/Compiler/BfPrinter.cpp b/IDEHelper/Compiler/BfPrinter.cpp index c00b25ea..a9df47b0 100644 --- a/IDEHelper/Compiler/BfPrinter.cpp +++ b/IDEHelper/Compiler/BfPrinter.cpp @@ -742,6 +742,19 @@ void BfPrinter::Visit(BfGenericParamsDeclaration* genericParams) VisitChild(genericParams->mCloseChevron); } +void BfPrinter::Visit(BfGenericOperatorConstraint* genericConstraints) +{ + Visit(genericConstraints->ToBase()); + + VisitChild(genericConstraints->mOperatorToken); + ExpectSpace(); + VisitChild(genericConstraints->mLeftType); + ExpectSpace(); + VisitChild(genericConstraints->mOpToken); + ExpectSpace(); + VisitChild(genericConstraints->mRightType); +} + void BfPrinter::Visit(BfGenericConstraintsDeclaration* genericConstraints) { Visit(genericConstraints->ToBase()); @@ -1946,6 +1959,12 @@ void BfPrinter::QueueMethodDeclaration(BfMethodDeclaration* methodDeclaration) QueueVisitChild(methodDeclaration->mExplicitInterface); QueueVisitChild(methodDeclaration->mExplicitInterfaceDotToken); QueueVisitChild(methodDeclaration->mNameNode); + + if (auto operatorDecl = BfNodeDynCast(methodDeclaration)) + { + if ((operatorDecl->mOpTypeToken != NULL) && (operatorDecl->mOpTypeToken->mToken == BfToken_LChevron)) + ExpectSpace(); + } QueueVisitChild(methodDeclaration->mGenericParams); if (auto operatorDecl = BfNodeDynCast(methodDeclaration)) @@ -1953,8 +1972,7 @@ void BfPrinter::QueueMethodDeclaration(BfMethodDeclaration* methodDeclaration) ExpectSpace(); QueueVisitChild(operatorDecl->mExplicitToken); ExpectSpace(); - QueueVisitChild(operatorDecl->mOperatorToken); - ExpectSpace(); + QueueVisitChild(operatorDecl->mOperatorToken); QueueVisitChild(operatorDecl->mOpTypeToken); ExpectSpace(); QueueVisitChild(methodDeclaration->mReturnType); diff --git a/IDEHelper/Compiler/BfPrinter.h b/IDEHelper/Compiler/BfPrinter.h index ce42cb2d..bf45216c 100644 --- a/IDEHelper/Compiler/BfPrinter.h +++ b/IDEHelper/Compiler/BfPrinter.h @@ -113,6 +113,7 @@ public: virtual void Visit(BfAttributeDirective* attributeDirective) override; virtual void Visit(BfGenericParamsDeclaration* genericParams) override; + virtual void Visit(BfGenericOperatorConstraint* genericConstraints) override; virtual void Visit(BfGenericConstraintsDeclaration* genericConstraints) override; virtual void Visit(BfGenericArgumentsNode* genericArgumentsNode) override; diff --git a/IDEHelper/DbgModule.cpp b/IDEHelper/DbgModule.cpp index bc2b6d50..fca0a641 100644 --- a/IDEHelper/DbgModule.cpp +++ b/IDEHelper/DbgModule.cpp @@ -904,6 +904,24 @@ const String& DbgSrcFile::GetLocalPath() return (!mLocalPath.IsEmpty()) ? mLocalPath : mFilePath; } +void DbgSrcFile::GetHash(String& outStr) +{ + if (mHashKind == DbgHashKind_MD5) + { + for (int i = 0; i < 16; i++) + { + outStr += StrFormat("%02X", mHash[i]); + } + } + else if (mHashKind == DbgHashKind_SHA256) + { + for (int i = 0; i < 32; i++) + { + outStr += StrFormat("%02X", mHash[i]); + } + } +} + ////////////////////////////////////////////////////////////////////////// DbgType::DbgType() @@ -1393,10 +1411,11 @@ DbgType* DbgType::GetPrimaryType() if ((mCompileUnit != NULL) && ((mCompileUnit->mLanguage == DbgLanguage_Beef) || (mTypeCode == DbgType_Namespace) || (mIsDeclaration))) { - mPrimaryType = mCompileUnit->mDbgModule->GetPrimaryType(this); + mPrimaryType = mCompileUnit->mDbgModule->GetPrimaryType(this); + mTypeCode = mPrimaryType->mTypeCode; } } - + return mPrimaryType; } diff --git a/IDEHelper/DbgModule.h b/IDEHelper/DbgModule.h index ba1b41da..a2eb65a3 100644 --- a/IDEHelper/DbgModule.h +++ b/IDEHelper/DbgModule.h @@ -760,6 +760,7 @@ public: void RemoveLines(DbgModule* debugModule, DbgSubprogram* dbgSubprogram, bool isHotReplaced); void RehupLineData(); const String& GetLocalPath(); + void GetHash(String& hashStr); }; class DwCommonFrameDescriptor diff --git a/IDEHelper/WinDebugger.cpp b/IDEHelper/WinDebugger.cpp index c2e15ff7..fbe1c388 100644 --- a/IDEHelper/WinDebugger.cpp +++ b/IDEHelper/WinDebugger.cpp @@ -6433,6 +6433,8 @@ String WinDebugger::DbgTypedValueToString(const DbgTypedValue& origTypedValue, c if (dwValueType == NULL) dwValueType = dbgModule->GetPrimitiveType(DbgType_Void, language); + else + dwValueType = dwValueType->GetPrimaryType(); if (dwValueType->mTypeCode == DbgType_TypeDef) { @@ -10683,20 +10685,7 @@ String WinDebugger::GetStackFrameInfo(int stackFrameIdx, intptr* addr, String* o if (srcFile->mHashKind != DbgHashKind_None) { outStr += "#"; - if (srcFile->mHashKind == DbgHashKind_MD5) - { - for (int i = 0; i < 16; i++) - { - outStr += StrFormat("%02X", srcFile->mHash[i]); - } - } - else - { - for (int i = 0; i < 32; i++) - { - outStr += StrFormat("%02X", srcFile->mHash[i]); - } - } + srcFile->GetHash(outStr); } }; @@ -11278,6 +11267,13 @@ String WinDebugger::DisassembleAt(intptr inAddress) { srcFile = dwSubProgram->GetLineSrcFile(*dwLineData); result += "S " + srcFile->GetLocalPath() + "\n"; + if (srcFile->mHashKind != DbgHashKind_None) + { + result += "H "; + srcFile->GetHash(result); + result += "\n"; + } + curLine = BF_MAX(0, dwLineData->mLine - 5); //for (; curLine <= dwLineData->mLine; curLine++) result += StrFormat("L %d %d\n", curLine, dwLineData->mLine - curLine + 1);