31 #include "../bridge/qscriptactivationobject_p.h" 33 #include "Arguments.h" 34 #include "CodeBlock.h" 36 #include "JSFunction.h" 38 #include "JSGlobalObject.h" 40 #include <QtCore/qstringlist.h> 175 frame->setException(jscValue);
197 JSC::ErrorType jscError = JSC::GeneralError;
202 jscError = JSC::ReferenceError;
205 jscError = JSC::SyntaxError;
208 jscError = JSC::TypeError;
211 jscError = JSC::RangeError;
214 jscError = JSC::URIError;
217 JSC::JSObject *result = JSC::throwError(frame, jscError, text);
236 JSC::JSObject *result = JSC::throwError(frame, JSC::GeneralError, text);
313 if (frame == frame->lexicalGlobalObject()->globalExec()) {
319 if (frame->codeBlock() && frame->callee()) {
326 JSC::JSValue result = frame->interpreter()->retrieveArguments(frame, JSC::asFunction(frame->callee()));
330 if (frame->callerFrame()->hasHostCallFrameFlag()) {
336 if (!frame->optionalCalleeArguments()
338 Q_ASSERT(frame->argumentCount() > 0);
339 JSC::Arguments* arguments =
new (&frame->globalData())JSC::Arguments(frame, JSC::Arguments::NoParameters);
340 frame->setCalleeArguments(arguments);
366 JSC::Instruction* returnPC = frame->returnPC();
375 if (returnPC[-JSC::op_construct_length].
u.opcode == frame->interpreter()->getOpcode(JSC::op_construct)) {
381 return returnPC[-1].u.operand < returnPC[-3].u.operand;
393 JSC::CallFrame *callerFrame = frame->callerFrame()->removeHostCallFrameFlag();
410 int argc = frame->argumentCount();
421 qWarning(
"QScriptContext::returnValue() not implemented");
432 if (!callerFrame->codeBlock())
435 int dst = frame->registers()[JSC::RegisterFile::ReturnValueRegister].i();
454 JSC::JSObject *result = 0;
460 frame->setScopeChain(frame->scopeChain()->copy()->push(scope));
465 JSC::ScopeChainNode *node = frame->scopeChain();
466 JSC::ScopeChainIterator
it(node);
467 for (it = node->begin(); it != node->end(); ++
it) {
468 if ((*it) && (*it)->isVariableObject()) {
478 qWarning(
"QScriptContext::activationObject: could not get activation object for frame");
516 qWarning(
"QScriptContext::setActivationObject() failed: " 517 "cannot set an object created in " 518 "a different engine");
531 JSC::JSObject *scope = object;
532 if (!scope->isVariableObject()) {
536 frame->setScopeChain(frame->scopeChain()->copy()->push(scope));
542 JSC::ScopeChainNode *node = frame->scopeChain();
544 if (node->object && node->object->isVariableObject()) {
545 if (!object->isVariableObject()) {
553 node->object = object;
570 if (!result || result.isNull())
571 result = frame->globalThisValue();
588 qWarning(
"QScriptContext::setThisObject() failed: " 589 "cannot set an object created in " 590 "a different engine");
593 if (frame == frame->lexicalGlobalObject()->globalExec()) {
598 JSC::CodeBlock *cb = frame->codeBlock();
600 frame[cb->thisRegister()] = jscThisObject;
603 thisRegister[0] = jscThisObject;
613 if (frame->hadException())
662 else if(frame->callerFrame()->hasHostCallFrameFlag())
670 result.
append(functionName);
678 if (i < parameterNames.
count()) {
679 result.
append(parameterNames.
at(i));
719 JSC::ScopeChainNode *node = frame->scopeChain();
720 JSC::ScopeChainIterator
it(node);
721 for (it = node->begin(); it != node->end(); ++
it) {
722 JSC::JSObject *
object = *
it;
749 if (!
object.isObject())
752 qWarning(
"QScriptContext::pushScope() failed: " 753 "cannot push an object created in " 754 "a different engine");
763 JSC::ScopeChainNode *scope = frame->scopeChain();
765 if (!scope->object) {
767 if (!jscObject->isGlobalObject()) {
768 qWarning(
"QScriptContext::pushScope() failed: initial object in scope chain has to be the Global Object");
771 scope->object = jscObject;
774 frame->setScopeChain(scope->push(jscObject));
794 JSC::ScopeChainNode *scope = frame->scopeChain();
803 frame->setScopeChain(scope->pop());
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
The QScriptContext class represents a Qt Script function invocation.
QScriptValue property(const QString &name, const ResolveFlags &mode=ResolvePrototype) const
Returns the value of this QScriptValue's property with the given name, using the given mode to resolv...
static JSC::ExecState * frameForContext(QScriptContext *context)
QScriptEnginePrivate * scriptEngineFromExec(const JSC::ExecState *exec)
static mach_timebase_info_data_t info
#define QT_END_NAMESPACE
This macro expands to.
bool isCalledAsConstructor() const
Returns true if the function was called as a constructor (e.g.
static JSC::Register * thisRegisterForFrame(JSC::ExecState *frame)
static const JSC::ClassInfo info
#define it(className, varName)
static QScriptEnginePrivate * get(QScriptEngine *q)
QString toString() const
Returns a string representation of this context.
QScriptValue callee() const
Returns the callee.
static uint contextFlags(JSC::ExecState *)
For native context, we use the ReturnValueRegister entry in the stackframe header to store flags...
QScriptValueList scopeChain() const
Returns the scope chain of this QScriptContext.
QScriptValue throwError(Error error, const QString &text)
Throws an error with the given text.
QScriptValue argumentsObject() const
Returns the arguments object of this QScriptContext.
QString toString() const
Returns the string value of this QScriptValue, as defined in ECMA-262 section 9.8, "ToString".
QScriptValue globalObject() const
Returns this engine's Global Object.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
int count(const T &t) const
Returns the number of occurrences of value in the list.
QScriptEngine * engine() const
Returns the QScriptEngine that this QScriptContext belongs to.
The QString class provides a Unicode character string.
ExecutionState
This enum specifies the frameution state of the context.
void setThisObject(const QScriptValue &thisObject)
Sets the `this' object associated with this QScriptContext to be thisObject.
static void setContextFlags(JSC::ExecState *, uint)
void setActivationObject(const QScriptValue &activation)
Sets the activation object of this QScriptContext to be the given activation.
QString fileName() const
Returns the name of the file where the code being executed was defined, if available; otherwise retur...
QScriptValue popScope()
Removes the front object from this context's scope chain, and returns the removed object...
void append(const T &t)
Inserts value at the end of the list.
The QScriptEngine class provides an environment for evaluating Qt Script code.
#define QT_BEGIN_NAMESPACE
This macro expands to.
int lineNumber() const
Returns the line number corresponding to the statement being executed, or -1 if the line number is no...
JSC::JSValue scriptValueToJSCValue(const QScriptValue &value)
static QScriptContext * contextForFrame(JSC::ExecState *frame)
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
JSC::JSGlobalObject * originalGlobalObject() const
bool isString() const
Returns true if this QScriptValue is of the primitive type String; otherwise returns false...
const T & at(int i) const
Returns the item at index position i in the list.
QScriptEngine * engine() const
Returns the QScriptEngine that created this QScriptValue, or 0 if this QScriptValue is invalid or the...
The QStringList class provides a list of strings.
QStringList backtrace() const
Returns a human-readable backtrace of this QScriptContext.
Q_CORE_EXPORT void qWarning(const char *,...)
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
void setGlobalObject(const QScriptValue &object)
Sets this engine's Global Object to be the given object.
int argumentCount() const
Returns the number of arguments passed to the function in this invocation.
ExecutionState state() const
Returns the frameution state of this QScriptContext.
#define Q_ASSERT_X(cond, where, what)
The QScriptContextInfo class provides additional information about a QScriptContext.
QString & append(QChar c)
QStringList functionParameterNames() const
Returns the names of the formal parameters of the called function, or an empty QStringList if the par...
void setReturnValue(const QScriptValue &result)
Error
This enum specifies types of error.
JSC::JSObject * originalGlobalObjectProxy
~QScriptContext()
Destroys this QScriptContext.
FunctionType functionType() const
Returns the type of the called function.
QScriptValue scriptValueFromJSCValue(JSC::JSValue value)
QScriptValue activationObject() const
Returns the activation object of this QScriptContext.
Represent a scope for native function call.
QScriptValue thisObject() const
Returns the `this' object associated with this QScriptContext.
void pushScope(const QScriptValue &object)
Adds the given object to the front of this context's scope chain.
static JSC::JSValue thisForContext(JSC::ExecState *frame)
The QScriptValue class acts as a container for the Qt Script data types.
static QString fileName(const QString &fileUrl)
QScriptValue returnValue() const
QScriptValue argument(int index) const
Returns the function argument at the given index.
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
QScriptContext * parentContext() const
Returns the parent context of this QScriptContext.
static bool hasValidCodeBlockRegister(JSC::ExecState *frame)
bool isObject() const
Returns true if this QScriptValue is of the Object type; otherwise returns false. ...
QString functionName() const
Returns the name of the called function, or an empty string if the name is not available.
QScriptValue throwValue(const QScriptValue &value)
Throws an exception with the given value.