Skip to content

Commit

Permalink
- separated the Doom specific parts of the ZScript parser from the co…
Browse files Browse the repository at this point in the history
…re into a subclass.
  • Loading branch information
coelckers committed Apr 11, 2020
1 parent 2838f57 commit 466ed4e
Show file tree
Hide file tree
Showing 10 changed files with 1,216 additions and 1,060 deletions.
16 changes: 7 additions & 9 deletions src/CMakeLists.txt
Expand Up @@ -207,24 +207,17 @@ endif()

# Decide on SSE setup

set( SSE_MATTERS NO )

# with global use of SSE 2 we do not need special handling for selected files
if (NOT ZDOOM_USE_SSE2)
# SSE only matters on 32-bit targets. We check compiler flags to know if we can do it.
if( CMAKE_SIZEOF_VOID_P MATCHES "4" AND NOT CMAKE_OSX_ARCHITECTURES MATCHES ppc )
# SSE only matters on 32-bit targets. We check compiler flags to know if we can do it.
if( CMAKE_SIZEOF_VOID_P MATCHES "4" AND NOT CMAKE_OSX_ARCHITECTURES MATCHES ppc )
CHECK_CXX_COMPILER_FLAG( "-msse2 -mfpmath=sse" CAN_DO_MFPMATH )
CHECK_CXX_COMPILER_FLAG( -arch:SSE2 CAN_DO_ARCHSSE2 )
if( CAN_DO_MFPMATH )
set( SSE1_ENABLE "-msse -mfpmath=sse" )
set( SSE2_ENABLE "-msse2 -mfpmath=sse" )
set( SSE_MATTERS YES )
elseif( CAN_DO_ARCHSSE2 )
set( SSE1_ENABLE -arch:SSE )
set( SSE2_ENABLE -arch:SSE2 )
set( SSE_MATTERS YES )
endif()
endif()
endif()

if( X64 )
Expand Down Expand Up @@ -1051,6 +1044,7 @@ set (PCH_SOURCES
scripting/decorate/thingdef_states.cpp
scripting/zscript/ast.cpp
scripting/zscript/zcc_compile.cpp
scripting/zscript/zcc_compile_doom.cpp
scripting/zscript/zcc_parser.cpp
rendering/swrenderer/textures/r_swtexture.cpp
rendering/swrenderer/textures/warptexture.cpp
Expand Down Expand Up @@ -1254,6 +1248,7 @@ include_directories( .
common/scripting/jit
common/scripting/core
common/scripting/interface
common/scripting/frontend
common/scripting/backend
g_statusbar
console
Expand All @@ -1272,6 +1267,7 @@ include_directories( .
utility
utility/nodebuilder
scripting
scripting/zscript
rendering
rendering/vulkan/thirdparty
../libraries/gdtoa
Expand Down Expand Up @@ -1453,6 +1449,8 @@ source_group("Common\\Objects" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/
source_group("Common\\Fonts" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/fonts/.+")
source_group("Common\\File System" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/filesystem/.+")
source_group("Common\\Scripting" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/scripting/.+")
source_group("Common\\Scripting\\Interface" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/scripting/interface/.+")
source_group("Common\\Scripting\\Backend" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/scripting/backend/.+")
source_group("Common\\Scripting\\Core" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/scripting/core/.+")
source_group("Common\\Scripting\\JIT" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/scripting/jit/.+")
source_group("Common\\Scripting\\VM" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/scripting/vm/.+")
Expand Down
30 changes: 30 additions & 0 deletions src/scripting/thingdef.cpp
Expand Up @@ -53,6 +53,8 @@
#include "stats.h"
#include "info.h"
#include "thingdef.h"
#include "zcc_parser.h"
#include "zcc_compile_doom.h"

// EXTERNAL FUNCTION PROTOTYPES --------------------------------------------
void InitThingdef();
Expand Down Expand Up @@ -408,6 +410,34 @@ void ParseAllDecorate();
void SynthesizeFlagFields();
void SetDoomCompileEnvironment();

void ParseScripts()
{
int lump, lastlump = 0;
FScriptPosition::ResetErrorCounter();

while ((lump = fileSystem.FindLump("ZSCRIPT", &lastlump)) != -1)
{
ZCCParseState state;
auto newns = ParseOneScript(lump, state);
PSymbolTable symtable;

ZCCDoomCompiler cc(state, NULL, symtable, newns, lump, 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(lump).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(lump).GetChars());
}

}
}

void LoadActors()
{
cycle_t timer;
Expand Down
4 changes: 0 additions & 4 deletions src/scripting/thingdef.h
Expand Up @@ -191,10 +191,6 @@ inline void ResetBaggage (Baggage *bag, PClassActor *stateclass)
//
//==========================================================================

AFuncDesc *FindFunction(PContainerType *cls, const char * string);
FieldDesc *FindField(PContainerType *cls, const char * string);


FxExpression *ParseExpression(FScanner &sc, PClassActor *cls, PNamespace *resolvenspc = nullptr);
void ParseStates(FScanner &sc, PClassActor *actor, AActor *defaults, Baggage &bag);
void ParseFunctionParameters(FScanner &sc, PClassActor *cls, TArray<FxExpression *> &out_params,
Expand Down
18 changes: 0 additions & 18 deletions src/scripting/vmthunks.cpp
Expand Up @@ -1606,24 +1606,6 @@ DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, ReplaceTextures, ReplaceTextures)
return 0;
}

//=====================================================================================
//
// textures
//
//=====================================================================================

void SetCameraToTexture(AActor *viewpoint, const FString &texturename, double fov);

DEFINE_ACTION_FUNCTION_NATIVE(_TexMan, SetCameraToTexture, SetCameraToTexture)
{
PARAM_PROLOGUE;
PARAM_OBJECT(viewpoint, AActor);
PARAM_STRING(texturename); // [ZZ] there is no point in having this as FTextureID because it's easier to refer to a cameratexture by name and it isn't executed too often to cache it.
PARAM_FLOAT(fov);
SetCameraToTexture(viewpoint, texturename, fov);
return 0;
}

static int CheckForTexture(const FString& name, int type, int flags)
{
return TexMan.CheckForTexture(name, static_cast<ETextureType>(type), flags).GetIndex();
Expand Down

0 comments on commit 466ed4e

Please sign in to comment.