escargot/src/runtime/SandBox.cpp
seonghyun kim e362acb82d 1. store thisValue in stackStorage instead of ExecutionState
2. remove GetThis byte code
3. optimize Function::call
4. optimize {get, set} of TypedArrayObject

Signed-off-by: seonghyun kim <sh8281.kim@samsung.com>
2017-02-14 18:32:15 +09:00

34 lines
945 B
C++

#include "Escargot.h"
#include "SandBox.h"
#include "runtime/Context.h"
#include "runtime/Environment.h"
#include "runtime/EnvironmentRecord.h"
#include "parser/Script.h"
#include "interpreter/ByteCode.h"
#include "interpreter/ByteCodeInterpreter.h"
namespace Escargot {
SandBox::SandBoxResult SandBox::run(const std::function<Value()>& scriptRunner)
{
SandBox::SandBoxResult result;
ExecutionState state(m_context);
try {
result.result = scriptRunner();
result.msgStr = result.result.toString(state);
} catch (const Value& err) {
result.error = err;
result.msgStr = result.error.toString(state);
for (size_t i = 0; i < m_stackTraceData.size(); i++) {
result.stackTraceData.pushBack(m_stackTraceData[i].second);
}
}
return result;
}
void SandBox::throwException(ExecutionState& state, Value exception)
{
m_exception = exception;
throw exception;
}
}