mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 23:53:52 +00:00
added global variable handling to compiler context (not working yet because of case problems)
This commit is contained in:
parent
f9c1548f80
commit
d57e67e722
5 changed files with 42 additions and 12 deletions
|
@ -36,6 +36,7 @@ source_group(apps\\openmw\\mwinput FILES ${GAMEINPUT} ${GAMEINPUT_HEADER})
|
||||||
|
|
||||||
set(GAMESCRIPT
|
set(GAMESCRIPT
|
||||||
apps/openmw/mwscript/scriptmanager.cpp
|
apps/openmw/mwscript/scriptmanager.cpp
|
||||||
|
apps/openmw/mwscript/compilercontext.cpp
|
||||||
apps/openmw/mwscript/interpretercontext.cpp
|
apps/openmw/mwscript/interpretercontext.cpp
|
||||||
apps/openmw/mwscript/cellextensions.cpp
|
apps/openmw/mwscript/cellextensions.cpp
|
||||||
apps/openmw/mwscript/extensions.cpp
|
apps/openmw/mwscript/extensions.cpp
|
||||||
|
|
|
@ -180,7 +180,8 @@ void OMW::Engine::go()
|
||||||
|
|
||||||
MWScript::registerExtensions (mExtensions);
|
MWScript::registerExtensions (mExtensions);
|
||||||
|
|
||||||
mScriptContext = new MWScript::CompilerContext (MWScript::CompilerContext::Type_Full);
|
mScriptContext = new MWScript::CompilerContext (MWScript::CompilerContext::Type_Full,
|
||||||
|
mEnvironment);
|
||||||
mScriptContext->setExtensions (&mExtensions);
|
mScriptContext->setExtensions (&mExtensions);
|
||||||
|
|
||||||
mScriptManager = new MWScript::ScriptManager (mEnvironment.mWorld->getStore(), mVerboseScripts,
|
mScriptManager = new MWScript::ScriptManager (mEnvironment.mWorld->getStore(), mVerboseScripts,
|
||||||
|
|
26
apps/openmw/mwscript/compilercontext.cpp
Normal file
26
apps/openmw/mwscript/compilercontext.cpp
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
|
||||||
|
#include "compilercontext.hpp"
|
||||||
|
|
||||||
|
#include "../mwworld/environment.hpp"
|
||||||
|
#include "../mwworld/world.hpp"
|
||||||
|
|
||||||
|
namespace MWScript
|
||||||
|
{
|
||||||
|
CompilerContext::CompilerContext (Type type, const MWWorld::Environment& environment)
|
||||||
|
: mType (type), mEnvironment (environment)
|
||||||
|
{}
|
||||||
|
|
||||||
|
bool CompilerContext::canDeclareLocals() const
|
||||||
|
{
|
||||||
|
return mType==Type_Full;
|
||||||
|
}
|
||||||
|
|
||||||
|
char CompilerContext::getGlobalType (const std::string& name) const
|
||||||
|
{
|
||||||
|
if (const ESM::Global *global = mEnvironment.mWorld->getStore().globals.find (name))
|
||||||
|
return global->type;
|
||||||
|
|
||||||
|
return ' ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -3,6 +3,11 @@
|
||||||
|
|
||||||
#include <components/compiler/context.hpp>
|
#include <components/compiler/context.hpp>
|
||||||
|
|
||||||
|
namespace MWWorld
|
||||||
|
{
|
||||||
|
class Environment;
|
||||||
|
}
|
||||||
|
|
||||||
namespace MWScript
|
namespace MWScript
|
||||||
{
|
{
|
||||||
class CompilerContext : public Compiler::Context
|
class CompilerContext : public Compiler::Context
|
||||||
|
@ -19,19 +24,17 @@ namespace MWScript
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Type mType;
|
Type mType;
|
||||||
|
const MWWorld::Environment& mEnvironment;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
CompilerContext (Type type) : mType (type) {}
|
CompilerContext (Type type, const MWWorld::Environment& environment);
|
||||||
|
|
||||||
// Is the compiler allowed to declare local variables?
|
/// Is the compiler allowed to declare local variables?
|
||||||
virtual bool canDeclareLocals() const
|
virtual bool canDeclareLocals() const;
|
||||||
{
|
|
||||||
return mType==Type_Full;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual char getGlobalType (const std::string& name) const { return ' '; }
|
/// 'l: long, 's': short, 'f': float, ' ': does not exist.
|
||||||
///< 'l: long, 's': short, 'f': float, ' ': does not exist.
|
virtual char getGlobalType (const std::string& name) const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace ESM {
|
||||||
|
|
||||||
struct Global
|
struct Global
|
||||||
{
|
{
|
||||||
float value;
|
unsigned value;
|
||||||
VarType type;
|
VarType type;
|
||||||
|
|
||||||
void load(ESMReader &esm)
|
void load(ESMReader &esm)
|
||||||
|
@ -24,8 +24,7 @@ struct Global
|
||||||
else esm.fail("Illegal global variable type " + tmp);
|
else esm.fail("Illegal global variable type " + tmp);
|
||||||
type = t;
|
type = t;
|
||||||
|
|
||||||
// The value looks like a float in many cases, and like an integer
|
// Note: Both floats and longs are represented as floats.
|
||||||
// in others (for the s type at least.) Figure it out.
|
|
||||||
esm.getHNT(value, "FLTV");
|
esm.getHNT(value, "FLTV");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue