mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 20:42:21 +02:00
Debugger mouseover improvements
This commit is contained in:
parent
4f0ad540a7
commit
4f2c28862d
8 changed files with 161 additions and 61 deletions
|
@ -2957,30 +2957,85 @@ void BfAutoComplete::CheckVarResolution(BfAstNode* varTypeRef, BfType* resolvedT
|
|||
}
|
||||
}
|
||||
|
||||
void BfAutoComplete::CheckResult(BfAstNode* node, const BfTypedValue& typedValue)
|
||||
class BfAutocompleteNodeChecker : public BfStructuralVisitor
|
||||
{
|
||||
public:
|
||||
BfAutoComplete* mAutoComplete;
|
||||
bool mSelected;
|
||||
|
||||
public:
|
||||
BfAutocompleteNodeChecker(BfAutoComplete* autoComplete)
|
||||
{
|
||||
mAutoComplete = autoComplete;
|
||||
mSelected = false;
|
||||
}
|
||||
|
||||
virtual void Visit(BfAstNode* bfAstNode) override
|
||||
{
|
||||
mSelected = mAutoComplete->IsAutocompleteNode(bfAstNode);
|
||||
}
|
||||
|
||||
virtual void Visit(BfBinaryOperatorExpression* binOpExpr) override
|
||||
{
|
||||
mSelected = mAutoComplete->IsAutocompleteNode(binOpExpr->mOpToken);
|
||||
}
|
||||
|
||||
virtual void Visit(BfUnaryOperatorExpression* unaryOpExpr) override
|
||||
{
|
||||
VisitChild(unaryOpExpr->mExpression);
|
||||
}
|
||||
|
||||
virtual void Visit(BfCastExpression* castExpr) override
|
||||
{
|
||||
VisitChild(castExpr->mExpression);
|
||||
}
|
||||
|
||||
virtual void Visit(BfLiteralExpression* literalExpr) override
|
||||
{
|
||||
mSelected = mAutoComplete->IsAutocompleteNode(literalExpr);
|
||||
}
|
||||
|
||||
virtual void Visit(BfIdentifierNode* identifierNode) override
|
||||
{
|
||||
mSelected = mAutoComplete->IsAutocompleteNode(identifierNode);
|
||||
}
|
||||
|
||||
virtual void Visit(BfMemberReferenceExpression* memberRefExpr) override
|
||||
{
|
||||
mSelected = mAutoComplete->IsAutocompleteNode(memberRefExpr->mMemberName);
|
||||
}
|
||||
};
|
||||
|
||||
void BfAutoComplete::CheckResult(BfAstNode* node, const BfTypedValue& typedValue)
|
||||
{
|
||||
if (mResolveType != BfResolveType_GetResultString)
|
||||
return;
|
||||
|
||||
if (!IsAutocompleteNode(node))
|
||||
return;
|
||||
|
||||
|
||||
if (!typedValue.mValue.IsConst())
|
||||
return;
|
||||
|
||||
if (typedValue.mType->IsPointer())
|
||||
return;
|
||||
if (typedValue.mType->IsObject())
|
||||
return;
|
||||
|
||||
auto constant = mModule->mBfIRBuilder->GetConstant(typedValue.mValue);
|
||||
if (BfIRConstHolder::IsInt(constant->mTypeCode))
|
||||
BfAutocompleteNodeChecker autocompleteNodeChecker(this);
|
||||
autocompleteNodeChecker.VisitChildNoRef(node);
|
||||
if (!autocompleteNodeChecker.mSelected)
|
||||
return;
|
||||
|
||||
String constStr = ConstantToString(mModule->mBfIRBuilder, typedValue);
|
||||
if (!constStr.IsEmpty())
|
||||
{
|
||||
mResultString = StrFormat(":%lld", constant->mInt64);
|
||||
mResultString = ":";
|
||||
mResultString += constStr;
|
||||
AddResultTypeKind(typedValue.mType);
|
||||
}
|
||||
else if (BfIRConstHolder::IsFloat(constant->mTypeCode))
|
||||
else
|
||||
{
|
||||
mResultString = StrFormat(":%f", constant->mDouble);
|
||||
SetResultStringType(typedValue.mType);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3041,7 +3096,7 @@ void BfAutoComplete::CheckLocalRef(BfAstNode* identifierNode, BfLocalVariable* v
|
|||
{
|
||||
String constStr;
|
||||
if (varDecl->mConstValue.IsConst())
|
||||
constStr = ConstantToString(mModule->mBfIRBuilder, varDecl->mConstValue);
|
||||
constStr = ConstantToString(mModule->mBfIRBuilder, BfTypedValue(varDecl->mConstValue, varDecl->mResolvedType));
|
||||
if (!constStr.IsEmpty())
|
||||
{
|
||||
mResultString = constStr;
|
||||
|
@ -3699,11 +3754,21 @@ String BfAutoComplete::FixitGetLocation(BfParserData* parser, int insertPos)
|
|||
return StrFormat("%s|%d:%d", parser->mFileName.c_str(), line, lineChar);
|
||||
}
|
||||
|
||||
String BfAutoComplete::ConstantToString(BfIRConstHolder* constHolder, BfIRValue id)
|
||||
String BfAutoComplete::ConstantToString(BfIRConstHolder* constHolder, BfTypedValue typedValue)
|
||||
{
|
||||
SetAndRestoreValue<BfTypeInstance*> prevTypeInst(mModule->mCurTypeInstance, typedValue.mType->ToTypeInstance());
|
||||
SetAndRestoreValue<BfMethodInstance*> prevMethodInst(mModule->mCurMethodInstance, NULL);
|
||||
|
||||
BF_ASSERT(typedValue.mValue.IsConst());
|
||||
|
||||
String result;
|
||||
result = "(";
|
||||
result += mModule->TypeToString(typedValue.mType);
|
||||
result += ")";
|
||||
|
||||
char str[32];
|
||||
|
||||
int stringId = mModule->GetStringPoolIdx(id, constHolder);
|
||||
int stringId = mModule->GetStringPoolIdx(typedValue.mValue, constHolder);
|
||||
if (stringId != -1)
|
||||
{
|
||||
BfStringPoolEntry* entry;
|
||||
|
@ -3716,49 +3781,52 @@ String BfAutoComplete::ConstantToString(BfIRConstHolder* constHolder, BfIRValue
|
|||
}
|
||||
}
|
||||
|
||||
auto constant = constHolder->GetConstant(id);
|
||||
auto constant = constHolder->GetConstant(typedValue.mValue);
|
||||
switch (constant->mTypeCode)
|
||||
{
|
||||
case BfTypeCode_Boolean:
|
||||
return StrFormat(":(bool) %s", constant->mBool ? "true" : "false");
|
||||
case BfTypeCode_UInt8:
|
||||
return StrFormat(":(uint8) %llu", constant->mUInt64);
|
||||
case BfTypeCode_UInt16:
|
||||
return StrFormat(":(uint16) %llu", constant->mUInt64);
|
||||
case BfTypeCode_UInt32:
|
||||
return StrFormat(":(uint32) %llu", constant->mUInt64);
|
||||
case BfTypeCode_UInt64:
|
||||
return StrFormat(":(uint64) %llu", constant->mUInt64);
|
||||
|
||||
case BfTypeCode_Int8:
|
||||
return StrFormat(":(int8) %lld", constant->mInt64);
|
||||
case BfTypeCode_Int16:
|
||||
return StrFormat(":(int16) %lld", constant->mInt64);
|
||||
case BfTypeCode_Int32:
|
||||
return StrFormat(":(int32) %lld", constant->mInt64);
|
||||
case BfTypeCode_Int64:
|
||||
return StrFormat(":(int64) %lld", constant->mInt64);
|
||||
|
||||
case BfTypeCode_Float:
|
||||
{
|
||||
ExactMinimalFloatToStr((float)constant->mDouble, str);
|
||||
String result;
|
||||
result += str;
|
||||
result += "f";
|
||||
return result;
|
||||
}
|
||||
case BfTypeCode_Double:
|
||||
{
|
||||
ExactMinimalDoubleToStr(constant->mDouble, str);
|
||||
String result;
|
||||
result += str;
|
||||
return result;
|
||||
}
|
||||
default:
|
||||
result += StrFormat(" %s", constant->mBool ? "true" : "false");
|
||||
break;
|
||||
case BfTypeCode_UInt8:
|
||||
result += StrFormat(" %llu", constant->mUInt64);
|
||||
break;
|
||||
case BfTypeCode_UInt16:
|
||||
result += StrFormat(" %llu", constant->mUInt64);
|
||||
break;
|
||||
case BfTypeCode_UInt32:
|
||||
result += StrFormat(" %llu", constant->mUInt64);
|
||||
break;
|
||||
case BfTypeCode_UInt64:
|
||||
result += StrFormat(" %llu", constant->mUInt64);
|
||||
break;
|
||||
case BfTypeCode_Int8:
|
||||
result += StrFormat(" %lld", constant->mInt64);
|
||||
break;
|
||||
case BfTypeCode_Int16:
|
||||
result += StrFormat(" %lld", constant->mInt64);
|
||||
break;
|
||||
case BfTypeCode_Int32:
|
||||
result += StrFormat(" %lld", constant->mInt64);
|
||||
break;
|
||||
case BfTypeCode_Int64:
|
||||
result += StrFormat(" %lld", constant->mInt64);
|
||||
break;
|
||||
case BfTypeCode_Float:
|
||||
ExactMinimalFloatToStr((float)constant->mDouble, str);
|
||||
result += " ";
|
||||
result += str;
|
||||
result += "f";
|
||||
break;
|
||||
case BfTypeCode_Double:
|
||||
ExactMinimalDoubleToStr(constant->mDouble, str);
|
||||
result += " ";
|
||||
result += str;
|
||||
break;
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
|
||||
return "";
|
||||
return result;
|
||||
}
|
||||
|
||||
void BfAutoComplete::FixitAddMethod(BfTypeInstance* typeInst, const StringImpl& methodName, BfType* returnType, const BfTypeVector& paramTypes, bool wantStatic)
|
||||
|
@ -3946,13 +4014,8 @@ void BfAutoComplete::FixitAddConstructor(BfTypeInstance *typeInstance)
|
|||
}
|
||||
}
|
||||
|
||||
void BfAutoComplete::SetResultStringType(BfType * type)
|
||||
void BfAutoComplete::AddResultTypeKind(BfType* type)
|
||||
{
|
||||
SetAndRestoreValue<BfTypeInstance*> prevTypeInst(mModule->mCurTypeInstance, type->ToTypeInstance());
|
||||
SetAndRestoreValue<BfMethodInstance*> prevMethodInst(mModule->mCurMethodInstance, NULL);
|
||||
|
||||
mResultString = ":";
|
||||
mResultString += mModule->TypeToString(type);
|
||||
if (type->IsObject())
|
||||
mResultString += "\n:type\tclass";
|
||||
else if (type->IsInterface())
|
||||
|
@ -3963,6 +4026,16 @@ void BfAutoComplete::SetResultStringType(BfType * type)
|
|||
mResultString += "\n:type\tvaluetype";
|
||||
}
|
||||
|
||||
void BfAutoComplete::SetResultStringType(BfType* type)
|
||||
{
|
||||
SetAndRestoreValue<BfTypeInstance*> prevTypeInst(mModule->mCurTypeInstance, type->ToTypeInstance());
|
||||
SetAndRestoreValue<BfMethodInstance*> prevMethodInst(mModule->mCurMethodInstance, NULL);
|
||||
|
||||
mResultString = ":";
|
||||
mResultString += mModule->TypeToString(type);
|
||||
AddResultTypeKind(type);
|
||||
}
|
||||
|
||||
void BfAutoComplete::FixitAddFullyQualify(BfAstNode* refNode, const StringImpl& findName, const SizedArrayImpl<BfUsingFieldData::MemberRef>& foundList)
|
||||
{
|
||||
BfProtectionCheckFlags protectionCheckFlags = BfProtectionCheckFlag_None;
|
||||
|
|
|
@ -244,7 +244,7 @@ public:
|
|||
void FixitGetParamString(const BfTypeVector& paramTypes, StringImpl& outStr);
|
||||
int FixitGetMemberInsertPos(BfTypeDef* typeDef);
|
||||
String FixitGetLocation(BfParserData* parserData, int insertPos);
|
||||
String ConstantToString(BfIRConstHolder* constHolder, BfIRValue id);
|
||||
String ConstantToString(BfIRConstHolder* constHolder, BfTypedValue typedValue);
|
||||
|
||||
public:
|
||||
BfAutoComplete(BfResolveType resolveType = BfResolveType_Autocomplete, bool doFuzzyAutoComplete = false);
|
||||
|
@ -283,6 +283,7 @@ public:
|
|||
void FixitAddConstructor(BfTypeInstance* typeInstance);
|
||||
void FixitAddFullyQualify(BfAstNode* refNode, const StringImpl& findName, const SizedArrayImpl<BfUsingFieldData::MemberRef>& foundList);
|
||||
|
||||
void AddResultTypeKind(BfType* type);
|
||||
void SetResultStringType(BfType* type);
|
||||
};
|
||||
|
||||
|
|
|
@ -167,7 +167,7 @@ BfTypedValue BfConstResolver::Resolve(BfExpression* expr, BfType* wantType, BfCo
|
|||
}
|
||||
else
|
||||
{
|
||||
mResult = mModule->Cast(expr, mResult, wantType, (BfCastFlags)(BfCastFlags_WantsConst | BfCastFlags_NoConversionOperator | (explicitCast ? BfCastFlags_Explicit : BfCastFlags_None)));
|
||||
mResult = mModule->Cast(expr, mResult, wantType, (BfCastFlags)(BfCastFlags_WantsConst | (explicitCast ? BfCastFlags_Explicit : BfCastFlags_None)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -399,7 +399,7 @@ bool BfConstResolver::PrepareMethodArguments(BfAstNode* targetSrc, BfMethodMatch
|
|||
|
||||
if (argExpr != NULL)
|
||||
{
|
||||
argValue = mModule->Cast(argExpr, argValue, wantType, (BfCastFlags)(BfCastFlags_WantsConst | BfCastFlags_NoConversionOperator));
|
||||
argValue = mModule->Cast(argExpr, argValue, wantType, (BfCastFlags)(BfCastFlags_WantsConst));
|
||||
if (!argValue)
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -5172,7 +5172,7 @@ BfTypedValue BfExprEvaluator::LoadField(BfAstNode* targetSrc, BfTypedValue targe
|
|||
|
||||
if (fieldInstance->mConstIdx != -1)
|
||||
{
|
||||
String constStr = autoComplete->ConstantToString(typeInstance->mConstHolder, BfIRValue(BfIRValueFlags_Const, fieldInstance->mConstIdx));
|
||||
String constStr = autoComplete->ConstantToString(typeInstance->mConstHolder, BfTypedValue(BfIRValue(BfIRValueFlags_Const, fieldInstance->mConstIdx), fieldInstance->mResolvedType));
|
||||
if (!constStr.IsEmpty())
|
||||
{
|
||||
autoComplete->mResultString += " = ";
|
||||
|
|
|
@ -4670,6 +4670,10 @@ BfTypedValue BfModule::GetFieldInitializerValue(BfFieldInstance* fieldInstance,
|
|||
if (mCompiler->mCeMachine->mExecuteId != ceExecuteId)
|
||||
fieldInstance->mHadConstEval = true;
|
||||
}
|
||||
|
||||
if (auto autoComplete = mCompiler->GetAutoComplete())
|
||||
autoComplete->CheckResult(initializer, result);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -9240,6 +9244,9 @@ BfTypedValue BfModule::CreateValueFromExpression(BfExprEvaluator& exprEvaluator,
|
|||
if ((typedVal.mType->IsValueType()) && ((flags & BfEvalExprFlags_NoValueAddr) != 0))
|
||||
typedVal = LoadValue(typedVal, 0, exprEvaluator.mIsVolatileReference);
|
||||
|
||||
if (auto autoComplete = mCompiler->GetAutoComplete())
|
||||
autoComplete->CheckResult(expr, typedVal);
|
||||
|
||||
return typedVal;
|
||||
}
|
||||
|
||||
|
|
|
@ -1778,6 +1778,11 @@ BfLocalVariable* BfModule::HandleVariableDeclaration(BfVariableDeclaration* varD
|
|||
resolvedType = initValue.mType;
|
||||
unresolvedType = resolvedType;
|
||||
}
|
||||
|
||||
if (auto autoComplete = mCompiler->GetAutoComplete())
|
||||
{
|
||||
autoComplete->CheckResult(varDecl->mInitializer, initValue);
|
||||
}
|
||||
}
|
||||
if ((!handledVarInit) && (!isConst))
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue