#include "config.h"
#include "Completion.h"
#include "CallFrame.h"
#include "CodeProfiling.h"
#include "JSGlobalObject.h"
#include "JSLock.h"
#include "Interpreter.h"
#include "Parser.h"
#include "Debugger.h"
#include <wtf/WTFThreadData.h>
#include <stdio.h>
namespace JSC {
bool checkSyntax(ExecState* exec, const SourceCode& source, JSValue* returnedException)
{
JSLockHolder lock(exec);
ASSERT(exec->globalData().identifierTable == wtfThreadData().currentIdentifierTable());
ProgramExecutable* program = ProgramExecutable::create(exec, source);
JSObject* error = program->checkSyntax(exec);
if (error) {
if (returnedException)
*returnedException = error;
return false;
}
return true;
}
JSValue evaluate(ExecState* exec, ScopeChainNode* scopeChain, const SourceCode& source, JSValue thisValue, JSValue* returnedException)
{
JSLockHolder lock(exec);
ASSERT(exec->globalData().identifierTable == wtfThreadData().currentIdentifierTable());
if (exec->globalData().isCollectorBusy())
CRASH();
CodeProfiling profile(source);
ProgramExecutable* program = ProgramExecutable::create(exec, source);
if (!program) {
if (returnedException)
*returnedException = exec->globalData().exception;
exec->globalData().exception = JSValue();
return jsUndefined();
}
if (!thisValue || thisValue.isUndefinedOrNull())
thisValue = exec->dynamicGlobalObject();
JSObject* thisObj = thisValue.toThisObject(exec);
JSValue result = exec->interpreter()->execute(program, exec, scopeChain, thisObj);
if (exec->hadException()) {
if (returnedException)
*returnedException = exec->exception();
exec->clearException();
return jsUndefined();
}
ASSERT(result);
return result;
}
}