added support for targeted scripts to script compiler

deque
Marc Zinnschlag 11 years ago
parent 75ab8de3d2
commit e8322da663

@ -300,9 +300,9 @@ namespace
code.push_back (Compiler::Generator::segment5 (46));
}
void opStartScript (Compiler::Generator::CodeContainer& code)
void opStartScript (Compiler::Generator::CodeContainer& code, bool targeted)
{
code.push_back (Compiler::Generator::segment5 (47));
code.push_back (Compiler::Generator::segment5 (targeted ? 71 : 47));
}
void opStopScript (Compiler::Generator::CodeContainer& code)
@ -830,9 +830,16 @@ namespace Compiler
opScriptRunning (code);
}
void startScript (CodeContainer& code)
void startScript (CodeContainer& code, Literals& literals, const std::string& id)
{
opStartScript (code);
if (id.empty())
opStartScript (code, false);
else
{
int index = literals.addString (id);
opPushInt (code, index);
opStartScript (code, true);
}
}
void stopScript (CodeContainer& code)

@ -113,7 +113,7 @@ namespace Compiler
void scriptRunning (CodeContainer& code);
void startScript (CodeContainer& code);
void startScript (CodeContainer& code, Literals& literals, const std::string& id);
void stopScript (CodeContainer& code);

@ -262,6 +262,13 @@ namespace Compiler
Generator::disable (mCode, mLiterals, mExplicit);
mState = PotentialEndState;
return true;
case Scanner::K_startscript:
mExprParser.parseArguments ("c", scanner, mCode);
Generator::startScript (mCode, mLiterals, mExplicit);
mState = EndState;
return true;
}
// check for custom extensions
@ -361,13 +368,6 @@ namespace Compiler
mState = EndState;
return true;
case Scanner::K_startscript:
mExprParser.parseArguments ("c", scanner, mCode);
Generator::startScript (mCode);
mState = EndState;
return true;
case Scanner::K_stopscript:
mExprParser.parseArguments ("c", scanner, mCode);

Loading…
Cancel
Save