static JSValue retrieveCallerFunction(ExecState* exec, JSFunction* functionObj) { StackIterator iter = exec->find(functionObj, skipOverBoundFunctions); if (iter != exec->end()) ++iter; return iter != exec->end() && iter->callee() ? iter->callee() : jsNull(); }
void debugPrintCallFrame(JSC::CallFrame* callFrame) { if (!callFrame) return; StackIterator iter = callFrame->begin(); iter->print(2); }
Result BinaryMathOperator::operator()(Stack& stack, StackOperator::Ptr ofThis) { Number::Ptr first; Number::Ptr second; StackIterator iter = stack.begin(); iter >> first >> second; // Defer stack.popAfter() until after evaluation if(!iter) { return iter.getResult(); } // Do the math float result = 0.0; const OpInfo* info = opInfoMap[op]; if(nullptr == info) { // Internal error.... Not sure what to do. return Result({"Internal Error: Missing BinaryMathOperator."}); } stack.popAfter(iter); Number::Ptr item = Number::create(info->getFunction()(first->getValue(), second->getValue())); (*item)(stack, item); return Result({Error::Ok}); }
void debugPrintStack(JSC::CallFrame* topCallFrame) { if (!topCallFrame) return; DebugPrintStackFunctor functor; StackIterator iter = topCallFrame->begin(); iter.iterate(functor); }
PassRefPtr<ScriptCallStack> createScriptCallStack(size_t maxStackSize, bool emptyIsAllowed) { Vector<ScriptCallFrame> frames; if (JSC::ExecState* exec = JSMainThreadExecState::currentState()) { CallFrame* frame = exec->vm().topCallFrame; for (StackIterator iter = frame->begin(); iter != frame->end() && maxStackSize--; ++iter) { unsigned line; unsigned column; iter->computeLineAndColumn(line, column); frames.append(ScriptCallFrame(iter->functionName(), iter->sourceURL(), line, column)); } } if (frames.isEmpty() && !emptyIsAllowed) { // No frames found. It may happen in the case where // a bound function is called from native code for example. // Fallback to setting lineNumber to 0, and source and function name to "undefined". frames.append(ScriptCallFrame("undefined", "undefined", 0, 0)); } return ScriptCallStack::create(frames); }
PassRefPtr<ScriptCallStack> createScriptCallStack(JSC::ExecState* exec, size_t maxStackSize) { Vector<ScriptCallFrame> frames; ASSERT(exec); CallFrame* frame = exec->vm().topCallFrame; StackIterator iter = frame->begin(); if (iter.numberOfFrames() > 1) ++iter; for (; iter != frame->end() && maxStackSize--; ++iter) { // This early exit is necessary to maintain our old behaviour // but the stack trace we produce now is complete and handles all // ways in which code may be running if (!iter->callee() && frames.size()) break; unsigned line; unsigned column; iter->computeLineAndColumn(line, column); frames.append(ScriptCallFrame(iter->functionName(), iter->sourceURL(), line, column)); } return ScriptCallStack::create(frames); }
static JSValue retrieveArguments(ExecState* exec, JSFunction* functionObj) { StackIterator iter = exec->find(functionObj); return iter != exec->end() ? JSValue(iter->arguments()) : jsNull(); }
StackIterator::Status operator()(StackIterator& iter) { iter->print(2); return StackIterator::Continue; }