AST.hxx

Go to the documentation of this file.
00001 #ifndef AST_HXX
00002 #define AST_HXX
00003 
00004 
00005 /*
00006  * Copyright (C) 2008, The EROS Group, LLC.
00007  * All rights reserved.
00008  *
00009  * Redistribution and use in source and binary forms, with or
00010  * without modification, are permitted provided that the following
00011  * conditions are met:
00012  *
00013  *   - Redistributions of source code must contain the above
00014  *     copyright notice, this list of conditions, and the following
00015  *     disclaimer.
00016  *
00017  *   - Redistributions in binary form must reproduce the above
00018  *     copyright notice, this list of conditions, and the following
00019  *     disclaimer in the documentation and/or other materials
00020  *     provided with the distribution.
00021  *
00022  *   - Neither the names of the copyright holders nor the names of any
00023  *     of any contributors may be used to endorse or promote products
00024  *     derived from this software without specific prior written
00025  *     permission.
00026  *
00027  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00028  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00029  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00030  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00031  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00032  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00033  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00034  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00035  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00036  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00037  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00038  */
00039 
00040 #include <string>
00041 #include <vector>
00042 
00043 
00044 #include <stdint.h>
00045 
00046 #include "libsherpa/EnumSet.hxx"
00047 #include "libsherpa/INOstream.hxx"
00048 
00049 #include "FQName.hxx"
00050 #include "LitValue.hxx"
00051 #include "Environment.hxx"
00052 #include "debug.hxx"
00053 #include "shared_ptr.hxx"
00054 
00055 
00056 #define AST_SMART_PTR boost::shared_ptr
00057 #define AST_SUPERCLASS boost::enable_shared_from_this<AST>
00058 
00059 
00060 
00061 struct Type;
00062 struct TypeScheme;
00063 struct spStruct;
00064 struct UocInfo;
00065 struct Instance;
00066 
00088 
00089 enum IdentType {
00097   id_unresolved,
00098 
00100   id_tvar,
00101 
00103   id_union,
00104 
00106   id_struct,
00107 
00109   id_object,
00110 
00112   id_typeclass,
00113 
00115   id_tcmethod,
00116 
00118   id_field,
00119 
00121   id_method,
00122 
00128   id_interface,
00129 
00132   id_value,
00133 
00135   id_ucon,
00136 
00138   id_ucon0,
00139 
00141   id_block,
00142 
00144   //
00145   // Anything below here is a category that is some union of
00146   // IdentTypes above
00147   //
00148   // The value of idc_FIRST_CATEGORY matches the value of idc_type,
00149   // but we list idc_type first so that debuggers will report the
00150   // value at runtime using that identifier.
00152 
00155   idc_type,
00156 
00157   idc_FIRST_CATEGORY = idc_type,
00158 
00161   idc_value,
00162 
00165   idc_uctor,
00166 
00169   idc_ctor,
00170 
00175   idc_apply,
00176 
00185   idc_usesel_lhs,
00186 };
00187 
00190 std::string identTypeToString(IdentType id);
00191 
00192 
00193 /* Declarations for AST FLAGS */
00194 
00195 enum AstFlagValues {
00196 
00197   // @brief Useful to have an empty set initializer:
00198   NO_FLAGS = 0,
00199 
00201   ID_IS_GLOBAL = 0x00000001u,
00203   ID_IS_GENSYM = 0x00000002u,
00204 
00211   SELF_TAIL = 0x00000004u,
00212 
00239   LB_IS_DUMMY = 0x00000008u,
00240 
00245   LB_POSTPONED = LB_IS_DUMMY,
00246 
00251   ID_IS_PRIVATE = 0x00000010u,
00252 
00255   DEF_IS_ENTRYPT = 0x00000020u,
00256 
00262   LB_REC_BIND = 0x00000040u,
00263 
00271   DEF_IS_EXTERNAL = 0x00000080u,
00272 
00281   ENUM_UN = 0x00000100u,
00282 
00291   SINGLE_LEG_UN = 0x00000200u,
00292 
00295   CARDELLI_UN = 0x00000400u,
00296 
00299   NULLABLE_UN = 0x00000800u,
00300 
00302 
00311   ID_FOR_USWITCH = 0x00001000u,
00312 
00314   ID_IS_CAPTURED = 0x00002000u,
00315 
00320   ID_IS_CLOSED = 0x00004000u,
00321 
00323   ID_NEEDS_HEAPIFY = 0x00008000u,
00324 
00330   ID_IS_MUTATED = 0x00010000u,
00331 
00339   ID_MUT_CLOSED = 0x00020000u,
00340 
00346   PROCLAIM_IS_INTERNAL = 0x00040000u,
00347 
00354   DEF_IS_TRIVIAL_INIT = 0x00080000u,
00355 
00382   IDENT_MANGLED = 0x00100000u,
00383 
00394   LOCAL_NOGEN_VAR = 0x00200000u,
00395 
00407   LBS_PROCESSED = 0x00400000u,
00408 
00410   ID_OBSERV_DEF = 0x00800000u,
00411 
00424   TVAR_POLY_SPECIAL = 0x01000000u,
00425 
00428   UNION_IS_REPR = 0x02000000u,
00429 
00432   FLD_IS_DISCM = 0x04000000u,
00433 
00439   LAM_NEEDS_TRANS = 0x08000000u,
00440 
00452   INNER_REF_NDX = 0x10000000u,
00453 
00471   ARG_BYREF = 0x20000000u,
00472 
00475   MASK_FLAGS_FROM_USE = (DEF_IS_ENTRYPT|ID_IS_CAPTURED)
00476 
00477 } /* AstFlagValues */;
00478 typedef sherpa::EnumSet<AstFlagValues> AstFlags;
00479 
00480 enum PrintFlagValues {
00481   pf_NONE,
00487   pf_IMPLIED,
00488 
00492   pf_PARENWRAP
00493 };
00494 typedef sherpa::EnumSet<PrintFlagValues> PrintFlags;
00495 
00496 enum PrettyPrintFlagValues {
00497   pp_NONE,
00498 
00500   pp_ShowTypes,
00501 
00505   pp_LitValues,
00506 
00510   pp_FinalNewline,
00511 
00515   pp_Raw,
00516 
00521   pp_InLayoutBlock
00522 };
00523 
00524 typedef sherpa::EnumSet<PrettyPrintFlagValues> PrettyPrintFlags;
00525 
00526 struct AST;
00527 
00531 struct EnvSet {
00532   boost::shared_ptr<ASTEnvironment> env;
00533   boost::shared_ptr<TSEnvironment> gamma;
00534   boost::shared_ptr<InstEnvironment> instEnv;
00535 
00536   EnvSet()
00537   {
00538     env = boost::GC_NULL;
00539     gamma = boost::GC_NULL;
00540     instEnv = boost::GC_NULL;
00541   }
00542 
00543   EnvSet(boost::shared_ptr<ASTEnvironment > _env, boost::shared_ptr<TSEnvironment >_gamma,
00544          boost::shared_ptr<InstEnvironment > _instEnv)
00545   {
00546     env = _env;
00547     gamma = _gamma;
00548     instEnv = _instEnv;
00549   }
00550 
00551   EnvSet(EnvSet &envs)
00552   {
00553     env = envs.env;
00554     gamma = envs.gamma;
00555     instEnv = envs.instEnv;
00556   }
00557 
00558   void
00559   updateKey(const std::string from, const std::string to)
00560   {
00561     env->updateKey(from, to);
00562     gamma->updateKey(from, to);
00563   }
00564 
00565   // Quasi-constructors:
00566   static inline boost::shared_ptr<EnvSet>
00567   make()
00568   {
00569     EnvSet *tmp = new EnvSet();
00570     return boost::shared_ptr<EnvSet>(tmp);
00571   }
00572 
00573   static inline boost::shared_ptr<EnvSet>
00574   make(boost::shared_ptr<ASTEnvironment> _env,
00575        boost::shared_ptr<TSEnvironment>_gamma,
00576        boost::shared_ptr<InstEnvironment> _instEnv)
00577   {
00578     EnvSet *tmp = new EnvSet(_env, _gamma, _instEnv);
00579     return boost::shared_ptr<EnvSet>(tmp);
00580   }
00581 
00582   static inline boost::shared_ptr<EnvSet>
00583   make(EnvSet &envs)
00584   {
00585     EnvSet *tmp = new EnvSet(envs);
00586     return boost::shared_ptr<EnvSet>(tmp);
00587   }
00588 };
00589 
00590 
00591 enum AstType {
00592   at_Null,
00593   at_AnyGroup,
00594   at_ident,
00595   at_ifident,
00596   at_usesel,
00597   at_boolLiteral,
00598   at_charLiteral,
00599   at_intLiteral,
00600   at_floatLiteral,
00601   at_stringLiteral,
00602   at_module,
00603   at_interface,
00604   at_defunion,
00605   at_declunion,
00606   at_defstruct,
00607   at_declstruct,
00608   at_defobject,
00609   at_defrepr,
00610   at_declrepr,
00611   at_reprctrs,
00612   at_reprctr,
00613   at_reprrepr,
00614   at_boxedCat,
00615   at_unboxedCat,
00616   at_opaqueCat,
00617   at_oc_closed,
00618   at_oc_open,
00619   at_defexception,
00620   at_deftypeclass,
00621   at_tcdecls,
00622   at_tyfn,
00623   at_tcapp,
00624   at_method_decls,
00625   at_method_decl,
00626   at_qualType,
00627   at_constraints,
00628   at_definstance,
00629   at_tcmethods,
00630   at_tcmethod_binding,
00631   at_proclaim,
00632   at_define,
00633   at_recdef,
00634   at_importAs,
00635   at_provide,
00636   at_import,
00637   at_ifsel,
00638   at_declares,
00639   at_declare,
00640   at_tvlist,
00641   at_constructors,
00642   at_constructor,
00643   at_fields,
00644   at_field,
00645   at_fill,
00646   at_methdecl,
00647   at_bitfieldType,
00648   at_byRefType,
00649   at_arrayRefType,
00650   at_boxedType,
00651   at_unboxedType,
00652   at_fn,
00653   at_methType,
00654   at_primaryType,
00655   at_fnargVec,
00656   at_arrayType,
00657   at_vectorType,
00658   at_mutableType,
00659   at_constType,
00660   at_typeapp,
00661   at_exceptionType,
00662   at_fieldType,
00663   at_dummyType,
00664   at_identPattern,
00665   at_typeAnnotation,
00666   at_mixfix,
00667   at_unit,
00668   at_suspend,
00669   at_sizeof,
00670   at_bitsizeof,
00671   at_MakeVector,
00672   at_vector,
00673   at_array,
00674   at_begin,
00675   at_select,
00676   at_fqCtr,
00677   at_sel_ctr,
00678   at_array_nth,
00679   at_array_ref_nth,
00680   at_vector_nth,
00681   at_nth,
00682   at_lambda,
00683   at_argVec,
00684   at_apply,
00685   at_struct_apply,
00686   at_object_apply,
00687   at_ucon_apply,
00688   at_if,
00689   at_when,
00690   at_unless,
00691   at_and,
00692   at_or,
00693   at_cond,
00694   at_cond_legs,
00695   at_cond_leg,
00696   at_condelse,
00697   at_setbang,
00698   at_deref,
00699   at_dup,
00700   at_inner_ref,
00701   at_allocREF,
00702   at_copyREF,
00703   at_mkClosure,
00704   at_setClosure,
00705   at_mkArrayRef,
00706   at_labeledBlock,
00707   at_return_from,
00708   at_uswitch,
00709   at_usw_legs,
00710   at_usw_leg,
00711   at_otherwise,
00712   at_try,
00713   at_throw,
00714   at_let,
00715   at_letbindings,
00716   at_letbinding,
00717   at_letrec,
00718   at_loop,
00719   at_loopbindings,
00720   at_loopbinding,
00721   at_looptest,
00722   at_localFrame,
00723   at_frameBindings,
00724   at_letStar,
00725   at_identList,
00726   at_container,
00727   at_docString,
00728   at_letGather,
00729   agt_var,
00730   agt_uselhs,
00731   agt_literal,
00732   agt_tvar,
00733   agt_CompilationUnit,
00734   agt_definition,
00735   agt_type_definition,
00736   agt_tc_definition,
00737   agt_value_definition,
00738   agt_if_definition,
00739   agt_category,
00740   agt_openclosed,
00741   agt_fielditem,
00742   agt_qtype,
00743   agt_type,
00744   agt_expr,
00745   agt_expr_or_define,
00746   agt__AnonGroup0,
00747   agt_eform,
00748   agt_ucon,
00749   agt_ow,
00750 };
00751 
00752 enum { at_NUM_ASTTYPE = agt_ow };
00753 
00754 #ifndef AST_SMART_PTR
00755 #include <boost/shared_ptr.hpp>
00756 #include <boost/enable_shared_from_this.hpp>
00757 #define AST_SMART_PTR boost::shared_ptr
00758 #endif /* AST_SMART_PTR */
00759 
00760 #ifndef AST_LOCATION_TYPE
00761 #include <libsherpa/LexLoc.hxx>
00762 #define AST_LOCATION_TYPE sherpa::LexLoc
00763 #endif /* AST_LOCATION_TYPE */
00764 
00765 #ifndef AST_TOKEN_TYPE
00766 #include <libsherpa/LToken.hxx>
00767 #define AST_TOKEN_TYPE sherpa::LToken
00768 #endif /* AST_TOKEN_TYPE */
00769 
00770 #ifndef AST_SUPERCLASS
00771 #define AST_SUPERCLASS boost::enable_shared_from_this<AST>
00772 #endif /* AST_SUPERCLASS */
00773 
00774 class AST :public AST_SUPERCLASS { 
00775   bool isOneOf(AstType);
00776 public:
00777   AstType        astType;
00778   ::std::string    s;
00779   AST_LOCATION_TYPE loc;
00780   ::std::vector<AST_SMART_PTR<AST> > children;
00781 
00782 
00783  private:
00784   static unsigned long long astCount;
00785 
00786  public:
00789   AST_LOCATION_TYPE endLoc() { return loc; }
00790 
00791   unsigned long long ID; // Unique ID of this AST
00792 
00793   LitValue litValue;
00794   unsigned long litBase;
00795 
00796   IdentType identType;
00797   AstFlags flags;
00798 
00799   PrintFlags printVariant;  // which syntax to use for pretty printing
00800 
00801   boost::shared_ptr<TypeScheme> scheme; // defining occurrences only
00802   boost::shared_ptr<Type> symType;      // the (pre-unified) type
00803   boost::shared_ptr<AST> symbolDef;
00804 
00805   bool isDecl;                  // is This a declaration or definition?
00806 
00807   bool isGlobal() { return (flags & ID_IS_GLOBAL); }
00808   bool isFnxn(); // Function
00809   size_t nBits();
00810   bool isLiteral();
00811   bool isTopLevelForm();
00812   bool isIdentType(IdentType idt);
00813   bool leadsToTopLevelForm();
00814   void clearTypes(); // Clear the sumType and scheme fields
00815                      // of this AST and ALL children RECURSIVELY.
00816                      // This needs to be done before re-typing an
00817                      // expression, for example post-clconv
00818                      // otherwise, old types will infulence
00819                      // new type records.
00820 
00824   boost::shared_ptr<AST> defn;
00825 
00828   boost::shared_ptr<AST> decl;
00829 
00837   FQName fqn;
00838 
00841   std::string externalName;
00842 
00848   EnvSet envs;
00849 
00892 
00893   boost::shared_ptr<AST> defForm;
00894 
00898   boost::shared_ptr<AST> defbps;
00899 
00901   boost::shared_ptr<Type> tagType;
00902 
00909   size_t field_bits;
00910 
00915   size_t unin_discm;
00916 
00919   size_t total_fill;
00920 
00923   boost::shared_ptr<TypeScheme> stSigma;
00924 
00933   boost::shared_ptr<AST> stCtr;
00934 
00935   // Tracking scope of type-variables:
00936 
00940   boost::shared_ptr<AST> tvarLB;
00941 
00947   boost::shared_ptr<AST> parentLB;
00948 
00949   static boost::shared_ptr<AST> makeBoolLit(const sherpa::LToken &tok);
00950   static boost::shared_ptr<AST> makeIntLit(const sherpa::LToken &tok);
00951   static boost::shared_ptr<AST> makeStringLit(const sherpa::LToken &tok);
00952   static boost::shared_ptr<AST> makeCharLit(const sherpa::LToken &tok);
00953   static boost::shared_ptr<AST> makeFloatLit(const sherpa::LToken &tok);
00954 
00966   void disown(size_t s);
00967 
00972   static boost::shared_ptr<AST>
00973     genIdent(const char *pfx = "tmp", const bool isTV = false);
00974 
00977   static boost::shared_ptr<AST> genSym(boost::shared_ptr<AST> lhs,
00978                      const char *pfx="tmp",
00979                      const bool isTV = false);
00980 
00987   std::string atKwd() const;
00988   std::string old_atKwd() const;
00989 
00995   void getIds(std::ostream &errStream,
00996               std::vector<boost::shared_ptr<AST> >& ids,
00997               bool getPattern = false);
00998 
01000   boost::shared_ptr<Type> getType();
01002   boost::shared_ptr<const Type> getType() const;
01003 
01006   boost::shared_ptr<AST> getCtr();
01007 
01008 
01011   boost::shared_ptr<AST> Use();
01012 
01015   AST(boost::shared_ptr<AST> ast, bool shallowCopyChildren=true);
01016 
01017   static inline boost::shared_ptr<AST>
01018   make(boost::shared_ptr<AST> ast, bool shallowCopyChildren=true) {
01019     AST *tmp = new AST(ast,shallowCopyChildren);
01020     return boost::shared_ptr<AST>(tmp);
01021   }
01022 
01025   boost::shared_ptr<AST> getTrueCopy();
01026 
01035   boost::shared_ptr<AST> getDeepCopy();
01036 
01043   void rename(boost::shared_ptr<AST> from, std::string newName);
01044 
01047   std::string asString() const;
01048   std::string asString(PrettyPrintFlags flags) const;
01049 
01051   boost::shared_ptr<AST> getID();
01052 
01055   boost::shared_ptr<AST> getInstanceMethod(std::string name);
01056 
01058   bool isUnionLeg();
01060   bool isTcMethod();
01061 
01062   // @brief Return the precedence of this AST node, for use in
01063   // pretty-printing the block syntax.
01064   int precedence() const;
01065 
01069   void PrettyPrint(std::ostream& out,
01070                    PrettyPrintFlags flags = pp_FinalNewline) const;
01071 
01072   void PrettyPrint(sherpa::INOstream& out,
01073                    PrettyPrintFlags flags = pp_FinalNewline) const;
01074 
01075   // For use in GDB:
01076   void PrettyPrint(bool decorated) const;
01077 
01078   AST(const AstType at = at_Null);
01079   // for literals:
01080   AST(const AstType at, const AST_TOKEN_TYPE& tok);
01081   AST(const AstType at, const AST_LOCATION_TYPE &loc);
01082   AST(const AstType at, const AST_LOCATION_TYPE &loc,
01083       AST_SMART_PTR<AST> child1);
01084   AST(const AstType at, const AST_LOCATION_TYPE &loc,
01085       AST_SMART_PTR<AST> child1,
01086       AST_SMART_PTR<AST> child2);
01087   AST(const AstType at, const AST_LOCATION_TYPE &loc,
01088       AST_SMART_PTR<AST> child1,
01089       AST_SMART_PTR<AST> child2,
01090       AST_SMART_PTR<AST> child3);
01091   AST(const AstType at, const AST_LOCATION_TYPE &loc,
01092       AST_SMART_PTR<AST> child1,
01093       AST_SMART_PTR<AST> child2,
01094       AST_SMART_PTR<AST> child3,
01095       AST_SMART_PTR<AST> child4);
01096   AST(const AstType at, const AST_LOCATION_TYPE &loc,
01097       AST_SMART_PTR<AST> child1,
01098       AST_SMART_PTR<AST> child2,
01099       AST_SMART_PTR<AST> child3,
01100       AST_SMART_PTR<AST> child4,
01101       AST_SMART_PTR<AST> child5);
01102   AST(const AstType at, const AST_LOCATION_TYPE &loc,
01103       AST_SMART_PTR<AST> child1,
01104       AST_SMART_PTR<AST> child2,
01105       AST_SMART_PTR<AST> child3,
01106       AST_SMART_PTR<AST> child4,
01107       AST_SMART_PTR<AST> child5,
01108       AST_SMART_PTR<AST> child6);
01109   AST(const AstType at, const AST_LOCATION_TYPE &loc,
01110       AST_SMART_PTR<AST> child1,
01111       AST_SMART_PTR<AST> child2,
01112       AST_SMART_PTR<AST> child3,
01113       AST_SMART_PTR<AST> child4,
01114       AST_SMART_PTR<AST> child5,
01115       AST_SMART_PTR<AST> child6,
01116       AST_SMART_PTR<AST> child7);
01117   AST(const AstType at, const AST_LOCATION_TYPE &loc,
01118       AST_SMART_PTR<AST> child1,
01119       AST_SMART_PTR<AST> child2,
01120       AST_SMART_PTR<AST> child3,
01121       AST_SMART_PTR<AST> child4,
01122       AST_SMART_PTR<AST> child5,
01123       AST_SMART_PTR<AST> child6,
01124       AST_SMART_PTR<AST> child7,
01125       AST_SMART_PTR<AST> child8);
01126   ~AST();
01127 
01128   // Helper quasi-constructors
01129   static inline AST_SMART_PTR<AST>
01130   make(const AstType at = at_Null)
01131   {
01132     AST *ast = new AST(at);
01133     return AST_SMART_PTR<AST>(ast);
01134   }
01135 
01136   static inline AST_SMART_PTR<AST>
01137   make(const AstType at, const AST_TOKEN_TYPE& tok)
01138   {
01139     AST *ast = new AST(at, tok);
01140     return AST_SMART_PTR<AST>(ast);
01141   }
01142 
01143   static inline AST_SMART_PTR<AST>
01144   make(const AstType at, const AST_LOCATION_TYPE &loc)
01145   {
01146     AST *ast = new AST(at, loc);
01147     return AST_SMART_PTR<AST>(ast);
01148   }
01149 
01150   static inline AST_SMART_PTR<AST>
01151   make(const AstType at, const AST_LOCATION_TYPE &loc,
01152        AST_SMART_PTR<AST> child1)
01153   {
01154     AST *ast = new AST(at, loc, child1);
01155     return AST_SMART_PTR<AST>(ast);
01156   }
01157 
01158   static inline AST_SMART_PTR<AST>
01159   make(const AstType at, const AST_LOCATION_TYPE &loc,
01160        const AST_SMART_PTR<AST> child1,
01161        const AST_SMART_PTR<AST> child2)
01162   {
01163     AST *ast = new AST(at, loc, child1, child2);
01164     return AST_SMART_PTR<AST>(ast);
01165   }
01166 
01167   static inline AST_SMART_PTR<AST>
01168   make(const AstType at, const AST_LOCATION_TYPE &loc,
01169        const AST_SMART_PTR<AST> child1,
01170        const AST_SMART_PTR<AST> child2,
01171        const AST_SMART_PTR<AST> child3)
01172   {
01173     AST *ast = new AST(at, loc, child1, child2,
01174                        child3);
01175     return AST_SMART_PTR<AST>(ast);
01176   }
01177 
01178   static inline AST_SMART_PTR<AST>
01179   make(const AstType at, const AST_LOCATION_TYPE &loc,
01180        const AST_SMART_PTR<AST> child1,
01181        const AST_SMART_PTR<AST> child2,
01182        const AST_SMART_PTR<AST> child3,
01183        const AST_SMART_PTR<AST> child4)
01184   {
01185     AST *ast = new AST(at, loc, child1, child2,
01186                        child3, child4);
01187     return AST_SMART_PTR<AST>(ast);
01188   }
01189 
01190   static inline AST_SMART_PTR<AST>
01191   make(const AstType at, const AST_LOCATION_TYPE &loc,
01192        const AST_SMART_PTR<AST> child1,
01193        const AST_SMART_PTR<AST> child2,
01194        const AST_SMART_PTR<AST> child3,
01195        const AST_SMART_PTR<AST> child4,
01196        const AST_SMART_PTR<AST> child5)
01197   {
01198     AST *ast = new AST(at, loc, child1, child2,
01199                        child3, child4, child5);
01200     return AST_SMART_PTR<AST>(ast);
01201   }
01202 
01203   static inline AST_SMART_PTR<AST>
01204   make(const AstType at, const AST_LOCATION_TYPE &loc,
01205        const AST_SMART_PTR<AST> child1,
01206        const AST_SMART_PTR<AST> child2,
01207        const AST_SMART_PTR<AST> child3,
01208        const AST_SMART_PTR<AST> child4,
01209        const AST_SMART_PTR<AST> child5,
01210        const AST_SMART_PTR<AST> child6)
01211   {
01212     AST *ast = new AST(at, loc, child1, child2,
01213                        child3, child4, child5,
01214                        child6);
01215     return AST_SMART_PTR<AST>(ast);
01216   }
01217 
01218   static inline AST_SMART_PTR<AST>
01219   make(const AstType at, const AST_LOCATION_TYPE &loc,
01220        const AST_SMART_PTR<AST> child1,
01221        const AST_SMART_PTR<AST> child2,
01222        const AST_SMART_PTR<AST> child3,
01223        const AST_SMART_PTR<AST> child4,
01224        const AST_SMART_PTR<AST> child5,
01225        const AST_SMART_PTR<AST> child6,
01226        const AST_SMART_PTR<AST> child7)
01227   {
01228     AST *ast = new AST(at, loc, child1, child2,
01229                        child3, child4, child5,
01230                        child6, child7);
01231     return AST_SMART_PTR<AST>(ast);
01232   }
01233 
01234   static inline AST_SMART_PTR<AST>
01235   make(const AstType at, const AST_LOCATION_TYPE &loc,
01236        const AST_SMART_PTR<AST> child1,
01237        const AST_SMART_PTR<AST> child2,
01238        const AST_SMART_PTR<AST> child3,
01239        const AST_SMART_PTR<AST> child4,
01240        const AST_SMART_PTR<AST> child5,
01241        const AST_SMART_PTR<AST> child6,
01242        const AST_SMART_PTR<AST> child7,
01243        const AST_SMART_PTR<AST> child8)
01244   {
01245     AST *ast = new AST(at, loc, child1, child2,
01246                        child3, child4, child5,
01247                        child6, child7, child8);
01248     return AST_SMART_PTR<AST>(ast);
01249   }
01250 
01251 
01252   const AST_SMART_PTR<AST>
01253   child(size_t i) const
01254   {
01255     return children[i];
01256   }
01257 
01258   AST_SMART_PTR<AST>&
01259   child(size_t i)
01260   {
01261     return children[i];
01262   }
01263 
01264   void addChild(AST_SMART_PTR<AST> cld);
01265   ::std::string getTokenString();
01266 
01267   void
01268   addChildrenFrom(AST_SMART_PTR<AST> other)
01269   {
01270     for(size_t i = 0; i < other->children.size(); i++)
01271       addChild(other->child(i));
01272   }
01273 
01274   static const char *tagName(const AstType at);
01275   static const char *nodeName(const AstType at);
01276   static const char *printName(const AstType at);
01277 
01278   inline const char *tagName() const
01279   { return tagName(astType); }
01280 
01281   inline const char *nodeName() const
01282   { return nodeName(astType); }
01283 
01284   inline const char *printName() const
01285   { return printName(astType); }
01286 
01287   bool isMemberOfType(AstType) const;
01288   bool isValid() const;
01289 };
01290 
01291 
01292 #endif /* AST_HXX */

Generated on Sat Feb 4 23:59:28 2012 for BitC Compiler by  doxygen 1.4.7