- removed the implicit conversion operators from FName.
These were creating dangerous interdependencies. It is better to do explicit conversions when needed. As an added plus, this means that zstring.h no longer depends on name.h which was very annoying.
This commit is contained in:
parent
6996d54a23
commit
ace3e29473
57 changed files with 184 additions and 200 deletions
|
|
@ -6164,7 +6164,7 @@ FxExpression *FxIdentifier::Resolve(FCompileContext& ctx)
|
|||
}
|
||||
|
||||
// and line specials
|
||||
if (newex == nullptr && (num = P_FindLineSpecial(Identifier, nullptr, nullptr)))
|
||||
if (newex == nullptr && (num = P_FindLineSpecial(Identifier.GetChars(), nullptr, nullptr)))
|
||||
{
|
||||
ScriptPosition.Message(MSG_DEBUGLOG, "Resolving name '%s' as line special %d\n", Identifier.GetChars(), num);
|
||||
newex = new FxConstant(num, ScriptPosition);
|
||||
|
|
@ -6371,7 +6371,7 @@ FxExpression *FxMemberIdentifier::Resolve(FCompileContext& ctx)
|
|||
// Thanks to the messed up search logic of the type system, which doesn't allow any search by type name for the basic types at all,
|
||||
// we have to do this manually, though and check for all types that may have values attached explicitly.
|
||||
// (What's the point of attached fields to types if you cannot even search for the types...???)
|
||||
switch (id)
|
||||
switch (id.GetIndex())
|
||||
{
|
||||
default:
|
||||
type = nullptr;
|
||||
|
|
@ -7674,7 +7674,7 @@ FxFunctionCall::FxFunctionCall(FName methodname, FName rngname, FArgumentList &a
|
|||
ArgList = std::move(args);
|
||||
if (rngname != NAME_None)
|
||||
{
|
||||
switch (MethodName)
|
||||
switch (MethodName.GetIndex())
|
||||
{
|
||||
case NAME_Random:
|
||||
case NAME_FRandom:
|
||||
|
|
@ -7870,7 +7870,7 @@ FxExpression *FxFunctionCall::Resolve(FCompileContext& ctx)
|
|||
// Note that for all builtins the used arguments have to be nulled in the ArgList so that they won't get deleted before they get used.
|
||||
FxExpression *func = nullptr;
|
||||
|
||||
switch (MethodName)
|
||||
switch (MethodName.GetIndex())
|
||||
{
|
||||
case NAME_Color:
|
||||
if (ArgList.Size() == 3 || ArgList.Size() == 4)
|
||||
|
|
@ -8215,7 +8215,7 @@ FxExpression *FxMemberFunctionCall::Resolve(FCompileContext& ctx)
|
|||
// No need to create a dedicated node here, all builtins map directly to trivial operations.
|
||||
Self->ValueType = TypeSInt32; // all builtins treat the texture index as integer.
|
||||
FxExpression *x;
|
||||
switch (MethodName)
|
||||
switch (MethodName.GetIndex())
|
||||
{
|
||||
case NAME_IsValid:
|
||||
x = new FxCompareRel('>', Self, new FxConstant(0, ScriptPosition));
|
||||
|
|
@ -8741,7 +8741,7 @@ ExpEmit FxActionSpecialCall::Emit(VMFunctionBuilder *build)
|
|||
{
|
||||
assert(argex->ValueType == TypeName);
|
||||
assert(argex->isConstant());
|
||||
emitters.AddParameterIntConst(-static_cast<FxConstant *>(argex)->GetValue().GetName());
|
||||
emitters.AddParameterIntConst(-static_cast<FxConstant *>(argex)->GetValue().GetName().GetIndex());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -10195,7 +10195,7 @@ FxExpression *FxCaseStatement::Resolve(FCompileContext &ctx)
|
|||
}
|
||||
else
|
||||
{
|
||||
CaseValue = static_cast<FxConstant *>(Condition)->GetValue().GetName();
|
||||
CaseValue = static_cast<FxConstant *>(Condition)->GetValue().GetName().GetIndex();
|
||||
}
|
||||
}
|
||||
return this;
|
||||
|
|
@ -10999,7 +10999,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(DObject, BuiltinNameToClass, NativeNameToClass)
|
|||
PARAM_NAME(clsname);
|
||||
PARAM_CLASS(desttype, DObject);
|
||||
|
||||
ACTION_RETURN_POINTER(NativeNameToClass(clsname, desttype));
|
||||
ACTION_RETURN_POINTER(NativeNameToClass(clsname.GetIndex(), desttype));
|
||||
}
|
||||
|
||||
ExpEmit FxClassTypeCast::Emit(VMFunctionBuilder *build)
|
||||
|
|
|
|||
|
|
@ -463,7 +463,7 @@ public:
|
|||
FxConstant(FName val, const FScriptPosition &pos) : FxExpression(EFX_Constant, pos)
|
||||
{
|
||||
ValueType = value.Type = TypeName;
|
||||
value.Int = val;
|
||||
value.Int = val.GetIndex();
|
||||
isresolved = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -872,7 +872,7 @@ void FFunctionBuildList::Build()
|
|||
// Emit code
|
||||
try
|
||||
{
|
||||
sfunc->SourceFileName = item.Code->ScriptPosition.FileName; // remember the file name for printing error messages if something goes wrong in the VM.
|
||||
sfunc->SourceFileName = item.Code->ScriptPosition.FileName.GetChars(); // remember the file name for printing error messages if something goes wrong in the VM.
|
||||
buildit.BeginStatement(item.Code);
|
||||
item.Code->Emit(&buildit);
|
||||
buildit.EndStatement();
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ void ParseOldDecoration(FScanner &sc, EDefinitionType def, PNamespace *ns)
|
|||
bag.fromDecorate = true;
|
||||
bag.Version = { 2, 0, 0 };
|
||||
#ifdef _DEBUG
|
||||
bag.ClassName = type->TypeName;
|
||||
bag.ClassName = type->TypeName.GetChars();
|
||||
#endif
|
||||
|
||||
sc.MustGetStringName("{");
|
||||
|
|
|
|||
|
|
@ -486,7 +486,7 @@ static FxExpression *ParseExpression0 (FScanner &sc, PClassActor *cls)
|
|||
FName identifier = FName(sc.String);
|
||||
PFunction *func;
|
||||
|
||||
switch (identifier)
|
||||
switch (identifier.GetIndex())
|
||||
{
|
||||
case NAME_Random:
|
||||
case NAME_FRandom:
|
||||
|
|
@ -519,7 +519,7 @@ static FxExpression *ParseExpression0 (FScanner &sc, PClassActor *cls)
|
|||
}
|
||||
if (sc.CheckToken('('))
|
||||
{
|
||||
switch (identifier)
|
||||
switch (identifier.GetIndex())
|
||||
{
|
||||
case NAME_Min:
|
||||
case NAME_Max:
|
||||
|
|
|
|||
|
|
@ -1124,7 +1124,7 @@ static PClassActor *ParseActorHeader(FScanner &sc, Baggage *bag)
|
|||
bag->Info = info;
|
||||
bag->Lumpnum = sc.LumpNum;
|
||||
#ifdef _DEBUG
|
||||
bag->ClassName = typeName;
|
||||
bag->ClassName = typeName.GetChars();
|
||||
#endif
|
||||
return info;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -703,7 +703,7 @@ void ParseFunctionParameters(FScanner &sc, PClassActor *cls, TArray<FxExpression
|
|||
|
||||
FName CheckCastKludges(FName in)
|
||||
{
|
||||
switch (in)
|
||||
switch (in.GetIndex())
|
||||
{
|
||||
case NAME_Int:
|
||||
return NAME___decorate_internal_int__;
|
||||
|
|
|
|||
|
|
@ -906,7 +906,7 @@ DEFINE_PROPERTY(damagefactor, ZF, Actor)
|
|||
DEFINE_PROPERTY(decal, S, Actor)
|
||||
{
|
||||
PROP_STRING_PARM(str, 0);
|
||||
defaults->DecalGenerator = (FDecalBase *)intptr_t(int(FName(str)));
|
||||
defaults->DecalGenerator = (FDecalBase *)(intptr_t)FName(str).GetIndex();
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
|
|||
|
|
@ -422,7 +422,7 @@ bool PContainerType::IsMatch(intptr_t id1, intptr_t id2) const
|
|||
void PContainerType::GetTypeIDs(intptr_t &id1, intptr_t &id2) const
|
||||
{
|
||||
id1 = (intptr_t)Outer;
|
||||
id2 = TypeName;
|
||||
id2 = TypeName.GetIndex();
|
||||
}
|
||||
|
||||
/* PInt *******************************************************************/
|
||||
|
|
@ -1612,11 +1612,11 @@ PEnum *NewEnum(FName name, PTypeBase *outer)
|
|||
{
|
||||
size_t bucket;
|
||||
if (outer == nullptr) outer = Namespaces.GlobalNamespace;
|
||||
PType *etype = TypeTable.FindType(NAME_Enum, (intptr_t)outer, (intptr_t)name, &bucket);
|
||||
PType *etype = TypeTable.FindType(NAME_Enum, (intptr_t)outer, name.GetIndex(), &bucket);
|
||||
if (etype == nullptr)
|
||||
{
|
||||
etype = new PEnum(name, outer);
|
||||
TypeTable.AddType(etype, NAME_Enum, (intptr_t)outer, (intptr_t)name, bucket);
|
||||
TypeTable.AddType(etype, NAME_Enum, (intptr_t)outer, name.GetIndex(), bucket);
|
||||
}
|
||||
return static_cast<PEnum *>(etype);
|
||||
}
|
||||
|
|
@ -2298,11 +2298,11 @@ PStruct *NewStruct(FName name, PTypeBase *outer, bool native)
|
|||
{
|
||||
size_t bucket;
|
||||
if (outer == nullptr) outer = Namespaces.GlobalNamespace;
|
||||
PType *stype = TypeTable.FindType(NAME_Struct, (intptr_t)outer, (intptr_t)name, &bucket);
|
||||
PType *stype = TypeTable.FindType(NAME_Struct, (intptr_t)outer, name.GetIndex(), &bucket);
|
||||
if (stype == nullptr)
|
||||
{
|
||||
stype = new PStruct(name, outer, native);
|
||||
TypeTable.AddType(stype, NAME_Struct, (intptr_t)outer, (intptr_t)name, bucket);
|
||||
TypeTable.AddType(stype, NAME_Struct, (intptr_t)outer, name.GetIndex(), bucket);
|
||||
}
|
||||
return static_cast<PStruct *>(stype);
|
||||
}
|
||||
|
|
@ -2425,11 +2425,11 @@ PField *PClassType::AddNativeField(FName name, PType *type, size_t address, uint
|
|||
PClassType *NewClassType(PClass *cls)
|
||||
{
|
||||
size_t bucket;
|
||||
PType *ptype = TypeTable.FindType(NAME_Object, 0, (intptr_t)cls->TypeName, &bucket);
|
||||
PType *ptype = TypeTable.FindType(NAME_Object, 0, cls->TypeName.GetIndex(), &bucket);
|
||||
if (ptype == nullptr)
|
||||
{
|
||||
ptype = new PClassType(cls);
|
||||
TypeTable.AddType(ptype, NAME_Object, 0, (intptr_t)cls->TypeName, bucket);
|
||||
TypeTable.AddType(ptype, NAME_Object, 0, cls->TypeName.GetIndex(), bucket);
|
||||
}
|
||||
return static_cast<PClassType *>(ptype);
|
||||
}
|
||||
|
|
@ -2507,7 +2507,7 @@ void FTypeTable::AddType(PType *type, FName type_name)
|
|||
|
||||
size_t FTypeTable::Hash(FName p1, intptr_t p2, intptr_t p3)
|
||||
{
|
||||
size_t i1 = (size_t)p1;
|
||||
size_t i1 = (size_t)p1.GetIndex();
|
||||
|
||||
// Swap the high and low halves of i1. The compiler should be smart enough
|
||||
// to transform this into a ROR or ROL.
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ static void CastV32S(FString *a, double b, double b1, double b2) { a->Format("(%
|
|||
static void CastP2S(FString *a, void *b) { if (b == nullptr) *a = "null"; else a->Format("%p", b); }
|
||||
static int CastS2I(FString *b) { return (int)b->ToLong(); }
|
||||
static double CastS2F(FString *b) { return b->ToDouble(); }
|
||||
static int CastS2N(FString *b) { return b->Len() == 0 ? FName(NAME_None) : FName(*b); }
|
||||
static int CastS2N(FString *b) { return b->Len() == 0 ? NAME_None : FName(*b).GetIndex(); }
|
||||
static void CastN2S(FString *a, int b) { FName name = FName(ENamedName(b)); *a = name.IsValidName() ? name.GetChars() : ""; }
|
||||
static int CastS2Co(FString *b) { return V_GetColor(nullptr, *b); }
|
||||
static void CastCo2S(FString *a, int b) { PalEntry c(b); a->Format("%02x %02x %02x", c.r, c.g, c.b); }
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@
|
|||
#include "cmdlib.h"
|
||||
#include "engineerrors.h"
|
||||
#include "memarena.h"
|
||||
#include "name.h"
|
||||
#include "scripting/backend/scopebarrier.h"
|
||||
|
||||
class DObject;
|
||||
|
|
|
|||
|
|
@ -1809,7 +1809,7 @@ static void DoCast(const VMRegisters ®, const VMFrame *f, int a, int b, int c
|
|||
|
||||
case CAST_S2N:
|
||||
ASSERTD(a); ASSERTS(b);
|
||||
reg.d[a] = reg.s[b].Len() == 0? FName(NAME_None) : FName(reg.s[b]);
|
||||
reg.d[a] = reg.s[b].Len() == 0? NAME_None : FName(reg.s[b]).GetIndex();
|
||||
break;
|
||||
|
||||
case CAST_N2S:
|
||||
|
|
|
|||
|
|
@ -893,13 +893,13 @@ DEFINE_ACTION_FUNCTION_NATIVE(AActor, isTeammate, isTeammate)
|
|||
|
||||
static int GetSpecies(AActor *self)
|
||||
{
|
||||
return self->GetSpecies();
|
||||
return self->GetSpecies().GetIndex();
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(AActor, GetSpecies, GetSpecies)
|
||||
{
|
||||
PARAM_SELF_PROLOGUE(AActor);
|
||||
ACTION_RETURN_INT(self->GetSpecies());
|
||||
ACTION_RETURN_INT(GetSpecies(self));
|
||||
}
|
||||
|
||||
static int isFriend(AActor *self, AActor *other)
|
||||
|
|
|
|||
|
|
@ -779,7 +779,7 @@ void ZCCCompiler::CreateClassTypes()
|
|||
do
|
||||
{
|
||||
if (build.IsNotEmpty()) build += '.';
|
||||
build += FName(p->Id);
|
||||
build += FName(p->Id).GetChars();
|
||||
p = static_cast<decltype(p)>(p->SiblingNext);
|
||||
} while (p != ParentName);
|
||||
Error(c->cls, "Qualified name '%s' for base class not supported in '%s'", build.GetChars(), FName(c->NodeName()).GetChars());
|
||||
|
|
@ -2391,13 +2391,13 @@ void ZCCCompiler::ProcessDefaultProperty(PClassActor *cls, ZCC_PropertyStmt *pro
|
|||
}
|
||||
|
||||
// a one-name property
|
||||
propname = FName(namenode->Id);
|
||||
propname = FName(namenode->Id).GetChars();
|
||||
|
||||
}
|
||||
else if (namenode->SiblingNext->SiblingNext == namenode)
|
||||
{
|
||||
// a two-name property
|
||||
propname << FName(namenode->Id) << "." << FName(static_cast<ZCC_Identifier *>(namenode->SiblingNext)->Id);
|
||||
propname << FName(namenode->Id).GetChars() << "." << FName(static_cast<ZCC_Identifier *>(namenode->SiblingNext)->Id).GetChars();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -2541,7 +2541,7 @@ void ZCCCompiler::InitDefaults()
|
|||
|
||||
Baggage bag;
|
||||
#ifdef _DEBUG
|
||||
bag.ClassName = cls->TypeName;
|
||||
bag.ClassName = cls->TypeName.GetChars();
|
||||
#endif
|
||||
bag.Version = mVersion;
|
||||
bag.Namespace = OutNamespace;
|
||||
|
|
@ -3283,7 +3283,7 @@ void ZCCCompiler::CompileStates()
|
|||
case AST_StateLabel:
|
||||
{
|
||||
auto sl = static_cast<ZCC_StateLabel *>(st);
|
||||
statename = FName(sl->Label);
|
||||
statename = FName(sl->Label).GetChars();
|
||||
statedef.AddStateLabel(statename);
|
||||
break;
|
||||
}
|
||||
|
|
@ -3372,12 +3372,12 @@ void ZCCCompiler::CompileStates()
|
|||
statename = "";
|
||||
if (sg->Qualifier != nullptr)
|
||||
{
|
||||
statename << FName(sg->Qualifier->Id) << "::";
|
||||
statename << FName(sg->Qualifier->Id).GetChars() << "::";
|
||||
}
|
||||
auto part = sg->Label;
|
||||
do
|
||||
{
|
||||
statename << FName(part->Id) << '.';
|
||||
statename << FName(part->Id).GetChars() << '.';
|
||||
part = static_cast<decltype(part)>(part->SiblingNext);
|
||||
} while (part != sg->Label);
|
||||
statename.Truncate(statename.Len() - 1); // remove the last '.' in the label name
|
||||
|
|
|
|||
|
|
@ -297,12 +297,12 @@ static void ParseSingleFile(FScanner *pSC, const char *filename, int lump, void
|
|||
|
||||
case TK_None: // 'NONE' is a token for SBARINFO but not here.
|
||||
case TK_Identifier:
|
||||
value.Int = FName(sc.String);
|
||||
value.Int = FName(sc.String).GetIndex();
|
||||
tokentype = ZCC_IDENTIFIER;
|
||||
break;
|
||||
|
||||
case TK_NonWhitespace:
|
||||
value.Int = FName(sc.String);
|
||||
value.Int = FName(sc.String).GetIndex();
|
||||
tokentype = ZCC_NWS;
|
||||
break;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue