- separated the Doom specific parts of the ZScript parser from the core into a subclass.
This commit is contained in:
parent
2838f5792c
commit
466ed4e8f2
10 changed files with 1216 additions and 1060 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -106,11 +106,14 @@ class ZCCCompiler
|
|||
{
|
||||
public:
|
||||
ZCCCompiler(ZCC_AST &tree, DObject *outer, PSymbolTable &symbols, PNamespace *outnamespace, int lumpnum, const VersionInfo & ver);
|
||||
~ZCCCompiler();
|
||||
int Compile();
|
||||
virtual ~ZCCCompiler();
|
||||
virtual int Compile();
|
||||
|
||||
private:
|
||||
protected:
|
||||
const char * GetStringConst(FxExpression *ex, FCompileContext &ctx);
|
||||
virtual int CheckActionKeyword(ZCC_FuncDeclarator* f, uint32_t &varflags, int useflags, ZCC_StructWork *c) { return -1; } // stock implementation does not support this.
|
||||
virtual bool PrepareMetaData(PClass *type) { return false; }
|
||||
virtual void SetImplicitArgs(TArray<PType*>* args, TArray<uint32_t>* argflags, TArray<FName>* argnames, PContainerType* cls, uint32_t funcflags, int useflags);
|
||||
|
||||
int IntConstFromNode(ZCC_TreeNode *node, PContainerType *cls);
|
||||
FString StringConstFromNode(ZCC_TreeNode *node, PContainerType *cls);
|
||||
|
|
|
|||
1100
src/scripting/zscript/zcc_compile_doom.cpp
Normal file
1100
src/scripting/zscript/zcc_compile_doom.cpp
Normal file
File diff suppressed because it is too large
Load diff
34
src/scripting/zscript/zcc_compile_doom.h
Normal file
34
src/scripting/zscript/zcc_compile_doom.h
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#pragma once
|
||||
#include "zcc_compile.h"
|
||||
|
||||
void SetImplicitArgs(TArray<PType*>* args, TArray<uint32_t>* argflags, TArray<FName>* argnames, PContainerType* cls, uint32_t funcflags, int useflags);
|
||||
|
||||
class ZCCDoomCompiler : public ZCCCompiler
|
||||
{
|
||||
public:
|
||||
ZCCDoomCompiler(ZCC_AST &tree, DObject *outer, PSymbolTable &symbols, PNamespace *outnamespace, int lumpnum, const VersionInfo & ver)
|
||||
: ZCCCompiler(tree, outer, symbols, outnamespace, lumpnum, ver)
|
||||
{}
|
||||
int Compile() override;
|
||||
protected:
|
||||
bool PrepareMetaData(PClass *type) override;
|
||||
void SetImplicitArgs(TArray<PType*>* args, TArray<uint32_t>* argflags, TArray<FName>* argnames, PContainerType* cls, uint32_t funcflags, int useflags) override
|
||||
{
|
||||
::SetImplicitArgs(args, argflags, argnames, cls, funcflags, useflags);
|
||||
}
|
||||
private:
|
||||
void CompileAllProperties();
|
||||
bool CompileProperties(PClass *type, TArray<ZCC_Property *> &Properties, FName prefix);
|
||||
bool CompileFlagDefs(PClass *type, TArray<ZCC_FlagDef *> &Properties, FName prefix);
|
||||
void DispatchProperty(FPropertyInfo *prop, ZCC_PropertyStmt *property, AActor *defaults, Baggage &bag);
|
||||
void DispatchScriptProperty(PProperty *prop, ZCC_PropertyStmt *property, AActor *defaults, Baggage &bag);
|
||||
void ProcessDefaultProperty(PClassActor *cls, ZCC_PropertyStmt *prop, Baggage &bag);
|
||||
void ProcessDefaultFlag(PClassActor *cls, ZCC_FlagStmt *flg);
|
||||
void InitDefaults();
|
||||
FxExpression *SetupActionFunction(PClass *cls, ZCC_TreeNode *af, int StateFlags);
|
||||
void CompileStates();
|
||||
int CheckActionKeyword(ZCC_FuncDeclarator *f, uint32_t &varflags, int useflags, ZCC_StructWork *c);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -350,16 +350,20 @@ parse_end:
|
|||
|
||||
//**--------------------------------------------------------------------------
|
||||
|
||||
static void DoParse(int lumpnum)
|
||||
PNamespace *ParseOneScript(const int baselump, ZCCParseState &state)
|
||||
{
|
||||
FScanner sc;
|
||||
void *parser;
|
||||
ZCCToken value;
|
||||
auto baselump = lumpnum;
|
||||
int lumpnum = baselump;
|
||||
auto fileno = fileSystem.GetFileContainer(lumpnum);
|
||||
|
||||
if (TokenMap.CountUsed() == 0)
|
||||
{
|
||||
InitTokenMap();
|
||||
}
|
||||
|
||||
parser = ZCCParseAlloc(malloc);
|
||||
ZCCParseState state;
|
||||
|
||||
#ifndef NDEBUG
|
||||
FILE *f = nullptr;
|
||||
|
|
@ -471,37 +475,8 @@ static void DoParse(int lumpnum)
|
|||
}
|
||||
}
|
||||
|
||||
PSymbolTable symtable;
|
||||
auto newns = fileSystem.GetFileContainer(baselump) == 0 ? Namespaces.GlobalNamespace : Namespaces.NewNamespace(fileSystem.GetFileContainer(baselump));
|
||||
ZCCCompiler cc(state, NULL, symtable, newns, baselump, state.ParseVersion);
|
||||
cc.Compile();
|
||||
|
||||
if (FScriptPosition::ErrorCounter > 0)
|
||||
{
|
||||
// Abort if the compiler produced any errors. Also do not compile further lumps, because they very likely miss some stuff.
|
||||
I_Error("%d errors, %d warnings while compiling %s", FScriptPosition::ErrorCounter, FScriptPosition::WarnCounter, fileSystem.GetFileFullPath(baselump).GetChars());
|
||||
}
|
||||
else if (FScriptPosition::WarnCounter > 0)
|
||||
{
|
||||
// If we got warnings, but no errors, print the information but continue.
|
||||
Printf(TEXTCOLOR_ORANGE "%d warnings while compiling %s\n", FScriptPosition::WarnCounter, fileSystem.GetFileFullPath(baselump).GetChars());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ParseScripts()
|
||||
{
|
||||
if (TokenMap.CountUsed() == 0)
|
||||
{
|
||||
InitTokenMap();
|
||||
}
|
||||
int lump, lastlump = 0;
|
||||
FScriptPosition::ResetErrorCounter();
|
||||
|
||||
while ((lump = fileSystem.FindLump("ZSCRIPT", &lastlump)) != -1)
|
||||
{
|
||||
DoParse(lump);
|
||||
}
|
||||
return newns;
|
||||
}
|
||||
|
||||
static FString ZCCTokenName(int terminal)
|
||||
|
|
|
|||
|
|
@ -618,4 +618,7 @@ const char *GetMixinTypeString(EZCCMixinType type);
|
|||
|
||||
ZCC_TreeNode *TreeNodeDeepCopy(ZCC_AST *ast, ZCC_TreeNode *orig, bool copySiblings);
|
||||
|
||||
// Main entry point for the parser. Returns some data needed by the compiler.
|
||||
PNamespace* ParseOneScript(const int baselump, ZCCParseState& state);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue