diff --git a/IDEHelper/Backend/BeMCContext.cpp b/IDEHelper/Backend/BeMCContext.cpp index 189af789..d8382c3d 100644 --- a/IDEHelper/Backend/BeMCContext.cpp +++ b/IDEHelper/Backend/BeMCContext.cpp @@ -2128,7 +2128,6 @@ String BeMCContext::ToString(const BeMCOperand& operand) if (operand.mKind == BeMCOperandKind_ConstAgg) { BeDumpContext dumpContext; - dumpContext.mModule = mBeFunction->mModule; String str = "const "; str += dumpContext.ToString(operand.mConstant); return str; diff --git a/IDEHelper/Backend/BeModule.cpp b/IDEHelper/Backend/BeModule.cpp index 7c17ae19..a6810d9a 100644 --- a/IDEHelper/Backend/BeModule.cpp +++ b/IDEHelper/Backend/BeModule.cpp @@ -28,6 +28,19 @@ void bpt(Beefy::BeType* t) } } +void bpv(Beefy::BeValue* val) +{ + BeDumpContext dumpCtx; + String str; + dumpCtx.ToString(str, val); + str += "\n"; + OutputDebugStr(str); + + auto type = val->GetType(); + if (type != NULL) + bpt(type); +} + ////////////////////////////////////////////////////////////////////////// void BeValueVisitor::VisitChild(BeValue* value) @@ -1229,11 +1242,12 @@ void BeDumpContext::ToString(StringImpl& str, BeValue* value, bool showType, boo if (auto arg = BeValueDynCast(value)) { - auto& typeParam = mModule->mActiveFunction->GetFuncType()->mParams[arg->mArgIdx]; - auto& param = mModule->mActiveFunction->mParams[arg->mArgIdx]; + auto activeFunction = arg->mModule->mActiveFunction; + auto& typeParam = activeFunction->GetFuncType()->mParams[arg->mArgIdx]; + auto& param = activeFunction->mParams[arg->mArgIdx]; if (showType) { - mModule->ToString(str, typeParam.mType); + BeModule::ToString(str, typeParam.mType); str += " %"; str += param.mName; } @@ -1242,6 +1256,7 @@ void BeDumpContext::ToString(StringImpl& str, BeValue* value, bool showType, boo str += "%"; str += param.mName; } + return; } @@ -1255,7 +1270,7 @@ void BeDumpContext::ToString(StringImpl& str, BeValue* value, bool showType, boo { if (showType) { - mModule->ToString(str, constant->mType); + BeModule::ToString(str, constant->mType); str += " "; } @@ -1323,7 +1338,7 @@ void BeDumpContext::ToString(StringImpl& str, BeValue* value, bool showType, boo if (auto constant = BeValueDynCast(value)) { - mModule->ToString(str, constant->mType); + BeModule::ToString(str, constant->mType); str += " "; switch (constant->mType->mTypeCode) @@ -1403,7 +1418,7 @@ void BeDumpContext::ToString(StringImpl& str, BeValue* value, bool showType, boo { if (resultType != NULL) { - mModule->ToString(str, resultType); + BeModule::ToString(str, resultType); str += " %"; } else @@ -1437,7 +1452,7 @@ void BeDumpContext::ToString(StringImpl& str, BeValue* value, bool showType, boo mValueNameMap[value] = useName; if ((showType) && (resultType != NULL)) { - mModule->ToString(str, resultType); + BeModule::ToString(str, resultType); str += " %"; str += useName; return; @@ -1460,13 +1475,13 @@ String BeDumpContext::ToString(BeValue* value, bool showType, bool mdDrillDown) String BeDumpContext::ToString(BeType* type) { String str; - mModule->ToString(str, type); + BeModule::ToString(str, type); return str; } void BeDumpContext::ToString(StringImpl& str, BeType* type) { - mModule->ToString(str, type); + BeModule::ToString(str, type); } void BeDumpContext::ToString(StringImpl& str, BeDbgFunction* dbgFunction, bool showScope) @@ -1755,8 +1770,7 @@ String BeModule::ToString(BeFunction* wantFunc) SetAndRestoreValue prevActiveFunc(mActiveFunction, NULL); BeDumpContext dc; - dc.mModule = this; - + if (wantFunc == NULL) { str += "Module: "; str += mModuleName; str += "\n"; @@ -2448,8 +2462,7 @@ void BeModule::Print(BeFunction* func) void BeModule::PrintValue(BeValue* val) { - BeDumpContext dumpCtx; - dumpCtx.mModule = this; + BeDumpContext dumpCtx; String str; dumpCtx.ToString(str, val); str += "\n"; @@ -2991,7 +3004,7 @@ void BeModule::SetActiveFunction(BeFunction* function) mActiveFunction = function; } -BeArgument * BeModule::GetArgument(int argIdx) +BeArgument* BeModule::GetArgument(int argIdx) { while ((int)argIdx >= mArgs.size()) { @@ -3371,8 +3384,7 @@ void BeDbgModule::HashContent(BeHashContext & hashCtx) hashCtx.MixinStr(mDirectory); hashCtx.MixinStr(mProducer); - BeDumpContext dc; - dc.mModule = mBeModule; + BeDumpContext dc; String lhsName; String rhsName; diff --git a/IDEHelper/Backend/BeModule.h b/IDEHelper/Backend/BeModule.h index 0816b11b..20781e2c 100644 --- a/IDEHelper/Backend/BeModule.h +++ b/IDEHelper/Backend/BeModule.h @@ -1291,8 +1291,7 @@ public: struct BeDumpContext { -public: - BeModule* mModule; +public: Dictionary mValueNameMap; Dictionary mSeenNames; @@ -1309,12 +1308,6 @@ public: static String ToString(int val); static String ToString(BeCmpKind cmpKind); static String ToString(BeBinaryOpKind opKind); - -public: - BeDumpContext() - { - mModule = NULL; - } }; ////////////////////////////////////////////////////////////////////////// diff --git a/IDEHelper/Compiler/BfIRBuilder.cpp b/IDEHelper/Compiler/BfIRBuilder.cpp index 74b59f2c..9c329e19 100644 --- a/IDEHelper/Compiler/BfIRBuilder.cpp +++ b/IDEHelper/Compiler/BfIRBuilder.cpp @@ -1197,9 +1197,16 @@ String BfIRBuilder::ToString(BfIRValue irValue) { auto val = mBeIRCodeGen->GetBeValue(irValue.mId); String str; - BeDumpContext dc; - dc.mModule = mBeIRCodeGen->mBeModule; + BeDumpContext dc; dc.ToString(str, val); + + auto type = val->GetType(); + if (type != NULL) + { + str += "\n"; + dc.ToString(str, type); + } + return str; } #endif @@ -1267,8 +1274,7 @@ String BfIRBuilder::ToString(BfIRType irType) } String str; - BeDumpContext dc; - dc.mModule = mBeIRCodeGen->mBeModule; + BeDumpContext dc; dc.ToString(str, beType); return str; } @@ -1302,8 +1308,7 @@ String BfIRBuilder::ToString(BfIRFunction irFunc) return "null"; String str; - BeDumpContext dc; - dc.mModule = mBeIRCodeGen->mBeModule; + BeDumpContext dc; dc.ToString(str, val); return str; } @@ -1349,8 +1354,7 @@ String BfIRBuilder::ToString(BfIRMDNode irMDNode) if (md == NULL) return "null"; String str; - BeDumpContext dc; - dc.mModule = mBeIRCodeGen->mBeModule; + BeDumpContext dc; dc.ToString(str, md); return str; } @@ -5060,3 +5064,4 @@ void BfIRBuilder::DbgCreateAnnotation(BfIRMDNode scope, const StringImpl& name, NEW_CMD_INSERTED; } + diff --git a/IDEHelper/Compiler/BfIRBuilder.h b/IDEHelper/Compiler/BfIRBuilder.h index 5c6ff727..e513f669 100644 --- a/IDEHelper/Compiler/BfIRBuilder.h +++ b/IDEHelper/Compiler/BfIRBuilder.h @@ -1260,7 +1260,7 @@ public: void DbgCreateGlobalVariable(BfIRMDNode context, const StringImpl& name, const StringImpl& linkageName, BfIRMDNode file, int lineNumber, BfIRMDNode type, bool isLocalToUnit, BfIRValue val, BfIRMDNode Decl = BfIRMDNode()); BfIRMDNode DbgCreateLexicalBlock(BfIRMDNode scope, BfIRMDNode file, int line, int col); - void DbgCreateAnnotation(BfIRMDNode scope, const StringImpl& name, BfIRValue value); + void DbgCreateAnnotation(BfIRMDNode scope, const StringImpl& name, BfIRValue value); }; NS_BF_END