Пример #1
0
void updateFuncExprNodeProfilerIdent(ExpressionNode* node, const ExpressionNode* base, const Identifier& ident)
{
	ASSERT(node);
	ASSERT(node->isFuncExprNode());
    
	FuncExprNode* funcExprNode = static_cast<FuncExprNode*>(node);
    if (base) {
        UString name(ident.ustring());
        const UString dotString(".");

        const ExpressionNode* baseIterator = base;
        while (baseIterator && baseIterator->isDotAccessorNode()) {
            const DotAccessorNode* const dotAccessorNode = static_cast<const DotAccessorNode*>(baseIterator);
            name = makeString(dotAccessorNode->identifier().ustring(), dotString, name);
            baseIterator = dotAccessorNode->base();
        }

        if (baseIterator && baseIterator->isResolveNode()) {
            const ResolveNode* const resolveNode = static_cast<const ResolveNode*>(baseIterator);
            name = makeString(resolveNode->identifier().ustring(), dotString, name);
        }

        funcExprNode->body()->setContextualName(name);
    } else {
        funcExprNode->body()->setContextualName(ident.ustring());
    }
}
Пример #2
0
static FunctionBodyNode* functionBody(ProgramNode* program)
{
    if (!program)
        return 0;

    StatementVector& children = program->children();
    if (children.size() != 1)
        return 0;

    ExprStatementNode* exprStatement = static_cast<ExprStatementNode*>(children[0].get()); 
    ASSERT(exprStatement->isExprStatement());
    if (!exprStatement || !exprStatement->isExprStatement())
        return 0;

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

    FunctionBodyNode* body = funcExpr->body();
    ASSERT(body);
    return body;
}