00001
00002
00003 #ifndef ptree_visitor_h
00004 #define ptree_visitor_h
00005
00006 #include <cassert>
00007 #include <algorithm>
00008
00009 #include "source.h"
00010 #include "downcast.h"
00011
00012
00013 #include <ptree.h>
00014 #include <walker.h>
00015
00016
00017
00018
00019
00020
00021 class Source;
00022
00030 template <typename Returntype>
00031 class Ptree_visitor : private Walker
00032 {
00033
00034 typedef Walker Super;
00035
00036
00037 Source* _s;
00038 Returntype _saved;
00039
00040 public:
00041 using Super::operator delete;
00042 using Super::operator new;
00043
00044 Source* get_source() const { return _s; }
00045
00046 public:
00047 explicit Ptree_visitor(Source* s);
00048
00049 virtual ~Ptree_visitor();
00050
00051 Returntype visit();
00052
00053 virtual Returntype visit(Ptree *p);
00054
00055 virtual Returntype visit_null();
00056
00057
00058
00059
00060
00064 virtual Returntype visit_leaf(Leaf *p);
00065
00066 virtual Returntype visit_nonleaf(NonLeaf *p);
00067
00068 virtual Returntype visit_declarator(PtreeDeclarator *p);
00069
00073 virtual Returntype visit_typedef(PtreeTypedef *p);
00074
00075 virtual Returntype visit_templatedecl(PtreeTemplateDecl *p);
00076
00077 virtual Returntype visit_templateinstantiation(PtreeTemplateInstantiation *p);
00078
00079 virtual Returntype visit_externtemplate(PtreeExternTemplate *p);
00080
00081 virtual Returntype visit_linkagespec(PtreeLinkageSpec *p);
00082
00083 virtual Returntype visit_namespacespec(PtreeNamespaceSpec *p);
00084
00085 virtual Returntype visit_using(PtreeUsing *p);
00086
00087 virtual Returntype visit_declaration(PtreeDeclaration *p);
00088
00089 virtual Returntype visit_brace(PtreeBrace *p);
00090
00091 virtual Returntype visit_block(PtreeBlock *p);
00092
00093 virtual Returntype visit_classbody(PtreeClassBody *p);
00094
00095 virtual Returntype visit_classspec(PtreeClassSpec *p);
00096
00097 virtual Returntype visit_enumspec(PtreeEnumSpec *p);
00098
00099 virtual Returntype visit_accessspec(PtreeAccessSpec *p);
00100
00101 virtual Returntype visit_accessdecl(PtreeAccessDecl *p);
00102
00103 virtual Returntype visit_useraccessspec(PtreeUserAccessSpec *p);
00104
00105 virtual Returntype visit_if(PtreeIfStatement *p);
00106
00107 virtual Returntype visit_switch(PtreeSwitchStatement *p);
00108
00109 virtual Returntype visit_while(PtreeWhileStatement *p);
00110
00111 virtual Returntype visit_do(PtreeDoStatement *p);
00112
00113 virtual Returntype visit_for(PtreeForStatement *p);
00114
00115 virtual Returntype visit_try(PtreeTryStatement *p);
00116
00117 virtual Returntype visit_break(PtreeBreakStatement *p);
00118
00119 virtual Returntype visit_continue(PtreeContinueStatement *p);
00120
00121 virtual Returntype visit_return(PtreeReturnStatement *p);
00122
00123 virtual Returntype visit_goto(PtreeGotoStatement *p);
00124
00125 virtual Returntype visit_case(PtreeCaseStatement *p);
00126
00127 virtual Returntype visit_default(PtreeDefaultStatement *p);
00128
00129 virtual Returntype visit_label(PtreeLabelStatement *p);
00130
00131 virtual Returntype visit_expr(PtreeExprStatement *p);
00132
00133 virtual Returntype visit_comma(PtreeCommaExpr *p);
00134
00135 virtual Returntype visit_assign(PtreeAssignExpr *p);
00136
00137 virtual Returntype visit_cond(PtreeCondExpr *p);
00138
00139 virtual Returntype visit_infix(PtreeInfixExpr *p);
00140
00141 virtual Returntype visit_pm(PtreePmExpr *p);
00142
00143 virtual Returntype visit_cast(PtreeCastExpr *p);
00144
00145 virtual Returntype visit_unary(PtreeUnaryExpr *p);
00146
00147 virtual Returntype visit_throw(PtreeThrowExpr *p);
00148
00149 virtual Returntype visit_sizeof(PtreeSizeofExpr *p);
00150
00151 virtual Returntype visit_new(PtreeNewExpr *p);
00152
00153 virtual Returntype visit_delete(PtreeDeleteExpr *p);
00154
00155 virtual Returntype visit_array(PtreeArrayExpr *p);
00156
00157 virtual Returntype visit_funcall(PtreeFuncallExpr *p);
00158
00159 virtual Returntype visit_postfix(PtreePostfixExpr *p);
00160
00161 virtual Returntype visit_userstatement(PtreeUserStatementExpr *p);
00162
00163 virtual Returntype visit_dotmember(PtreeDotMemberExpr *p);
00164
00165 virtual Returntype visit_arrowmember(PtreeArrowMemberExpr *p);
00166
00167 virtual Returntype visit_paren(PtreeParenExpr *p);
00168
00169 virtual Returntype visit_staticuserstatement(PtreeStaticUserStatementExpr *p);
00170
00171 virtual Returntype visit_exprstatement(PtreeExprStatement *p);
00172
00173 virtual Returntype visit_fstylecastexpr(PtreeFstyleCastExpr *p);
00174
00177 virtual Returntype visit_name(Ptree *p);
00178
00179 virtual Returntype visit_this(LeafThis *p);
00180
00181 protected:
00188 Returntype recurse(Ptree* p);
00189
00196 virtual Returntype default_action(Ptree* p);
00197
00198 virtual void runtime_error();
00199
00200 private:
00201
00202
00203
00204
00205
00206
00207 virtual Ptree* TranslatePtree(Ptree *p);
00208
00209 virtual Ptree* TranslateTypedef(Ptree *p);
00210
00211 virtual Ptree* TranslateTemplateDecl(Ptree *p);
00212
00213 virtual Ptree* TranslateTemplateInstantiation(Ptree *p);
00214
00215 virtual Ptree* TranslateExternTemplate(Ptree *p);
00216
00217 virtual Ptree* TranslateLinkageSpec(Ptree *p);
00218
00219 virtual Ptree* TranslateNamespaceSpec(Ptree *p);
00220
00221 virtual Ptree* TranslateUsing(Ptree *p);
00222
00223 virtual Ptree* TranslateDeclaration(Ptree *p);
00224
00225 virtual Ptree* TranslateBrace(Ptree *p);
00226
00227 virtual Ptree* TranslateBlock(Ptree *p);
00228
00229 virtual Ptree* TranslateClassBody(Ptree *p, Ptree *, Class *);
00230
00231 virtual Ptree* TranslateClassSpec(Ptree *p);
00232
00233 virtual Ptree* TranslateEnumSpec(Ptree *p);
00234
00235 virtual Ptree* TranslateAccessSpec(Ptree *p);
00236
00237 virtual Ptree* TranslateAccessDecl(Ptree *p);
00238
00239 virtual Ptree* TranslateUserAccessSpec(Ptree *p);
00240
00241 virtual Ptree* TranslateIf(Ptree *p);
00242
00243 virtual Ptree* TranslateSwitch(Ptree *p);
00244
00245 virtual Ptree* TranslateWhile(Ptree *p);
00246
00247 virtual Ptree* TranslateDo(Ptree *p);
00248
00249 virtual Ptree* TranslateFor(Ptree *p);
00250
00251 virtual Ptree* TranslateTry(Ptree *p);
00252
00253 virtual Ptree* TranslateBreak(Ptree *p);
00254
00255 virtual Ptree* TranslateContinue(Ptree *p);
00256
00257 virtual Ptree* TranslateReturn(Ptree *p);
00258
00259 virtual Ptree* TranslateGoto(Ptree *p);
00260
00261 virtual Ptree* TranslateCase(Ptree *p);
00262
00263 virtual Ptree* TranslateDefault(Ptree *p);
00264
00265 virtual Ptree* TranslateLabel(Ptree *p);
00266
00267 virtual Ptree* TranslateExprStatement(Ptree *p);
00268
00269 virtual Ptree* TranslateComma(Ptree *p);
00270
00271 virtual Ptree* TranslateAssign(Ptree *p);
00272
00273 virtual Ptree* TranslateCond(Ptree *p);
00274
00275 virtual Ptree* TranslateInfix(Ptree *p);
00276
00277 virtual Ptree* TranslatePm(Ptree *p);
00278
00279 virtual Ptree* TranslateCast(Ptree *p);
00280
00281 virtual Ptree* TranslateUnary(Ptree *p);
00282
00283 virtual Ptree* TranslateThrow(Ptree *p);
00284
00285 virtual Ptree* TranslateSizeof(Ptree *p);
00286
00287 virtual Ptree* TranslateNew(Ptree *p);
00288
00289 virtual Ptree* TranslateDelete(Ptree *p);
00290
00291 virtual Ptree* TranslateArray(Ptree *p);
00292
00293 virtual Ptree* TranslateFuncall(Ptree *p);
00294
00295 virtual Ptree* TranslatePostfix(Ptree *p);
00296
00297 virtual Ptree* TranslateUserStatement(Ptree *p);
00298
00299 virtual Ptree* TranslateDotMember(Ptree *p);
00300
00301 virtual Ptree* TranslateArrowMember(Ptree *p);
00302
00303 virtual Ptree* TranslateParen(Ptree *p);
00304
00305 virtual Ptree* TranslateStaticUserStatement(Ptree *p);
00306
00307 virtual Ptree* TranslateFstyleCast(Ptree *p);
00308
00309 virtual Ptree* TranslateVariable(Ptree *p);
00310
00311 virtual Ptree* TranslateThis(Ptree *p);
00312
00313
00314
00315 virtual bool IsClassWalker();
00316
00317 virtual void TypeofPtree(Ptree *, TypeInfo &);
00318
00319 virtual Ptree* TranslateTemplateInstantiation(Ptree *, Ptree *, Ptree *, Class *);
00320
00321 virtual Ptree* TranslateTemplateClass(Ptree *, Ptree *);
00322
00323 virtual Ptree* TranslateTemplateFunction(Ptree *, Ptree *);
00324
00325 virtual Ptree* TranslateStorageSpecifiers(Ptree *);
00326
00327 virtual Ptree* TranslateDeclarators(Ptree *);
00328
00329 virtual Ptree* TranslateDeclarator(bool, PtreeDeclarator *);
00330
00331 virtual Ptree* TranslateArgDeclList(bool, Ptree *, Ptree *);
00332
00333 virtual Ptree* TranslateInitializeArgs(PtreeDeclarator *, Ptree *);
00334
00335 virtual Ptree* TranslateAssignInitializer(PtreeDeclarator *, Ptree *);
00336
00337 virtual Ptree* TranslateFunctionImplementation(Ptree *);
00338
00339 virtual Ptree* RecordArgsAndTranslateFbody(Class *, Ptree *args, Ptree *body);
00340
00341 virtual Ptree* TranslateFunctionBody(Ptree *);
00342
00343 virtual Ptree* TranslateClassSpec(Ptree *, Ptree *, Ptree *, Class *);
00344
00345 virtual Ptree* TranslateTypespecifier(Ptree *);
00346
00347 virtual Ptree* TranslateNew2(Ptree *, Ptree *, Ptree *, Ptree *, Ptree *, Ptree *, Ptree *);
00348
00349 virtual Ptree* TranslateNew3(Ptree *type);
00350
00351
00352 virtual Class* MakeTemplateInstantiationMetaobject(Ptree *full_class_spec, Ptree *userkey, Ptree *class_spec);
00353
00354 virtual Class* MakeTemplateClassMetaobject(Ptree *, Ptree *, Ptree *);
00355
00356 virtual Class* MakeClassMetaobject(Ptree *, Ptree *, Ptree *);
00357
00358
00359 virtual void TypeofComma(Ptree *, TypeInfo &);
00360
00361 virtual void TypeofAssign(Ptree *, TypeInfo &);
00362
00363 virtual void TypeofCond(Ptree *, TypeInfo &);
00364
00365 virtual void TypeofInfix(Ptree *, TypeInfo &);
00366
00367 virtual void TypeofPm(Ptree *, TypeInfo &);
00368
00369 virtual void TypeofCast(Ptree *, TypeInfo &);
00370
00371 virtual void TypeofUnary(Ptree *, TypeInfo &);
00372
00373 virtual void TypeofThrow(Ptree *, TypeInfo &);
00374
00375 virtual void TypeofSizeof(Ptree *, TypeInfo &);
00376
00377 virtual void TypeofNew(Ptree *, TypeInfo &);
00378
00379 virtual void TypeofDelete(Ptree *, TypeInfo &);
00380
00381 virtual void TypeofThis(Ptree *, TypeInfo &);
00382
00383 virtual void TypeofVariable(Ptree *, TypeInfo &);
00384
00385 virtual void TypeofFstyleCast(Ptree *, TypeInfo &);
00386
00387 virtual void TypeofArray(Ptree *, TypeInfo &);
00388
00389 virtual void TypeofFuncall(Ptree *, TypeInfo &);
00390
00391 virtual void TypeofPostfix(Ptree *, TypeInfo &);
00392
00393 virtual void TypeofUserStatement(Ptree *, TypeInfo &);
00394
00395 virtual void TypeofDotMember(Ptree *, TypeInfo &);
00396
00397 virtual void TypeofArrowMember(Ptree *, TypeInfo &);
00398
00399 virtual void TypeofParen(Ptree *, TypeInfo &);
00400
00401 virtual void TypeofStaticUserStatement(Ptree *, TypeInfo &);
00402 };
00403
00404
00405
00406
00407
00408
00409
00410
00411 template <typename Returntype> Ptree_visitor<Returntype>::Ptree_visitor(Source* s)
00412 : Walker (s->parser()),
00413 _s (s)
00414 {
00415 }
00416
00417
00418
00419 template <typename Returntype> Ptree_visitor<Returntype>::~Ptree_visitor()
00420 {
00421 }
00422
00423
00424
00425 template <typename Returntype> Returntype
00426 Ptree_visitor<Returntype>::visit()
00427 {
00428 _s->translate(this);
00429 return _saved;
00430 }
00431
00432
00433
00434 template <typename Returntype> Returntype
00435 Ptree_visitor<Returntype>::visit(Ptree *p)
00436 {
00437 if (! p)
00438 return visit_null ();
00439
00440 Returntype saved = _saved;
00441
00442 Super::Translate (p);
00443
00444 std::swap (_saved, saved);
00445 return saved;
00446 }
00447
00448
00456 template <typename Returntype> Returntype
00457 Ptree_visitor<Returntype>::recurse(Ptree* p)
00458 {
00459 assert (p);
00460
00461 if (p->IsLeaf())
00462 return Returntype(0);
00463
00464 Returntype r(0);
00465
00466 do
00467 {
00468 r = visit (p->Car());
00469 p = p->Cdr();
00470
00471 if (p && p->IsLeaf())
00472 {
00473 r = visit (p);
00474 break;
00475 }
00476 }
00477 while (p);
00478
00479 return r;
00480 }
00481
00482
00490 template <typename Returntype> Returntype
00491 Ptree_visitor<Returntype>::default_action(Ptree* p)
00492 {
00493 if (p)
00494 return recurse (p);
00495
00496 return Returntype (0);
00497 }
00498
00499
00500
00501 template <typename Returntype> Returntype
00502 Ptree_visitor<Returntype>::visit_null()
00503 {
00504 return default_action (0);
00505 }
00506
00507
00508
00509
00510
00511
00512
00517 template <typename Returntype> Returntype
00518 Ptree_visitor<Returntype>::visit_leaf(Leaf *p)
00519 {
00520 return default_action(p);
00521 }
00522
00523
00524
00525 template <typename Returntype> Returntype
00526 Ptree_visitor<Returntype>::visit_nonleaf(NonLeaf *p)
00527 {
00528 return default_action(p);
00529 }
00530
00531
00532
00533 template <typename Returntype> Returntype
00534 Ptree_visitor<Returntype>::visit_declarator(PtreeDeclarator *p)
00535 {
00536 return default_action(p);
00537 }
00538
00539
00544 template <typename Returntype> Returntype
00545 Ptree_visitor<Returntype>::visit_typedef(PtreeTypedef *p)
00546 {
00547 return default_action(p);
00548 }
00549
00550
00551
00552 template <typename Returntype> Returntype
00553 Ptree_visitor<Returntype>::visit_templatedecl(PtreeTemplateDecl *p)
00554 {
00555 return default_action(p);
00556 }
00557
00558
00559
00560 template <typename Returntype> Returntype
00561 Ptree_visitor<Returntype>::visit_templateinstantiation(PtreeTemplateInstantiation *p)
00562 {
00563 return default_action(p);
00564 }
00565
00566
00567
00568 template <typename Returntype> Returntype
00569 Ptree_visitor<Returntype>::visit_externtemplate(PtreeExternTemplate *p)
00570 {
00571 return default_action(p);
00572 }
00573
00574
00575
00576 template <typename Returntype> Returntype
00577 Ptree_visitor<Returntype>::visit_linkagespec(PtreeLinkageSpec *p)
00578 {
00579 return default_action(p);
00580 }
00581
00582
00583
00584 template <typename Returntype> Returntype
00585 Ptree_visitor<Returntype>::visit_namespacespec(PtreeNamespaceSpec *p)
00586 {
00587 return default_action(p);
00588 }
00589
00590
00591
00592 template <typename Returntype> Returntype
00593 Ptree_visitor<Returntype>::visit_using(PtreeUsing *p)
00594 {
00595 return default_action(p);
00596 }
00597
00598
00599
00600 template <typename Returntype> Returntype
00601 Ptree_visitor<Returntype>::visit_declaration(PtreeDeclaration *p)
00602 {
00603 return default_action(p);
00604 }
00605
00606
00607
00608 template <typename Returntype> Returntype
00609 Ptree_visitor<Returntype>::visit_brace(PtreeBrace *p)
00610 {
00611 return default_action(p);
00612 }
00613
00614
00615
00616 template <typename Returntype> Returntype
00617 Ptree_visitor<Returntype>::visit_block(PtreeBlock *p)
00618 {
00619 return default_action(p);
00620 }
00621
00622
00623
00624 template <typename Returntype> Returntype
00625 Ptree_visitor<Returntype>::visit_classbody(PtreeClassBody *p)
00626 {
00627 return default_action(p);
00628 }
00629
00630
00631
00632 template <typename Returntype> Returntype
00633 Ptree_visitor<Returntype>::visit_classspec(PtreeClassSpec *p)
00634 {
00635 return default_action(p);
00636 }
00637
00638
00639
00640 template <typename Returntype> Returntype
00641 Ptree_visitor<Returntype>::visit_enumspec(PtreeEnumSpec *p)
00642 {
00643 return default_action(p);
00644 }
00645
00646
00647
00648 template <typename Returntype> Returntype
00649 Ptree_visitor<Returntype>::visit_accessspec(PtreeAccessSpec *p)
00650 {
00651 return default_action(p);
00652 }
00653
00654
00655
00656 template <typename Returntype> Returntype
00657 Ptree_visitor<Returntype>::visit_accessdecl(PtreeAccessDecl *p)
00658 {
00659 return default_action(p);
00660 }
00661
00662
00663
00664 template <typename Returntype> Returntype
00665 Ptree_visitor<Returntype>::visit_useraccessspec(PtreeUserAccessSpec *p)
00666 {
00667 return default_action(p);
00668 }
00669
00670
00671
00672 template <typename Returntype> Returntype
00673 Ptree_visitor<Returntype>::visit_if(PtreeIfStatement *p)
00674 {
00675 return default_action(p);
00676 }
00677
00678
00679
00680 template <typename Returntype> Returntype
00681 Ptree_visitor<Returntype>::visit_switch(PtreeSwitchStatement *p)
00682 {
00683 return default_action(p);
00684 }
00685
00686
00687
00688 template <typename Returntype> Returntype
00689 Ptree_visitor<Returntype>::visit_while(PtreeWhileStatement *p)
00690 {
00691 return default_action(p);
00692 }
00693
00694
00695
00696 template <typename Returntype> Returntype
00697 Ptree_visitor<Returntype>::visit_do(PtreeDoStatement *p)
00698 {
00699 return default_action(p);
00700 }
00701
00702
00703
00704 template <typename Returntype> Returntype
00705 Ptree_visitor<Returntype>::visit_for(PtreeForStatement *p)
00706 {
00707 return default_action(p);
00708 }
00709
00710
00711
00712 template <typename Returntype> Returntype
00713 Ptree_visitor<Returntype>::visit_try(PtreeTryStatement *p)
00714 {
00715 return default_action(p);
00716 }
00717
00718
00719
00720 template <typename Returntype> Returntype
00721 Ptree_visitor<Returntype>::visit_break(PtreeBreakStatement *p)
00722 {
00723 return default_action(p);
00724 }
00725
00726
00727
00728 template <typename Returntype> Returntype
00729 Ptree_visitor<Returntype>::visit_continue(PtreeContinueStatement *p)
00730 {
00731 return default_action(p);
00732 }
00733
00734
00735
00736 template <typename Returntype> Returntype
00737 Ptree_visitor<Returntype>::visit_return(PtreeReturnStatement *p)
00738 {
00739 return default_action(p);
00740 }
00741
00742
00743
00744 template <typename Returntype> Returntype
00745 Ptree_visitor<Returntype>::visit_goto(PtreeGotoStatement *p)
00746 {
00747 return default_action(p);
00748 }
00749
00750
00751
00752 template <typename Returntype> Returntype
00753 Ptree_visitor<Returntype>::visit_case(PtreeCaseStatement *p)
00754 {
00755 return default_action(p);
00756 }
00757
00758
00759
00760 template <typename Returntype> Returntype
00761 Ptree_visitor<Returntype>::visit_default(PtreeDefaultStatement *p)
00762 {
00763 return default_action(p);
00764 }
00765
00766
00767
00768 template <typename Returntype> Returntype
00769 Ptree_visitor<Returntype>::visit_label(PtreeLabelStatement *p)
00770 {
00771 return default_action(p);
00772 }
00773
00774
00775
00776 template <typename Returntype> Returntype
00777 Ptree_visitor<Returntype>::visit_expr(PtreeExprStatement *p)
00778 {
00779 return default_action(p);
00780 }
00781
00782
00783
00784 template <typename Returntype> Returntype
00785 Ptree_visitor<Returntype>::visit_comma(PtreeCommaExpr *p)
00786 {
00787 return default_action(p);
00788 }
00789
00790
00791
00792 template <typename Returntype> Returntype
00793 Ptree_visitor<Returntype>::visit_assign(PtreeAssignExpr *p)
00794 {
00795 return default_action(p);
00796 }
00797
00798
00799
00800 template <typename Returntype> Returntype
00801 Ptree_visitor<Returntype>::visit_cond(PtreeCondExpr *p)
00802 {
00803 return default_action(p);
00804 }
00805
00806
00807
00808 template <typename Returntype> Returntype
00809 Ptree_visitor<Returntype>::visit_infix(PtreeInfixExpr *p)
00810 {
00811 return default_action(p);
00812 }
00813
00814
00815
00816 template <typename Returntype> Returntype
00817 Ptree_visitor<Returntype>::visit_pm(PtreePmExpr *p)
00818 {
00819 return default_action(p);
00820 }
00821
00822
00823
00824 template <typename Returntype> Returntype
00825 Ptree_visitor<Returntype>::visit_cast(PtreeCastExpr *p)
00826 {
00827 return default_action(p);
00828 }
00829
00830
00831
00832 template <typename Returntype> Returntype
00833 Ptree_visitor<Returntype>::visit_unary(PtreeUnaryExpr *p)
00834 {
00835 return default_action(p);
00836 }
00837
00838
00839
00840 template <typename Returntype> Returntype
00841 Ptree_visitor<Returntype>::visit_throw(PtreeThrowExpr *p)
00842 {
00843 return default_action(p);
00844 }
00845
00846
00847
00848 template <typename Returntype> Returntype
00849 Ptree_visitor<Returntype>::visit_sizeof(PtreeSizeofExpr *p)
00850 {
00851 return default_action(p);
00852 }
00853
00854
00855
00856 template <typename Returntype> Returntype
00857 Ptree_visitor<Returntype>::visit_new(PtreeNewExpr *p)
00858 {
00859 return default_action(p);
00860 }
00861
00862
00863
00864 template <typename Returntype> Returntype
00865 Ptree_visitor<Returntype>::visit_delete(PtreeDeleteExpr *p)
00866 {
00867 return default_action(p);
00868 }
00869
00870
00871
00872 template <typename Returntype> Returntype
00873 Ptree_visitor<Returntype>::visit_array(PtreeArrayExpr *p)
00874 {
00875 return default_action(p);
00876 }
00877
00878
00879
00880 template <typename Returntype> Returntype
00881 Ptree_visitor<Returntype>::visit_funcall(PtreeFuncallExpr *p)
00882 {
00883 return default_action(p);
00884 }
00885
00886
00887
00888 template <typename Returntype> Returntype
00889 Ptree_visitor<Returntype>::visit_postfix(PtreePostfixExpr *p)
00890 {
00891 return default_action(p);
00892 }
00893
00894
00895
00896 template <typename Returntype> Returntype
00897 Ptree_visitor<Returntype>::visit_userstatement(PtreeUserStatementExpr *p)
00898 {
00899 return default_action(p);
00900 }
00901
00902
00903
00904 template <typename Returntype> Returntype
00905 Ptree_visitor<Returntype>::visit_dotmember(PtreeDotMemberExpr *p)
00906 {
00907 return default_action(p);
00908 }
00909
00910
00911
00912 template <typename Returntype> Returntype
00913 Ptree_visitor<Returntype>::visit_arrowmember(PtreeArrowMemberExpr *p)
00914 {
00915 return default_action(p);
00916 }
00917
00918
00919
00920 template <typename Returntype> Returntype
00921 Ptree_visitor<Returntype>::visit_paren(PtreeParenExpr *p)
00922 {
00923 return default_action(p);
00924 }
00925
00926
00927
00928 template <typename Returntype> Returntype
00929 Ptree_visitor<Returntype>::visit_staticuserstatement(PtreeStaticUserStatementExpr *p)
00930 {
00931 return default_action(p);
00932 }
00933
00934
00935
00936 template <typename Returntype> Returntype
00937 Ptree_visitor<Returntype>::visit_exprstatement(PtreeExprStatement *p)
00938 {
00939 return default_action(p);
00940 }
00941
00942
00943
00944 template <typename Returntype> Returntype
00945 Ptree_visitor<Returntype>::visit_fstylecastexpr(PtreeFstyleCastExpr *p)
00946 {
00947 return default_action(p);
00948 }
00949
00950
00954 template <typename Returntype> Returntype
00955 Ptree_visitor<Returntype>::visit_name(Ptree *p)
00956 {
00957 return default_action(p);
00958 }
00959
00960
00961
00962 template <typename Returntype> Returntype
00963 Ptree_visitor<Returntype>::visit_this(LeafThis *p)
00964 {
00965 return default_action(p);
00966 }
00967
00968
00969
00970 template <typename Returntype> void
00971 Ptree_visitor<Returntype>::runtime_error()
00972 {
00973 assert (!"This should never be called.");
00974 }
00975
00976
00977
00978
00979
00980
00981
00982
00983
00984
00985 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslatePtree(Ptree *p)
00986 {
00987
00988
00989
00990 if (p->IsLeaf())
00991 _saved = visit_leaf (downcast<Leaf*>(p));
00992 else if (PtreeDeclarator* d = dynamic_cast<PtreeDeclarator*>(p))
00993 _saved = visit_declarator (d);
00994 else
00995 _saved = visit_nonleaf (downcast<NonLeaf*>(p));
00996
00997
00998 return 0;
00999 }
01000
01001
01002
01003 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateTypedef(Ptree *p)
01004 {
01005 _saved = visit_typedef (downcast<PtreeTypedef*>(p));
01006 return 0;
01007 }
01008
01009
01010
01011 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateTemplateDecl(Ptree *p)
01012 {
01013 _saved = visit_templatedecl (downcast<PtreeTemplateDecl*>(p));
01014 return 0;
01015 }
01016
01017
01018
01019 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateTemplateInstantiation(Ptree *p)
01020 {
01021 _saved = visit_templateinstantiation
01022 (downcast<PtreeTemplateInstantiation*>(p));
01023 return 0;
01024 }
01025
01026
01027
01028 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateExternTemplate(Ptree *p)
01029 {
01030 _saved = visit_externtemplate (downcast<PtreeExternTemplate*>(p));
01031 return 0;
01032 }
01033
01034
01035
01036 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateLinkageSpec(Ptree *p)
01037 {
01038 _saved = visit_linkagespec (downcast<PtreeLinkageSpec*>(p));
01039 return 0;
01040 }
01041
01042
01043
01044 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateNamespaceSpec(Ptree *p)
01045 {
01046 _saved = visit_namespacespec (downcast<PtreeNamespaceSpec*>(p));
01047 return 0;
01048 }
01049
01050
01051
01052 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateUsing(Ptree *p)
01053 {
01054 _saved = visit_using (downcast<PtreeUsing*>(p));
01055 return 0;
01056 }
01057
01058
01059
01060 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateDeclaration(Ptree *p)
01061 {
01062 _saved = visit_declaration (downcast<PtreeDeclaration*>(p));
01063 return 0;
01064 }
01065
01066
01067
01068 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateBrace(Ptree *p)
01069 {
01070 _saved = visit_brace (downcast<PtreeBrace*>(p));
01071 return 0;
01072 }
01073
01074
01075
01076 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateBlock(Ptree *p)
01077 {
01078 _saved = visit_block (downcast<PtreeBlock*>(p));
01079 return 0;
01080 }
01081
01082
01083
01084 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateClassBody(Ptree *p, Ptree *, Class *)
01085 {
01086 _saved = visit_classbody (downcast<PtreeClassBody*>(p));
01087 return 0;
01088 }
01089
01090
01091
01092 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateClassSpec(Ptree *p)
01093 {
01094 _saved = visit_classspec (downcast<PtreeClassSpec*>(p));
01095 return 0;
01096 }
01097
01098
01099
01100 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateEnumSpec(Ptree *p)
01101 {
01102 _saved = visit_enumspec (downcast<PtreeEnumSpec*>(p));
01103 return 0;
01104 }
01105
01106
01107
01108 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateAccessSpec(Ptree *p)
01109 {
01110 _saved = visit_accessspec (downcast<PtreeAccessSpec*>(p));
01111 return 0;
01112 }
01113
01114
01115
01116 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateAccessDecl(Ptree *p)
01117 {
01118 _saved = visit_accessdecl (downcast<PtreeAccessDecl*>(p));
01119 return 0;
01120 }
01121
01122
01123
01124 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateUserAccessSpec(Ptree *p)
01125 {
01126 _saved = visit_useraccessspec (downcast<PtreeUserAccessSpec*>(p));
01127 return 0;
01128 }
01129
01130
01131
01132 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateIf(Ptree *p)
01133 {
01134 _saved = visit_if (downcast<PtreeIfStatement*>(p));
01135 return 0;
01136 }
01137
01138
01139
01140 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateSwitch(Ptree *p)
01141 {
01142 _saved = visit_switch (downcast<PtreeSwitchStatement*>(p));
01143 return 0;
01144 }
01145
01146
01147
01148 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateWhile(Ptree *p)
01149 {
01150 _saved = visit_while (downcast<PtreeWhileStatement*>(p));
01151 return 0;
01152 }
01153
01154
01155
01156 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateDo(Ptree *p)
01157 {
01158 _saved = visit_do (downcast<PtreeDoStatement*>(p));
01159 return 0;
01160 }
01161
01162
01163
01164 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateFor(Ptree *p)
01165 {
01166 _saved = visit_for (downcast<PtreeForStatement*>(p));
01167 return 0;
01168 }
01169
01170
01171
01172 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateTry(Ptree *p)
01173 {
01174 _saved = visit_try (downcast<PtreeTryStatement*>(p));
01175 return 0;
01176 }
01177
01178
01179
01180 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateBreak(Ptree *p)
01181 {
01182 _saved = visit_break (downcast<PtreeBreakStatement*>(p));
01183 return 0;
01184 }
01185
01186
01187
01188 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateContinue(Ptree *p)
01189 {
01190 _saved = visit_continue (downcast<PtreeContinueStatement*>(p));
01191 return 0;
01192 }
01193
01194
01195
01196 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateReturn(Ptree *p)
01197 {
01198 _saved = visit_return (downcast<PtreeReturnStatement*>(p));
01199 return 0;
01200 }
01201
01202
01203
01204 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateGoto(Ptree *p)
01205 {
01206 _saved = visit_goto (downcast<PtreeGotoStatement*>(p));
01207 return 0;
01208 }
01209
01210
01211
01212 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateCase(Ptree *p)
01213 {
01214 _saved = visit_case (downcast<PtreeCaseStatement*>(p));
01215 return 0;
01216 }
01217
01218
01219
01220 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateDefault(Ptree *p)
01221 {
01222 _saved = visit_default (downcast<PtreeDefaultStatement*>(p));
01223 return 0;
01224 }
01225
01226
01227
01228 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateLabel(Ptree *p)
01229 {
01230 _saved = visit_label (downcast<PtreeLabelStatement*>(p));
01231 return 0;
01232 }
01233
01234
01235
01236 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateExprStatement(Ptree *p)
01237 {
01238 _saved = visit_exprstatement (downcast<PtreeExprStatement*>(p));
01239 return 0;
01240 }
01241
01242
01243
01244 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateComma(Ptree *p)
01245 {
01246 _saved = visit_comma (downcast<PtreeCommaExpr*>(p));
01247 return 0;
01248 }
01249
01250
01251
01252 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateAssign(Ptree *p)
01253 {
01254 _saved = visit_assign (downcast<PtreeAssignExpr*>(p));
01255 return 0;
01256 }
01257
01258
01259
01260 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateCond(Ptree *p)
01261 {
01262 _saved = visit_cond (downcast<PtreeCondExpr*>(p));
01263 return 0;
01264 }
01265
01266
01267
01268 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateInfix(Ptree *p)
01269 {
01270 _saved = visit_infix (downcast<PtreeInfixExpr*>(p));
01271 return 0;
01272 }
01273
01274
01275
01276 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslatePm(Ptree *p)
01277 {
01278 _saved = visit_pm (downcast<PtreePmExpr*>(p));
01279 return 0;
01280 }
01281
01282
01283
01284 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateCast(Ptree *p)
01285 {
01286 _saved = visit_cast (downcast<PtreeCastExpr*>(p));
01287 return 0;
01288 }
01289
01290
01291
01292 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateUnary(Ptree *p)
01293 {
01294 _saved = visit_unary (downcast<PtreeUnaryExpr*>(p));
01295 return 0;
01296 }
01297
01298
01299
01300 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateThrow(Ptree *p)
01301 {
01302 _saved = visit_throw (downcast<PtreeThrowExpr*>(p));
01303 return 0;
01304 }
01305
01306
01307
01308 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateSizeof(Ptree *p)
01309 {
01310 _saved = visit_sizeof (downcast<PtreeSizeofExpr*>(p));
01311 return 0;
01312 }
01313
01314
01315
01316 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateNew(Ptree *p)
01317 {
01318 _saved = visit_new (downcast<PtreeNewExpr*>(p));
01319 return 0;
01320 }
01321
01322
01323
01324 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateDelete(Ptree *p)
01325 {
01326 _saved = visit_delete (downcast<PtreeDeleteExpr*>(p));
01327 return 0;
01328 }
01329
01330
01331
01332 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateArray(Ptree *p)
01333 {
01334 _saved = visit_array (downcast<PtreeArrayExpr*>(p));
01335 return 0;
01336 }
01337
01338
01339
01340 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateFuncall(Ptree *p)
01341 {
01342 _saved = visit_funcall (downcast<PtreeFuncallExpr*>(p));
01343 return 0;
01344 }
01345
01346
01347
01348 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslatePostfix(Ptree *p)
01349 {
01350 _saved = visit_postfix (downcast<PtreePostfixExpr*>(p));
01351 return 0;
01352 }
01353
01354
01355
01356 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateUserStatement(Ptree *p)
01357 {
01358 _saved = visit_userstatement (downcast<PtreeUserStatementExpr*>(p));
01359 return 0;
01360 }
01361
01362
01363
01364 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateDotMember(Ptree *p)
01365 {
01366 _saved = visit_dotmember (downcast<PtreeDotMemberExpr*>(p));
01367 return 0;
01368 }
01369
01370
01371
01372 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateArrowMember(Ptree *p)
01373 {
01374 _saved = visit_arrowmember (downcast<PtreeArrowMemberExpr*>(p));
01375 return 0;
01376 }
01377
01378
01379
01380 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateParen(Ptree *p)
01381 {
01382 _saved = visit_paren (downcast<PtreeParenExpr*>(p));
01383 return 0;
01384 }
01385
01386
01387
01388 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateStaticUserStatement(Ptree *p)
01389 {
01390 _saved = visit_staticuserstatement (downcast<PtreeStaticUserStatementExpr*>(p));
01391 return 0;
01392 }
01393
01394
01395
01396 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateFstyleCast(Ptree *p)
01397 {
01398 _saved = visit_fstylecastexpr (downcast<PtreeFstyleCastExpr*>(p));
01399 return 0;
01400 }
01401
01402
01403
01404 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateVariable(Ptree *p)
01405 {
01406
01407 _saved = visit_name (p);
01408 return 0;
01409 }
01410
01411
01412
01413 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateThis(Ptree *p)
01414 {
01415 _saved = visit_this (downcast<LeafThis*>(p));
01416 return 0;
01417 }
01418
01419
01420
01421
01422
01423 template <typename Returntype> bool Ptree_visitor<Returntype>::IsClassWalker() { runtime_error(); return 0; }
01424
01425
01426 template <typename Returntype> void Ptree_visitor<Returntype>::TypeofPtree(Ptree *, TypeInfo &) { runtime_error(); }
01427
01428
01429 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateTemplateInstantiation(Ptree *, Ptree *, Ptree *, Class *) { runtime_error(); return 0; }
01430
01431
01432 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateTemplateClass(Ptree *, Ptree *) { runtime_error(); return 0; }
01433
01434
01435 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateTemplateFunction(Ptree *, Ptree *) { runtime_error(); return 0; }
01436
01437
01438 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateStorageSpecifiers(Ptree *) { runtime_error(); return 0; }
01439
01440
01441 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateDeclarators(Ptree *) { runtime_error(); return 0; }
01442
01443
01444 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateDeclarator(bool, PtreeDeclarator *) { runtime_error(); return 0; }
01445
01446
01447 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateArgDeclList(bool, Ptree *, Ptree *) { runtime_error(); return 0; }
01448
01449
01450 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateInitializeArgs(PtreeDeclarator *, Ptree *) { runtime_error(); return 0; }
01451
01452
01453 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateAssignInitializer(PtreeDeclarator *, Ptree *) { runtime_error(); return 0; }
01454
01455
01456 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateFunctionImplementation(Ptree *) { runtime_error(); return 0; }
01457
01458
01459 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::RecordArgsAndTranslateFbody(Class *, Ptree *args, Ptree *body) { runtime_error(); return 0; }
01460
01461
01462 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateFunctionBody(Ptree *) { runtime_error(); return 0; }
01463
01464
01465 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateClassSpec(Ptree *, Ptree *, Ptree *, Class *) { runtime_error(); return 0; }
01466
01467
01468 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateTypespecifier(Ptree *) { runtime_error(); return 0; }
01469
01470
01471 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateNew2(Ptree *, Ptree *, Ptree *, Ptree *, Ptree *, Ptree *, Ptree *) { runtime_error(); return 0; }
01472
01473
01474 template <typename Returntype> Ptree* Ptree_visitor<Returntype>::TranslateNew3(Ptree *type) { runtime_error(); return 0; }
01475
01476
01477
01478
01479 template <typename Returntype> Class* Ptree_visitor<Returntype>::MakeTemplateInstantiationMetaobject(Ptree *full_class_spec, Ptree *userkey, Ptree *class_spec) { runtime_error(); return 0; }
01480
01481
01482 template <typename Returntype> Class* Ptree_visitor<Returntype>::MakeTemplateClassMetaobject(Ptree *, Ptree *, Ptree *) { runtime_error(); return 0; }
01483
01484
01485 template <typename Returntype> Class* Ptree_visitor<Returntype>::MakeClassMetaobject(Ptree *, Ptree *, Ptree *) { runtime_error(); return 0; }
01486
01487
01488
01489
01490 template <typename Returntype> void Ptree_visitor<Returntype>::TypeofComma(Ptree *, TypeInfo &) { runtime_error(); }
01491
01492
01493 template <typename Returntype> void Ptree_visitor<Returntype>::TypeofAssign(Ptree *, TypeInfo &) { runtime_error(); }
01494
01495
01496 template <typename Returntype> void Ptree_visitor<Returntype>::TypeofCond(Ptree *, TypeInfo &) { runtime_error(); }
01497
01498
01499 template <typename Returntype> void Ptree_visitor<Returntype>::TypeofInfix(Ptree *, TypeInfo &) { runtime_error(); }
01500
01501
01502 template <typename Returntype> void Ptree_visitor<Returntype>::TypeofPm(Ptree *, TypeInfo &) { runtime_error(); }
01503
01504
01505 template <typename Returntype> void Ptree_visitor<Returntype>::TypeofCast(Ptree *, TypeInfo &) { runtime_error(); }
01506
01507
01508 template <typename Returntype> void Ptree_visitor<Returntype>::TypeofUnary(Ptree *, TypeInfo &) { runtime_error(); }
01509
01510
01511 template <typename Returntype> void Ptree_visitor<Returntype>::TypeofThrow(Ptree *, TypeInfo &) { runtime_error(); }
01512
01513
01514 template <typename Returntype> void Ptree_visitor<Returntype>::TypeofSizeof(Ptree *, TypeInfo &) { runtime_error(); }
01515
01516
01517 template <typename Returntype> void Ptree_visitor<Returntype>::TypeofNew(Ptree *, TypeInfo &) { runtime_error(); }
01518
01519
01520 template <typename Returntype> void Ptree_visitor<Returntype>::TypeofDelete(Ptree *, TypeInfo &) { runtime_error(); }
01521
01522
01523 template <typename Returntype> void Ptree_visitor<Returntype>::TypeofThis(Ptree *, TypeInfo &) { runtime_error(); }
01524
01525
01526 template <typename Returntype> void Ptree_visitor<Returntype>::TypeofVariable(Ptree *, TypeInfo &) { runtime_error(); }
01527
01528
01529 template <typename Returntype> void Ptree_visitor<Returntype>::TypeofFstyleCast(Ptree *, TypeInfo &) { runtime_error(); }
01530
01531
01532 template <typename Returntype> void Ptree_visitor<Returntype>::TypeofArray(Ptree *, TypeInfo &) { runtime_error(); }
01533
01534
01535 template <typename Returntype> void Ptree_visitor<Returntype>::TypeofFuncall(Ptree *, TypeInfo &) { runtime_error(); }
01536
01537
01538 template <typename Returntype> void Ptree_visitor<Returntype>::TypeofPostfix(Ptree *, TypeInfo &) { runtime_error(); }
01539
01540
01541 template <typename Returntype> void Ptree_visitor<Returntype>::TypeofUserStatement(Ptree *, TypeInfo &) { runtime_error(); }
01542
01543
01544 template <typename Returntype> void Ptree_visitor<Returntype>::TypeofDotMember(Ptree *, TypeInfo &) { runtime_error(); }
01545
01546
01547 template <typename Returntype> void Ptree_visitor<Returntype>::TypeofArrowMember(Ptree *, TypeInfo &) { runtime_error(); }
01548
01549
01550 template <typename Returntype> void Ptree_visitor<Returntype>::TypeofParen(Ptree *, TypeInfo &) { runtime_error(); }
01551
01552
01553 template <typename Returntype> void Ptree_visitor<Returntype>::TypeofStaticUserStatement(Ptree *, TypeInfo &) { runtime_error(); }
01554
01555 #endif // ptree_visitor_h