Brian Fiete 4 роки тому
батько
коміт
15c62583a2

+ 3 - 3
IDEHelper/Backend/BeIRCodeGen.cpp

@@ -839,7 +839,7 @@ void BeIRCodeGen::Read(BeValue*& beValue)
 			{
 				auto val = values[i];
 				BeConstant* constant = BeValueDynCast<BeConstant>(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<BeValue*>, values);
 

+ 6 - 0
IDEHelper/Backend/BeModule.cpp

@@ -3005,6 +3005,12 @@ void BeModule::AddInst(BeInst* inst)
 
 void BeModule::ToString(StringImpl& str, BeType* type)
 {
+	if (type == NULL)
+	{
+		str += "<MissingType>";
+		return;
+	}
+
 	switch (type->mTypeCode)
 	{
 	case BeTypeCode_None:

+ 19 - 7
IDEHelper/Compiler/BfIRBuilder.cpp

@@ -746,7 +746,7 @@ BfIRValue BfIRConstHolder::CreateConstAgg(BfIRType type, const BfSizedArray<BfIR
 		BF_ASSERT(val);
 	}
 #endif
-
+	
 	BfConstantAgg* constant = mTempAlloc.Alloc<BfConstantAgg>();
 	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
 	{

+ 0 - 3
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;
 			}