    001    /* Copyright 2000, 2001, Compaq Computer Corporation */
    002
    003    package javafe.ast;
    004
    005    import javafe.util.Assert;
    006    import javafe.util.Location;
    007
    008
    009    public class DefaultVisitor extends Visitor {
    010
    011      public void visitASTNode(ASTNode x) {
    012        // Assert.fail("DefaultVisitor.visitASTNode"+x);
    013      }
    014
    015      public void visitModifierPragma(ModifierPragma x) {
    016      }
    017
    018      public void visitTypeDeclElemPragma(TypeDeclElemPragma x) {
    019      }
    020
    021      public void visitStmtPragma(StmtPragma x) {
    022      }
    023
    024      public void visitTypeModifierPragma(TypeModifierPragma x) {
    025      }
    026
    027      public void visitLexicalPragma(LexicalPragma x) {
    028      }
    029
    030
    031      public void visitCompilationUnit(CompilationUnit x) {
    032        for(int i=0; i<x.imports.size(); i++)
    033          x.imports.elementAt(i).accept( this );
    034        for(int i=0; i<x.elems.size(); i++)
    035          x.elems.elementAt(i).accept( this );
    036        if( x.lexicalPragmas != null )
    037            for(int i=0; i<x.lexicalPragmas.size(); i++)
    038                x.lexicalPragmas.elementAt(i).accept( this );
    039      }
    040
    041      public void visitTypeDecl(TypeDecl x) {
    042        for(int i=0; i<x.superInterfaces.size(); i++)
    043          x.superInterfaces.elementAt(i).accept( this );
    044        for(int i=0; i<x.elems.size(); i++)
    045          x.elems.elementAt(i).accept( this );
    046        if( x.pmodifiers != null )
    047            for(int i=0; i<x.pmodifiers.size(); i++)
    048                x.pmodifiers.elementAt(i).accept( this );
    049        if( x.tmodifiers != null )
    050            for(int i=0; i<x.tmodifiers.size(); i++)
    051                x.tmodifiers.elementAt(i).accept( this );
    052      }
    053
    054      public void visitClassDecl(ClassDecl x) {
    055        if( x.superClass != null ) x.superClass.accept( this );
    056        visitTypeDecl(x);
    057      }
    058
    059      public void visitInterfaceDecl(InterfaceDecl x) {
    060        visitTypeDecl(x);
    061      }
    062
    063      public void visitRoutineDecl(RoutineDecl x) {
    064        for(int i=0; i<x.args.size(); i++)
    065          x.args.elementAt(i).accept( this );
    066        for(int i=0; i<x.raises.size(); i++)
    067          x.raises.elementAt(i).accept( this );
    068        if( x.pmodifiers != null )
    069            for(int i=0; i<x.pmodifiers.size(); i++)
    070                x.pmodifiers.elementAt(i).accept( this );
    071        if( x.body != null ) x.body.accept( this );
    072
    073      }
    074
    075      public void visitConstructorDecl(ConstructorDecl x) {
    076        visitRoutineDecl(x);
    077        if( x.tmodifiers != null )
    078            for(int i=0; i<x.tmodifiers.size(); i++)
    079                x.tmodifiers.elementAt(i).accept( this );
    080      }
    081
    082      public void visitMethodDecl(MethodDecl x) {
    083        visitRoutineDecl(x);
    084        x.returnType.accept( this );
    085      }
    086
    087      public void visitInitBlock(InitBlock x) {
    088        x.block.accept( this );
    089        if( x.pmodifiers != null )
    090            for(int i=0; i<x.pmodifiers.size(); i++)
    091                x.pmodifiers.elementAt(i).accept( this );
    092      }
    093
    094      public void visitGenericVarDecl(GenericVarDecl x) {
    095        if( x.pmodifiers != null )
    096            for(int i=0; i<x.pmodifiers.size(); i++)
    097                x.pmodifiers.elementAt(i).accept( this );
    098        x.type.accept( this );
    099      }
    100
    101      public void visitLocalVarDecl(LocalVarDecl x) {
    102        visitGenericVarDecl(x);
    103        if( x.init != null ) x.init.accept( this );
    104      }
    105
    106      public void visitFieldDecl(FieldDecl x) {
    107        visitGenericVarDecl(x);
    108        if( x.init != null ) x.init.accept( this );
    109      }
    110
    111      public void visitFormalParaDecl(FormalParaDecl x) {
    112        visitGenericVarDecl(x);
    113      }
    114
    115      // ------------------------------
    116
    117      public void visitGenericBlockStmt(GenericBlockStmt x) {
    118        for(int i=0; i<x.stmts.size(); i++)
    119          x.stmts.elementAt(i).accept( this );
    120      }
    121
    122      public void visitBlockStmt(BlockStmt x) {
    123        visitGenericBlockStmt(x);
    124      }
    125
    126      public void visitSwitchStmt(SwitchStmt x) {
    127        visitGenericBlockStmt(x);
    128        x.expr.accept( this );
    129      }
    130
    131      public void visitClassDeclStmt(ClassDeclStmt x) {
    132        x.decl.accept( this );
    133      }
    134
    135      public void visitVarDeclStmt(VarDeclStmt x) {
    136        x.decl.accept( this );
    137      }
    138
    139      public void visitWhileStmt(WhileStmt x) {
    140        x.expr.accept( this );
    141        x.stmt.accept( this );
    142      }
    143
    144      public void visitDoStmt(DoStmt x) {
    145        x.expr.accept( this );
    146        x.stmt.accept( this );
    147      }
    148
    149      public void visitSynchronizeStmt(SynchronizeStmt x) {
    150        x.expr.accept( this );
    151        x.stmt.accept( this );
    152      }
    153
    154      public void visitEvalStmt(EvalStmt x) {
    155        x.expr.accept( this );
    156      }
    157
    158      public void visitReturnStmt(ReturnStmt x) {
    159        if( x.expr != null ) x.expr.accept( this );
    160      }
    161
    162      public void visitThrowStmt(ThrowStmt x) {
    163        x.expr.accept( this );
    164      }
    165
    166      public void visitBranchStmt(BranchStmt x) {
    167      }
    168
    169      public void visitBreakStmt(BreakStmt x) {
    170      }
    171
    172      public void visitContinueStmt(ContinueStmt x) {
    173      }
    174
    175      public void visitLabelStmt(LabelStmt x) {
    176        x.stmt.accept( this );
    177      }
    178
    179      public void visitIfStmt(IfStmt x) {
    180        x.expr.accept( this );
    181        x.thn.accept( this );
    182        x.els.accept( this );
    183      }
    184
    185      public void visitForStmt(ForStmt x) {
    186        for(int i=0; i<x.forInit.size(); i++)
    187          x.forInit.elementAt(i).accept( this );
    188        x.test.accept( this );
    189        for(int i=0; i<x.forUpdate.size(); i++)
    190          x.forUpdate.elementAt(i).accept( this );
    191        x.body.accept( this );
    192      }
    193
    194      public void visitSkipStmt(SkipStmt x) {
    195      }
    196
    197      public void visitSwitchLabel(SwitchLabel x) {
    198        if( x.expr != null ) x.expr.accept( this );
    199      }
    200
    201      public void visitTryFinallyStmt(TryFinallyStmt x) {
    202        x.tryClause.accept( this );
    203        x.finallyClause.accept( this );
    204      }
    205
    206      public void visitTryCatchStmt(TryCatchStmt x) {
    207        x.tryClause.accept( this );
    208        for(int i=0; i<x.catchClauses.size(); i++)
    209          x.catchClauses.elementAt(i).accept( this );
    210      }
    211
    212      public void visitConstructorInvocation(ConstructorInvocation x) {
    213        for(int i=0; i<x.args.size(); i++)
    214          x.args.elementAt(i).accept( this );
    215      }
    216
    217      public void visitCatchClause(CatchClause x) {
    218        x.arg.accept( this );
    219        x.body.accept( this );
    220      }
    221
    222      public void visitArrayInit(ArrayInit x) {
    223        for(int i=0; i<x.elems.size(); i++)
    224          x.elems.elementAt(i).accept( this );
    225      }
    226
    227      public void visitExpr(Expr x) {
    228      }
    229
    230      public void visitThisExpr(ThisExpr x) {
    231        if (x.classPrefix != null)
    232            x.classPrefix.accept( this );
    233        visitExpr(x);
    234      }
    235
    236      public void visitLiteralExpr(LiteralExpr x) {
    237        visitExpr(x);
    238      }
    239
    240      public void visitArrayRefExpr(ArrayRefExpr x) {
    241        x.array.accept( this );
    242        x.index.accept( this );
    243        visitExpr(x);
    244      }
    245
    246      public void visitNewInstanceExpr(NewInstanceExpr x) {
    247        x.type.accept( this );
    248        for(int i=0; i<x.args.size(); i++)
    249          x.args.elementAt(i).accept( this );
    250        if (x.anonDecl != null) x.anonDecl.accept( this );
    251        visitExpr(x);
    252      }
    253
    254      public void visitNewArrayExpr(NewArrayExpr x) {
    255        x.type.accept( this );
    256        for(int i=0; i<x.dims.size(); i++)
    257          x.dims.elementAt(i).accept( this );
    258        if (x.init != null) x.init.accept( this );
    259        visitExpr(x);
    260      }
    261
    262      public void visitCondExpr(CondExpr x) {
    263        x.test.accept( this );
    264        x.thn.accept( this );
    265        x.els.accept( this );
    266        visitExpr(x);
    267      }
    268
    269      public void visitInstanceOfExpr(InstanceOfExpr x) {
    270        x.expr.accept( this );
    271        x.type.accept( this );
    272        visitExpr(x);
    273      }
    274
    275      public void visitCastExpr(CastExpr x) {
    276        x.expr.accept( this );
    277        x.type.accept( this );
    278        visitExpr(x);
    279      }
    280
    281      public void visitBinaryExpr(BinaryExpr x) {
    282        x.left.accept( this );
    283        x.right.accept( this );
    284        visitExpr(x);
    285      }
    286
    287      public void visitUnaryExpr(UnaryExpr x) {
    288        x.expr.accept( this );
    289        visitExpr(x);
    290      }
    291
    292      public void visitParenExpr(ParenExpr x) {
    293        x.expr.accept( this );
    294        visitExpr(x);
    295      }
    296
    297      public void visitAmbiguousVariableAccess(AmbiguousVariableAccess x) {
    298        visitExpr(x);
    299      }
    300
    301      public void visitVariableAccess(VariableAccess x) {
    302        visitExpr(x);
    303      }
    304
    305      public void visitFieldAccess(FieldAccess x) {
    306        x.od.accept( this );
    307        visitExpr(x);
    308      }
    309
    310      public void visitAmbiguousMethodInvocation(AmbiguousMethodInvocation x) {
    311        for(int i=0; i<x.args.size(); i++)
    312          x.args.elementAt(i).accept( this );
    313        visitExpr(x);
    314      }
    315
    316      public void visitMethodInvocation(MethodInvocation x) {
    317        x.od.accept( this );
    318        for(int i=0; i<x.args.size(); i++)
    319          x.args.elementAt(i).accept( this );
    320        visitExpr(x);
    321      }
    322
    323      public void visitClassLiteral(ClassLiteral x) {
    324        x.type.accept( this );
    325        visitExpr(x);
    326      }
    327
    328
    329      // ------------------------------
    330
    331      public void visitExprObjectDesignator(ExprObjectDesignator x) {
    332        x.expr.accept( this );
    333        visitObjectDesignator(x);
    334      }
    335
    336      public void visitTypeObjectDesignator(TypeObjectDesignator x) {
    337        x.type.accept( this );
    338        visitObjectDesignator(x);
    339      }
    340
    341      public void visitSuperObjectDesignator(SuperObjectDesignator x) {
    342        visitObjectDesignator(x);
    343      }
    344
    345      // ------------------------------
    346
    347      public void visitPrimitiveType(PrimitiveType x) {
    348        visitType(x);
    349      }
    350
    351      public void visitTypeName(TypeName x) {
    352        visitType(x);
    353      }
    354
    355      public void visitArrayType(ArrayType x) {
    356        x.elemType.accept( this );
    357        visitType(x);
    358      }
    359
    360      public void visitType(Type x) {
    361      }
    362
    363      // ------------------------------
    364
    365      public void visitName(Name x) {
    366      }
    367    }