modified code to avoid a warning on MSVC

actorid
Marc Zinnschlag 15 years ago
parent d4bf916f18
commit a899a290c0

@ -23,7 +23,7 @@ namespace MWScript
: mErrorHandler (std::cerr), mStore (store), mVerbose (verbose),
mCompilerContext (compilerContext), mParser (mErrorHandler, mCompilerContext)
{}
bool ScriptManager::compile (const std::string& name)
{
mParser.reset();
@ -32,22 +32,22 @@ namespace MWScript
bool Success = true;
if (const ESM::Script *script = mStore.scripts.find (name))
{
{
if (mVerbose)
std::cout << "compiling script: " << name << std::endl;
try
{
{
std::istringstream input (script->scriptText);
Compiler::Scanner scanner (mErrorHandler, input, mCompilerContext.getExtensions());
scanner.scan (mParser);
if (!mErrorHandler.isGood())
Success = false;
}
catch (const std::exception& error)
catch (...)
{
Success = false;
}
@ -59,20 +59,20 @@ namespace MWScript
<< script->scriptText
<< std::endl << std::endl;
}
if (Success)
{
std::vector<Interpreter::Type_Code> code;
mParser.getCode (code);
mScripts.insert (std::make_pair (name, code));
// TODO sanity check on generated locals
return true;
}
}
return false;
return false;
}
void ScriptManager::run (const std::string& name, Interpreter::Context& interpreterContext)
@ -80,7 +80,7 @@ namespace MWScript
// compile script
std::map<std::string, std::vector<Interpreter::Type_Code> >::iterator iter =
mScripts.find (name);
if (iter==mScripts.end())
{
if (!compile (name))
@ -90,28 +90,27 @@ namespace MWScript
mScripts.insert (std::make_pair (name, empty));
return;
}
iter = mScripts.find (name);
assert (iter!=mScripts.end());
}
// execute script
if (!iter->second.empty())
try
{
Interpreter::Interpreter interpreter (interpreterContext);
installOpcodes (interpreter);
interpreter.run (&iter->second[0], iter->second.size());
interpreter.run (&iter->second[0], iter->second.size());
}
catch (const std::exception& e)
{
std::cerr << "exeution of script " << name << " failed." << std::endl;
if (mVerbose)
std::cerr << "(" << e.what() << ")" << std::endl;
iter->second.clear(); // don't execute again.
}
}
}

Loading…
Cancel
Save