- moved compiler frontend to 'common'.
This commit is contained in:
parent
466ed4e8f2
commit
2e5bc3e962
11 changed files with 250 additions and 168 deletions
|
|
@ -590,107 +590,6 @@ FPropertyInfo *FindProperty(const char * string)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
template <typename Desc>
|
||||
static int CompareClassNames(const char* const aname, const Desc& b)
|
||||
{
|
||||
// ++ to get past the prefix letter of the native class name, which gets omitted by the FName for the class.
|
||||
const char* bname = b.ClassName;
|
||||
if ('\0' != *bname) ++bname;
|
||||
return stricmp(aname, bname);
|
||||
}
|
||||
|
||||
template <typename Desc>
|
||||
static int CompareClassNames(const Desc& a, const Desc& b)
|
||||
{
|
||||
// ++ to get past the prefix letter of the native class name, which gets omitted by the FName for the class.
|
||||
const char* aname = a.ClassName;
|
||||
if ('\0' != *aname) ++aname;
|
||||
return CompareClassNames(aname, b);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Find a function by name using a binary search
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
AFuncDesc *FindFunction(PContainerType *cls, const char * string)
|
||||
{
|
||||
int min = 0, max = AFTable.Size() - 1;
|
||||
|
||||
while (min <= max)
|
||||
{
|
||||
int mid = (min + max) / 2;
|
||||
int lexval = CompareClassNames(cls->TypeName.GetChars(), AFTable[mid]);
|
||||
if (lexval == 0) lexval = stricmp(string, AFTable[mid].FuncName);
|
||||
if (lexval == 0)
|
||||
{
|
||||
return &AFTable[mid];
|
||||
}
|
||||
else if (lexval > 0)
|
||||
{
|
||||
min = mid + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
max = mid - 1;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Find a function by name using a binary search
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
FieldDesc *FindField(PContainerType *cls, const char * string)
|
||||
{
|
||||
int min = 0, max = FieldTable.Size() - 1;
|
||||
const char * cname = cls ? cls->TypeName.GetChars() : "";
|
||||
|
||||
while (min <= max)
|
||||
{
|
||||
int mid = (min + max) / 2;
|
||||
int lexval = CompareClassNames(cname, FieldTable[mid]);
|
||||
if (lexval == 0) lexval = stricmp(string, FieldTable[mid].FieldName);
|
||||
if (lexval == 0)
|
||||
{
|
||||
return &FieldTable[mid];
|
||||
}
|
||||
else if (lexval > 0)
|
||||
{
|
||||
min = mid + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
max = mid - 1;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Find an action function in AActor's table
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
VMFunction *FindVMFunction(PClass *cls, const char *name)
|
||||
{
|
||||
auto f = dyn_cast<PFunction>(cls->FindSymbol(name, true));
|
||||
return f == nullptr ? nullptr : f->Variants[0].Implementation;
|
||||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Sorting helpers
|
||||
|
|
@ -707,25 +606,12 @@ static int propcmp(const void * a, const void * b)
|
|||
return stricmp( (*(FPropertyInfo**)a)->name, (*(FPropertyInfo**)b)->name);
|
||||
}
|
||||
|
||||
static int funccmp(const void * a, const void * b)
|
||||
{
|
||||
int res = CompareClassNames(*(AFuncDesc*)a, *(AFuncDesc*)b);
|
||||
if (res == 0) res = stricmp(((AFuncDesc*)a)->FuncName, ((AFuncDesc*)b)->FuncName);
|
||||
return res;
|
||||
}
|
||||
|
||||
static int fieldcmp(const void * a, const void * b)
|
||||
{
|
||||
int res = CompareClassNames(*(FieldDesc*)a, *(FieldDesc*)b);
|
||||
if (res == 0) res = stricmp(((FieldDesc*)a)->FieldName, ((FieldDesc*)b)->FieldName);
|
||||
return res;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Initialization
|
||||
//
|
||||
//==========================================================================
|
||||
void InitImports();
|
||||
|
||||
void InitThingdef()
|
||||
{
|
||||
|
|
@ -871,25 +757,6 @@ void InitThingdef()
|
|||
qsort(&properties[0], properties.Size(), sizeof(properties[0]), propcmp);
|
||||
}
|
||||
|
||||
// Create a sorted list of native action functions
|
||||
AFTable.Clear();
|
||||
if (AFTable.Size() == 0)
|
||||
{
|
||||
FAutoSegIterator probe(ARegHead, ARegTail);
|
||||
|
||||
while (*++probe != NULL)
|
||||
{
|
||||
AFuncDesc *afunc = (AFuncDesc *)*probe;
|
||||
assert(afunc->VMPointer != NULL);
|
||||
*(afunc->VMPointer) = new VMNativeFunction(afunc->Function, afunc->FuncName);
|
||||
(*(afunc->VMPointer))->PrintableName.Format("%s.%s [Native]", afunc->ClassName+1, afunc->FuncName);
|
||||
(*(afunc->VMPointer))->DirectNativeCall = afunc->DirectNative;
|
||||
AFTable.Push(*afunc);
|
||||
}
|
||||
AFTable.ShrinkToFit();
|
||||
qsort(&AFTable[0], AFTable.Size(), sizeof(AFTable[0]), funccmp);
|
||||
}
|
||||
|
||||
// Add the constructor and destructor to FCheckPosition.
|
||||
auto fcp = NewStruct("FCheckPosition", nullptr);
|
||||
fcp->mConstructor = *FindFunction(fcp, "_Constructor")->VMPointer;
|
||||
|
|
@ -908,19 +775,7 @@ void InitThingdef()
|
|||
fltd->Size = sizeof(FLineTraceData);
|
||||
fltd->Align = alignof(FLineTraceData);
|
||||
|
||||
FieldTable.Clear();
|
||||
if (FieldTable.Size() == 0)
|
||||
{
|
||||
FAutoSegIterator probe(FRegHead, FRegTail);
|
||||
|
||||
while (*++probe != NULL)
|
||||
{
|
||||
FieldDesc *afield = (FieldDesc *)*probe;
|
||||
FieldTable.Push(*afield);
|
||||
}
|
||||
FieldTable.ShrinkToFit();
|
||||
qsort(&FieldTable[0], FieldTable.Size(), sizeof(FieldTable[0]), fieldcmp);
|
||||
}
|
||||
InitImports();
|
||||
}
|
||||
|
||||
void SynthesizeFlagFields()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue