Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

walker.h

Go to the documentation of this file.
00001 /*
00002   Copyright (C) 1997-2001 Shigeru Chiba, Tokyo Institute of Technology.
00003 
00004   Permission to use, copy, distribute and modify this software and   
00005   its documentation for any purpose is hereby granted without fee,        
00006   provided that the above copyright notice appear in all copies and that 
00007   both that copyright notice and this permission notice appear in 
00008   supporting documentation.
00009 
00010   Shigeru Chiba makes no representations about the suitability of this 
00011   software for any purpose.  It is provided "as is" without express or
00012   implied warranty.
00013 */
00014 
00015 #ifndef _walker_h
00016 #define _walker_h
00017 
00018 #include "types.h"
00019 
00020 class Environment;
00021 class TypeInfo;
00022 class Class;
00023 class Parser;
00024 class Ptree;
00025 class PtreeDeclarator;
00026 
00027 class Walker : public LightObject {
00028 public:
00029     Walker(Parser*);
00030     Walker(Parser*, Environment*);
00031     Walker(Environment*);
00032     Walker(Walker*);
00033 
00034     Ptree* Translate(Ptree*);
00035     void Typeof(Ptree*, TypeInfo&);
00036 
00037     virtual bool IsClassWalker();
00038 
00039     // default translation
00040     virtual Ptree* TranslatePtree(Ptree*);
00041     virtual void TypeofPtree(Ptree*, TypeInfo&);
00042 
00043     virtual Ptree* TranslateTypedef(Ptree*);
00044     virtual Ptree* TranslateTemplateDecl(Ptree*);
00045     virtual Ptree* TranslateTemplateInstantiation(Ptree*);
00046     virtual Ptree* TranslateTemplateInstantiation(Ptree*, Ptree*,
00047                                                   Ptree*, Class*);
00048     virtual Class* MakeTemplateInstantiationMetaobject(
00049         Ptree* full_class_spec, Ptree* userkey, Ptree* class_spec);
00050     virtual Ptree* TranslateExternTemplate(Ptree*);
00051     virtual Ptree* TranslateTemplateClass(Ptree*, Ptree*);
00052     virtual Class* MakeTemplateClassMetaobject(Ptree*, Ptree*, Ptree*);
00053     virtual Ptree* TranslateTemplateFunction(Ptree*, Ptree*);
00054     virtual Ptree* TranslateMetaclassDecl(Ptree*);
00055     virtual Ptree* TranslateLinkageSpec(Ptree*);
00056     virtual Ptree* TranslateNamespaceSpec(Ptree*);
00057     virtual Ptree* TranslateUsing(Ptree*);
00058     virtual Ptree* TranslateDeclaration(Ptree*);
00059     virtual Ptree* TranslateStorageSpecifiers(Ptree*);
00060     virtual Ptree* TranslateDeclarators(Ptree*);
00061     virtual Ptree* TranslateDeclarator(bool, PtreeDeclarator*);
00062     static bool GetArgDeclList(PtreeDeclarator*, Ptree*&);
00063     virtual Ptree* TranslateArgDeclList(bool, Ptree*, Ptree*);
00064     static Ptree* TranslateArgDeclList2(bool, Environment*, bool, bool, int,
00065                                         Ptree*);
00066     static Ptree* FillArgumentName(Ptree*, Ptree*, int arg_name);
00067     virtual Ptree* TranslateInitializeArgs(PtreeDeclarator*, Ptree*);
00068     virtual Ptree* TranslateAssignInitializer(PtreeDeclarator*, Ptree*);
00069     virtual Ptree* TranslateFunctionImplementation(Ptree*);
00070     virtual Ptree* RecordArgsAndTranslateFbody(Class*, Ptree* args,
00071                                                Ptree* body);
00072     virtual Ptree* TranslateFunctionBody(Ptree*);
00073     virtual Ptree* TranslateBrace(Ptree*);
00074     virtual Ptree* TranslateBlock(Ptree*);
00075     virtual Ptree* TranslateClassBody(Ptree*, Ptree*, Class*);
00076 
00077     virtual Ptree* TranslateClassSpec(Ptree*);
00078     virtual Class* MakeClassMetaobject(Ptree*, Ptree*, Ptree*);
00079     virtual Ptree* TranslateClassSpec(Ptree*, Ptree*, Ptree*, Class*);
00080     virtual Ptree* TranslateEnumSpec(Ptree*);
00081 
00082     virtual Ptree* TranslateAccessSpec(Ptree*);
00083     virtual Ptree* TranslateAccessDecl(Ptree*);
00084     virtual Ptree* TranslateUserAccessSpec(Ptree*);
00085 
00086     virtual Ptree* TranslateIf(Ptree*);
00087     virtual Ptree* TranslateSwitch(Ptree*);
00088     virtual Ptree* TranslateWhile(Ptree*);
00089     virtual Ptree* TranslateDo(Ptree*);
00090     virtual Ptree* TranslateFor(Ptree*);
00091     virtual Ptree* TranslateTry(Ptree*);
00092     virtual Ptree* TranslateBreak(Ptree*);
00093     virtual Ptree* TranslateContinue(Ptree*);
00094     virtual Ptree* TranslateReturn(Ptree*);
00095     virtual Ptree* TranslateGoto(Ptree*);
00096     virtual Ptree* TranslateCase(Ptree*);
00097     virtual Ptree* TranslateDefault(Ptree*);
00098     virtual Ptree* TranslateLabel(Ptree*);
00099     virtual Ptree* TranslateExprStatement(Ptree*);
00100 
00101     virtual Ptree* TranslateTypespecifier(Ptree*);
00102 
00103     virtual Ptree* TranslateComma(Ptree*);
00104     virtual Ptree* TranslateAssign(Ptree*);
00105     virtual Ptree* TranslateCond(Ptree*);
00106     virtual Ptree* TranslateInfix(Ptree*);
00107     virtual Ptree* TranslatePm(Ptree*);
00108     virtual Ptree* TranslateCast(Ptree*);
00109     virtual Ptree* TranslateUnary(Ptree*);
00110     virtual Ptree* TranslateThrow(Ptree*);
00111     virtual Ptree* TranslateSizeof(Ptree*);
00112     virtual Ptree* TranslateNew(Ptree*);
00113     virtual Ptree* TranslateNew2(Ptree*, Ptree*, Ptree*, Ptree*,
00114                                 Ptree*, Ptree*, Ptree*);
00115     virtual Ptree* TranslateNew3(Ptree* type);
00116     virtual Ptree* TranslateDelete(Ptree*);
00117     virtual Ptree* TranslateThis(Ptree*);
00118     virtual Ptree* TranslateVariable(Ptree*);
00119     virtual Ptree* TranslateFstyleCast(Ptree*);
00120     virtual Ptree* TranslateArray(Ptree*);
00121     virtual Ptree* TranslateFuncall(Ptree*);    // and fstyle cast
00122     virtual Ptree* TranslatePostfix(Ptree*);
00123     virtual Ptree* TranslateUserStatement(Ptree*);
00124     virtual Ptree* TranslateDotMember(Ptree*);
00125     virtual Ptree* TranslateArrowMember(Ptree*);
00126     virtual Ptree* TranslateParen(Ptree*);
00127     virtual Ptree* TranslateStaticUserStatement(Ptree*);
00128 
00129     virtual void TypeofComma(Ptree*, TypeInfo&);
00130     virtual void TypeofAssign(Ptree*, TypeInfo&);
00131     virtual void TypeofCond(Ptree*, TypeInfo&);
00132     virtual void TypeofInfix(Ptree*, TypeInfo&);
00133     virtual void TypeofPm(Ptree*, TypeInfo&);
00134     virtual void TypeofCast(Ptree*, TypeInfo&);
00135     virtual void TypeofUnary(Ptree*, TypeInfo&);
00136     virtual void TypeofThrow(Ptree*, TypeInfo&);
00137     virtual void TypeofSizeof(Ptree*, TypeInfo&);
00138     virtual void TypeofNew(Ptree*, TypeInfo&);
00139     virtual void TypeofDelete(Ptree*, TypeInfo&);
00140     virtual void TypeofThis(Ptree*, TypeInfo&);
00141     virtual void TypeofVariable(Ptree*, TypeInfo&);
00142     virtual void TypeofFstyleCast(Ptree*, TypeInfo&);
00143     virtual void TypeofArray(Ptree*, TypeInfo&);
00144     virtual void TypeofFuncall(Ptree*, TypeInfo&);      // and fstyle cast
00145     virtual void TypeofPostfix(Ptree*, TypeInfo&);
00146     virtual void TypeofUserStatement(Ptree*, TypeInfo&);
00147     virtual void TypeofDotMember(Ptree*, TypeInfo&);
00148     virtual void TypeofArrowMember(Ptree*, TypeInfo&);
00149     virtual void TypeofParen(Ptree*, TypeInfo&);
00150     virtual void TypeofStaticUserStatement(Ptree*, TypeInfo&);
00151 
00152 public:
00153     struct NameScope {
00154         Environment* env;
00155         Walker* walker;
00156     };
00157 
00158     void NewScope();
00159     void NewScope(Environment*);
00160     void NewScope(Class*);
00161     Environment* ExitScope();
00162     void RecordBaseclassEnv(Ptree*);
00163     NameScope ChangeScope(Environment*);
00164     void RestoreScope(NameScope&);
00165 
00166 protected:
00167     Ptree* TranslateDeclarators(Ptree*, bool);
00168     Class* LookupMetaclass(Ptree*, Ptree*, Ptree*, bool);
00169 
00170 private:
00171     Class* LookupBaseMetaclass(Ptree*, Ptree*, bool);
00172 
00173 public:
00174     Ptree* TranslateNewDeclarator(Ptree* decl);
00175     Ptree* TranslateNewDeclarator2(Ptree* decl);
00176     Ptree* TranslateArguments(Ptree*);
00177     static Ptree* GetClassOrEnumSpec(Ptree*);
00178     static Ptree* GetClassTemplateSpec(Ptree*);
00179     static Ptree* StripCvFromIntegralType(Ptree*);
00180     static void SetDeclaratorComments(Ptree*, Ptree*);
00181     static Ptree* NthDeclarator(Ptree*, int&);
00182     static Ptree* FindDeclarator(Ptree*, char*, int, char*, int&,
00183                                  Environment*);
00184     static bool MatchedDeclarator(Ptree*, char*, int, char*, Environment*);
00185     static bool WhichDeclarator(Ptree*, Ptree*, int&, Environment*);
00186 
00187     void ErrorMessage(char*, Ptree*, Ptree*);
00188     void WarningMessage(char*, Ptree*, Ptree*);
00189 
00190     static void InaccurateErrorMessage(char*, Ptree*, Ptree*);
00191     static void InaccurateWarningMessage(char*, Ptree*, Ptree*);
00192 
00193     static void ChangeDefaultMetaclass(char*);
00194 
00195 public:
00196     Parser* GetParser() { return parser; }
00197 
00198 protected:
00199     Environment* env;
00200     Parser* parser;
00201 
00202 public:
00203     static char* argument_name;
00204 
00205 private:
00206     static Parser* default_parser;
00207     static char* default_metaclass;
00208 };
00209 
00210 #endif /* _walker_h */

Generated on Mon Feb 10 17:33:01 2003 for VFiasco Semantics Compiler by doxygen1.2.15