mirror of
https://github.com/Samsung/escargot.git
synced 2026-06-22 10:01:50 +00:00
1. implement tracing stack when got exception
2. binding function name 3. implement sandbox for isolate throw exception 4. implement object expression 5. implement get, set object operation 6. implement logical and, or operation Signed-off-by: seonghyun kim <sh8281.kim@samsung.com>
This commit is contained in:
parent
b17523eb33
commit
288b147659
48 changed files with 1158 additions and 272 deletions
|
|
@ -8,6 +8,7 @@
|
|||
#include "runtime/Environment.h"
|
||||
#include "runtime/EnvironmentRecord.h"
|
||||
#include "runtime/ErrorObject.h"
|
||||
#include "runtime/SandBox.h"
|
||||
|
||||
namespace Escargot {
|
||||
|
||||
|
|
@ -21,26 +22,33 @@ Script::ScriptExecuteResult Script::execute(Context* ctx)
|
|||
ByteCodeGenerator g;
|
||||
g.generateByteCode(ctx, m_topCodeBlock, programNode);
|
||||
|
||||
ExecutionState stateForInit(ctx);
|
||||
LexicalEnvironment* globalEnvironment = new LexicalEnvironment(new GlobalEnvironmentRecord(stateForInit, m_topCodeBlock, ctx->globalObject()), nullptr);
|
||||
LexicalEnvironment* globalEnvironment;
|
||||
{
|
||||
ExecutionState stateForInit(ctx);
|
||||
globalEnvironment = new LexicalEnvironment(new GlobalEnvironmentRecord(stateForInit, m_topCodeBlock, ctx->globalObject()), nullptr);
|
||||
}
|
||||
|
||||
ExecutionContext ec(ctx, globalEnvironment, m_topCodeBlock->isStrict());
|
||||
ExecutionContext ec(ctx, nullptr, globalEnvironment, m_topCodeBlock->isStrict());
|
||||
Value resultValue;
|
||||
ExecutionState state(ctx, &ec, &resultValue);
|
||||
try {
|
||||
|
||||
SandBox sb(ctx);
|
||||
auto sandBoxResult = sb.run([&]() -> Value {
|
||||
ByteCodeInterpreter::interpret(state, m_topCodeBlock);
|
||||
result.error = Value(Value::EmptyValue);
|
||||
result.result = resultValue;
|
||||
return result;
|
||||
} catch(const Value& err) {
|
||||
result.result = Value(Value::EmptyValue);
|
||||
result.error = err;
|
||||
return result;
|
||||
} catch(PointerValue* err) {
|
||||
result.result = Value(Value::EmptyValue);
|
||||
result.error = err;
|
||||
return result;
|
||||
return resultValue;
|
||||
});
|
||||
result.result = sandBoxResult.result;
|
||||
result.error.errorValue = sandBoxResult.error;
|
||||
if (!sandBoxResult.error.isEmpty()) {
|
||||
for (size_t i = 0; i < sandBoxResult.stackTraceData.size(); i ++) {
|
||||
ScriptExecuteResult::Error::StackTrace t;
|
||||
t.fileName = sandBoxResult.stackTraceData[i].fileName;
|
||||
t.line = sandBoxResult.stackTraceData[i].loc.line;
|
||||
t.column = sandBoxResult.stackTraceData[i].loc.column;
|
||||
result.error.stackTrace.pushBack(t);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue