diff --git a/IDEHelper/Backend/BeIRCodeGen.cpp b/IDEHelper/Backend/BeIRCodeGen.cpp index 58566745..ac533eec 100644 --- a/IDEHelper/Backend/BeIRCodeGen.cpp +++ b/IDEHelper/Backend/BeIRCodeGen.cpp @@ -839,7 +839,7 @@ void BeIRCodeGen::Read(BeValue*& beValue) { auto val = values[i]; BeConstant* constant = BeValueDynCast(val); -#ifdef _DEBUG + if (type->IsSizedArray()) { auto arrayType = (BeSizedArrayType*)type; @@ -882,9 +882,9 @@ void BeIRCodeGen::Read(BeValue*& beValue) } constStruct->mMemberValues.Add(constant); -#endif } beValue = constStruct; + BE_MEM_END("ParamType_Const_Array"); return; } @@ -1236,7 +1236,7 @@ void BeIRCodeGen::HandleNextCmd() } break; case BfIRCmd_CreateConstAgg: - { + { CMD_PARAM(BeType*, type); CMD_PARAM(CmdParamVec, values); diff --git a/IDEHelper/Backend/BeModule.cpp b/IDEHelper/Backend/BeModule.cpp index 51b259db..f0c8e20f 100644 --- a/IDEHelper/Backend/BeModule.cpp +++ b/IDEHelper/Backend/BeModule.cpp @@ -3005,6 +3005,12 @@ void BeModule::AddInst(BeInst* inst) void BeModule::ToString(StringImpl& str, BeType* type) { + if (type == NULL) + { + str += ""; + return; + } + switch (type->mTypeCode) { case BeTypeCode_None: diff --git a/IDEHelper/Compiler/BfIRBuilder.cpp b/IDEHelper/Compiler/BfIRBuilder.cpp index 6b44f9a1..b4cd3342 100644 --- a/IDEHelper/Compiler/BfIRBuilder.cpp +++ b/IDEHelper/Compiler/BfIRBuilder.cpp @@ -746,7 +746,7 @@ BfIRValue BfIRConstHolder::CreateConstAgg(BfIRType type, const BfSizedArray(); constant->mConstType = BfConstType_Agg; constant->mType = type = type; @@ -1297,9 +1297,12 @@ String BfIRBuilder::ToString(BfIRValue irValue) } else if (constant->mConstType == BfConstType_GlobalVar) { - if (mBfIRCodeGen != NULL) + auto gvConst = (BfGlobalVar*)constant; + if (gvConst->mStreamId == -1) { - auto gvConst = (BfGlobalVar*)constant; + } + else if (mBfIRCodeGen != NULL) + { auto val = mBfIRCodeGen->GetLLVMValue(gvConst->mStreamId); std::string outStr; llvm::raw_string_ostream strStream(outStr); @@ -1308,8 +1311,7 @@ String BfIRBuilder::ToString(BfIRValue irValue) return outStr; } else if (mBeIRCodeGen != NULL) - { - auto gvConst = (BfGlobalVar*)constant; + { auto val = mBeIRCodeGen->GetBeValue(gvConst->mStreamId); String outStr; BeDumpContext dumpCtx; @@ -1317,7 +1319,7 @@ String BfIRBuilder::ToString(BfIRValue irValue) return outStr; } else - return "GlobalVar???"; + return String("GlobalVar ") + gvConst->mName; } else if (constant->mConstType == BfConstType_BitCast) { @@ -1368,6 +1370,16 @@ String BfIRBuilder::ToString(BfIRValue irValue) { return ToString(constant->mIRType) + " zeroinitializer"; } + else if (constant->mConstType == BfConstType_TypeOf) + { + auto typeofConst = (BfTypeOf_Const*)constant; + return "typeof " + mModule->TypeToString(typeofConst->mType); + } + else if (constant->mConstType == BfConstType_TypeOf_WithData) + { + auto typeofConst = (BfTypeOf_WithData_Const*)constant; + return "typeof_withData " + mModule->TypeToString(typeofConst->mType); + } else { BF_FATAL("Unhandled"); @@ -1485,7 +1497,7 @@ String BfIRBuilder::ToString(BfIRType irType) } else if (irType.mKind == BfIRTypeData::TypeKind_TypeId) { - return StrFormat("Type Id %d", irType.mId); + return StrFormat("Type Id %d (%s)", irType.mId, mModule->TypeToString(mModule->mContext->mTypes[irType.mId]).c_str()); } else { diff --git a/IDEHelper/Tests/src/Comptime.bf b/IDEHelper/Tests/src/Comptime.bf index 3f995890..1d264f89 100644 --- a/IDEHelper/Tests/src/Comptime.bf +++ b/IDEHelper/Tests/src/Comptime.bf @@ -120,9 +120,6 @@ namespace Tests for (let field in typeof(T).GetFields()) if (!field.IsStatic) fieldCount++; - - //Debug.WriteLine($"{fieldCount}"); - return fieldCount; }