Example #1
0
void SLintVisitor::visit(const ast::FunctionDec & e)
{
    context.pushFn(&e);
    auto range = preCheck(e);
    e.getBody().accept(*this);
    postCheck(e, range);

    context.popFn();
}
void InstrumentVisitor::visit(ast::FunctionDec & e)
{
    types::Macro * pMacro = e.getMacro();
    if (!pMacro)
    {
        std::list<symbol::Variable *> * pVarList = new std::list<symbol::Variable *>();
        const ast::exps_t & vars = e.getArgs().getVars();
        for (const auto var : vars)
        {
            pVarList->push_back(var->getAs<ast::SimpleVar>()->getStack());
        }

        //get output parameters list
        std::list<symbol::Variable * > * pRetList = new std::list<symbol::Variable *>();
        const ast::exps_t & rets = e.getReturns().getVars();
        for (const auto ret : rets)
        {
            pRetList->push_back(ret->getAs<ast::SimpleVar>()->getStack());
        }

        pMacro = new types::Macro(e.getSymbol().getName(), *pVarList, *pRetList, static_cast<ast::SeqExp &>(e.getBody()), L"script");
        pMacro->setLines(e.getLocation().first_line, e.getLocation().last_line);
        //pMacro->setFirstLine(e.getLocation().first_line);
        e.setMacro(pMacro);
    }

    inners.push_back(pMacro);
}