mirror of
https://github.com/Samsung/escargot.git
synced 2026-06-29 10:02:14 +00:00
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>
35 lines
1,005 B
C++
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;
|
|
}
|
|
}
|