|
|
@ -132,7 +132,34 @@ namespace Interpreter
|
|
|
|
throw std::runtime_error (error.str());
|
|
|
|
throw std::runtime_error (error.str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Interpreter::Interpreter()
|
|
|
|
void Interpreter::begin()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (mRunning)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
mCallstack.push (mRuntime);
|
|
|
|
|
|
|
|
mRuntime.clear();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
mRunning = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Interpreter::end()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (mCallstack.empty())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
mRuntime.clear();
|
|
|
|
|
|
|
|
mRunning = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
mRuntime = mCallstack.top();
|
|
|
|
|
|
|
|
mCallstack.pop();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Interpreter::Interpreter() : mRunning (false)
|
|
|
|
{}
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
Interpreter::~Interpreter()
|
|
|
|
Interpreter::~Interpreter()
|
|
|
@ -202,6 +229,10 @@ namespace Interpreter
|
|
|
|
{
|
|
|
|
{
|
|
|
|
assert (codeSize>=4);
|
|
|
|
assert (codeSize>=4);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
begin();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
mRuntime.configure (code, codeSize, context);
|
|
|
|
mRuntime.configure (code, codeSize, context);
|
|
|
|
|
|
|
|
|
|
|
|
int opcodes = static_cast<int> (code[0]);
|
|
|
|
int opcodes = static_cast<int> (code[0]);
|
|
|
@ -214,7 +245,13 @@ namespace Interpreter
|
|
|
|
mRuntime.setPC (mRuntime.getPC()+1);
|
|
|
|
mRuntime.setPC (mRuntime.getPC()+1);
|
|
|
|
execute (code);
|
|
|
|
execute (code);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (...)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
end();
|
|
|
|
|
|
|
|
throw;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
mRuntime.clear();
|
|
|
|
end();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|