escargot/src/runtime/SandBox.cpp
seonghyun kim 272c675e2e 1. sperate ByteCodeBlock::computeNodeLOCFromByteCode
2. implement selective clearing Stack
- only blockes have object, array, new expression are cleared by ClearStack function now
3. improve get object inline cache
4. remove CodeBlock::hasNonConfiguableNameOnGlobal
5. add thisValue in ExecutionState
6. optimize Value::abstractEqualsToSlowCase

Signed-off-by: seonghyun kim <sh8281.kim@samsung.com>
2017-02-13 10:36:25 +09:00

35 lines
1,005 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;
Value thisValue(m_context->globalObject());
ExecutionState state(m_context, &thisValue);
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;
}
}