1 2 void visit(AST::LiteralExpression * lexp)3::visit( AST::LiteralExpression* lexp ) { 4 5 } 6 7 void visit(AST::IdentifierExpression * iexp)8::visit( AST::IdentifierExpression* iexp ) { 9 10 } 11 12 void visit(AST::UnaryExpression * uexp)13::visit( AST::UnaryExpression* uexp ) { 14 15 } 16 17 void visit(AST::BinaryExpression * bexp)18::visit( AST::BinaryExpression* bexp ) { 19 20 } 21 22 void visit(AST::ConditionalExpression * cexp)23::visit( AST::ConditionalExpression* cexp ) { 24 25 } 26 27 void visit(AST::AssignmentExpression * aexp)28::visit( AST::AssignmentExpression* aexp ) { 29 AST::IdentifierExpression *id_expr = dynamic_cast< AST::IdentifierExpression* >( aexp->e1 ); 30 assert( id_expr ); 31 Variable *var = id_expr->var; 32 33 } 34 35 void visit(AST::FunctionCall * funcall)36::visit( AST::FunctionCall* funcall ) { 37 AST::ExpressionList::iterator arg_iter; 38 FunctionType::ParameterList::iterator param_iter; 39 // do something with actual arguments 40 arg_iter = funcall->exp_list->begin(); 41 param_iter = funcall->fun_type->parameters.begin(); 42 for( ; arg_iter != funcall->exp_list->end(); ++arg_iter, ++param_iter ) { 43 Variable *var = *param_iter; 44 AST::Expression *exp = *arg_iter; 45 46 } 47 48 49 //AST::FunctionDefinition *fun_def = symbol_env.findFunctionDef( funcall->fun_type->id ); 50 //assert( fun_def != nullptr ); 51 52 // postprocessing 53 param_iter = funcall->fun_type->parameters.begin(); 54 for( ; param_iter != funcall->fun_type->parameters.end(); ++param_iter ) { 55 Variable *var = *param_iter; 56 57 } 58 59 } 60 61 void visit(AST::EmptyStatement * stmt)62::visit( AST::EmptyStatement* stmt ) { 63 64 } 65 66 void visit(AST::ExpressionStatement * estmt)67::visit( AST::ExpressionStatement* estmt ) { 68 69 } 70 71 void visit(AST::ConditionalStatement * cstmt)72::visit( AST::ConditionalStatement* cstmt ) { 73 if( cstmt->else_branch ) { 74 75 } 76 } 77 78 void visit(AST::Return * ret)79::visit( AST::Return* ret ) { 80 81 } 82 83 void visit(AST::StatementList * slist)84::visit( AST::StatementList* slist ) { 85 AST::StatementContainer::iterator it; 86 for( it = slist->statements->begin(); it != slist->statements->end(); ++it ) { 87 AST::Statement *stmt = *it; 88 89 } 90 } 91 92 void visit(AST::VariableDeclaration * vardecl)93::visit( AST::VariableDeclaration* vardecl ) { 94 95 } 96 97 void visit(AST::CompoundStatement * compound)98::visit( AST::CompoundStatement* compound ) { 99 100 } 101 102 void visit(AST::FunctionDefinition * fundef)103::visit( AST::FunctionDefinition* fundef ) { 104 FunctionType::ParameterList::iterator it; 105 for( it = fundef->type->parameters.begin(); it != fundef->type->parameters.end(); ++it ) { 106 Variable *var = *it; 107 108 } 109 // do something with fundef->body 110 111 // postprocessing 112 for( it = fundef->type->parameters.begin(); it != fundef->type->parameters.end(); ++it ) { 113 Variable *var = *it; 114 115 } 116 } 117 118 void visit(AST::TranslationUnit * tu)119::visit( AST::TranslationUnit* tu ) { 120 std::vector< AST::FunctionDefinition* >::iterator it; 121 for( it = tu->functions.begin(); it != tu->functions.end(); ++it ) { 122 AST::FunctionDefinition *fundef = *it; 123 124 } 125 126 }