mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 03:28:20 +02:00
Added typeof_comptime const type
This commit is contained in:
parent
a82cc0534d
commit
c511773dad
10 changed files with 111 additions and 10 deletions
|
@ -962,11 +962,21 @@ void BeIRCodeGen::Read(BeValue*& beValue)
|
|||
}
|
||||
else if (constType == BfConstType_TypeOf)
|
||||
{
|
||||
CMD_PARAM(BeType*, type);
|
||||
CMD_PARAM(BeType*, type);
|
||||
beValue = mReflectDataMap[type];
|
||||
BF_ASSERT(beValue != NULL);
|
||||
return;
|
||||
}
|
||||
else if (constType == BfConstType_TypeOf_Comptime)
|
||||
{
|
||||
CMD_PARAM(BeType*, typeType);
|
||||
CMD_PARAM(int, bfTypeId);
|
||||
auto beConst = mBeModule->mAlloc.Alloc<BeTypeOfConstant>();
|
||||
beConst->mType = typeType;
|
||||
beConst->mBfTypeId = bfTypeId;
|
||||
beValue = beConst;
|
||||
return;
|
||||
}
|
||||
else if (constType == BfConstType_TypeOf_WithData)
|
||||
{
|
||||
CMD_PARAM(BeType*, type);
|
||||
|
|
|
@ -1457,6 +1457,13 @@ void BeDumpContext::ToString(StringImpl& str, BeValue* value, bool showType, boo
|
|||
return;
|
||||
}
|
||||
|
||||
if (auto constant = BeValueDynCast<BeTypeOfConstant>(value))
|
||||
{
|
||||
ToString(str, constant->GetType());
|
||||
str += StrFormat(" typeof(%d)", constant->mBfTypeId);
|
||||
return;
|
||||
}
|
||||
|
||||
if (auto constant = BeValueDynCast<BeStringConstant>(value))
|
||||
{
|
||||
ToString(str, constant->GetType());
|
||||
|
|
|
@ -439,6 +439,20 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
class BeTypeOfConstant : public BeConstant
|
||||
{
|
||||
public:
|
||||
BE_VALUE_TYPE(BeTypeOfConstant, BeConstant);
|
||||
|
||||
int mBfTypeId;
|
||||
|
||||
virtual void HashContent(BeHashContext& hashCtx) override
|
||||
{
|
||||
hashCtx.Mixin(TypeId);
|
||||
hashCtx.Mixin(mBfTypeId);
|
||||
}
|
||||
};
|
||||
|
||||
class BeStringConstant : public BeConstant
|
||||
{
|
||||
public:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue