void WebDebugListenerImpl::sourceParsedFunctions(ExecState* execState, intptr_t sourceId, JSC::ParserArenaData<DeclarationStacks::FunctionStack>* funcStack)
{
    if (m_listener && !m_inDebug) {
        m_inDebug = true;

        MarkedArgumentBuffer funcList;
        ArgList empty;

        Identifier functionName (execState, "functionName");
        Identifier firstLine (execState, "firstLine");
        Identifier lastLine (execState, "lastLine");

        for(size_t i=0, l=funcStack->data.size(); i<l; i++) {
            FunctionBodyNode *funcBody = funcStack->data[i];

            ASSERT(funcBody);
            if (!funcBody) continue;

            JSObject* funcObj = JSC::constructEmptyObject(execState);

            JSC::PutPropertySlot slot;
            funcObj->put(execState, functionName, jsString( execState, funcBody->ident().ustring() ), slot );

            funcObj->put(execState, firstLine, jsNumber ( execState, funcBody->firstLine() ), slot );
            funcObj->put(execState, lastLine,  jsNumber ( execState, funcBody->lastLine() ), slot);

            funcList.append(funcObj);

        }

        JSObject* functions = JSC::constructArray(execState, funcList);

        WebScriptProxyVariant* functionsVariant = WebCore::ApolloScriptBridging::getApolloVariantForJSValue(execState, functions);

        m_listener->m_pVTable->sourceParsedFunctions(m_listener, sourceId, functionsVariant);

        m_inDebug = false;
    }
}
Esempio n. 2
0
FunctionExecutable* FunctionExecutable::fromGlobalCode(const Identifier& functionName, ExecState* exec, Debugger* debugger, const SourceCode& source, JSObject** exception)
{
    JSGlobalObject* lexicalGlobalObject = exec->lexicalGlobalObject();
    RefPtr<ProgramNode> program = exec->globalData().parser->parse<ProgramNode>(lexicalGlobalObject, debugger, exec, source, 0, JSParseNormal, exception);
    if (!program) {
        ASSERT(*exception);
        return 0;
    }

    // Uses of this function that would not result in a single function expression are invalid.
    StatementNode* exprStatement = program->singleStatement();
    ASSERT(exprStatement);
    ASSERT(exprStatement->isExprStatement());
    ExpressionNode* funcExpr = static_cast<ExprStatementNode*>(exprStatement)->expr();
    ASSERT(funcExpr);
    ASSERT(funcExpr->isFuncExprNode());
    FunctionBodyNode* body = static_cast<FuncExprNode*>(funcExpr)->body();
    ASSERT(body);

    return FunctionExecutable::create(exec->globalData(), functionName, body->source(), body->usesArguments(), body->parameters(), body->isStrictMode(), body->lineNo(), body->lastLine());
}
Esempio n. 3
0
PassRefPtr<FunctionExecutable> FunctionExecutable::fromGlobalCode(const Identifier& functionName, ExecState* exec, Debugger* debugger, const SourceCode& source, int* errLine, UString* errMsg)
{
    RefPtr<ProgramNode> program = exec->globalData().parser->parse<ProgramNode>(&exec->globalData(), debugger, exec, source, errLine, errMsg);
    if (!program)
        return 0;

    StatementNode* exprStatement = program->singleStatement();
    ASSERT(exprStatement);
    ASSERT(exprStatement->isExprStatement());
    if (!exprStatement || !exprStatement->isExprStatement())
        return 0;

    ExpressionNode* funcExpr = static_cast<ExprStatementNode*>(exprStatement)->expr();
    ASSERT(funcExpr);
    ASSERT(funcExpr->isFuncExprNode());
    if (!funcExpr || !funcExpr->isFuncExprNode())
        return 0;

    FunctionBodyNode* body = static_cast<FuncExprNode*>(funcExpr)->body();
    ASSERT(body);
    return FunctionExecutable::create(&exec->globalData(), functionName, body->source(), body->usesArguments(), body->parameters(), body->lineNo(), body->lastLine());
}