Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/ParseNode.h

    r630a82a r7305915  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // ParseNode.h -- 
     7// ParseNode.h --
    88//
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Sat May 16 13:28:16 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Apr  8 16:27:20 2016
    13 // Update Count     : 205
     12// Last Modified On : Mon Jun 27 23:28:10 2016
     13// Update Count     : 242
    1414//
    1515
     
    2020#include <list>
    2121#include <iterator>
     22#include <memory>
    2223
    2324#include "Common/utility.h"
    2425#include "Parser/LinkageSpec.h"
    2526#include "SynTree/Type.h"
     27#include "SynTree/Expression.h"
    2628//#include "SynTree/Declaration.h"
    2729#include "Common/UniqueName.h"
     
    7981        ExpressionNode *set_argName( const std::string *aName );
    8082        ExpressionNode *set_argName( ExpressionNode *aDesignator );
     83        bool get_extension() const { return extension; }
     84        ExpressionNode *set_extension( bool exten ) { extension = exten; return this; }
    8185
    8286        virtual void print( std::ostream &, int indent = 0) const = 0;
     
    8791        void printDesignation ( std::ostream &, int indent = 0) const;
    8892  private:
    89         ExpressionNode *argName;
     93        ExpressionNode *argName = 0;
     94        bool extension = false;
     95};
     96
     97template< typename T >
     98struct maybeBuild_t<Expression, T> {
     99        static inline Expression * doit( const T *orig ) {
     100                if ( orig ) {
     101                        Expression *p = orig->build();
     102                        p->set_extension( orig->get_extension() );
     103                        return p;
     104                } else {
     105                        return 0;
     106                } // if
     107        }
    90108};
    91109
     
    108126
    109127        ConstantNode( Type, std::string * );
    110         ConstantNode( const ConstantNode &other ) : value( *new std::string( other.value ) ) {};
     128        ConstantNode( const ConstantNode &other ) : type( other.type ), btype( other.btype), value( *new std::string( other.value ) ) {};
    111129        ~ConstantNode() { delete &value; }
    112130
     
    177195        enum Type { TupleC, Comma, TupleFieldSel, // n-adic
    178196                                // triadic
    179                                 Cond, NCond, 
     197                                Cond, NCond,
    180198                                // diadic
    181                                 SizeOf, AlignOf, OffsetOf, Attr, CompLit, Plus, Minus, Mul, Div, Mod, Or, And,
    182                                 BitOr, BitAnd, Xor, Cast, LShift, RShift, LThan, GThan, LEThan, GEThan, Eq, Neq, 
     199                                SizeOf, AlignOf, OffsetOf, Attr, Plus, Minus, Mul, Div, Mod, Or, And,
     200                                BitOr, BitAnd, Xor, Cast, LShift, RShift, LThan, GThan, LEThan, GEThan, Eq, Neq,
    183201                                Assign, MulAssn, DivAssn, ModAssn, PlusAssn, MinusAssn, LSAssn, RSAssn, AndAssn, ERAssn, OrAssn,
    184202                                Index, FieldSel, PFieldSel, Range,
    185203                                // monadic
    186204                                UnPlus, UnMinus, AddressOf, PointTo, Neg, BitNeg, Incr, IncrPost, Decr, DecrPost, LabelAddress,
     205                                Ctor, Dtor,
    187206        };
    188207
     
    309328        ValofExprNode( const ValofExprNode &other );
    310329        ~ValofExprNode();
    311  
     330
    312331        virtual ValofExprNode *clone() const { return new ValofExprNode( *this ); }
    313332
     
    333352        enum BuiltinType { Valist };
    334353
    335         static const char *storageName[]; 
     354        static const char *storageName[];
    336355        static const char *qualifierName[];
    337356        static const char *basicTypeName[];
     
    406425        ExpressionNode *get_enumeratorValue() const { return enumeratorValue; }
    407426
     427        bool get_extension() const { return extension; }
     428        DeclarationNode *set_extension( bool exten ) { extension = exten; return this; }
     429
    408430        DeclarationNode();
    409431        ~DeclarationNode();
     
    421443        bool hasEllipsis;
    422444        LinkageSpec::Type linkage;
     445        bool extension = false;
    423446
    424447        static UniqueName anonymous;
     
    427450class StatementNode : public ParseNode {
    428451  public:
    429         enum Type { Exp,   If,        Switch,  Case,    Default,  Choose,   Fallthru, 
     452        enum Type { Exp,   If,        Switch,  Case,    Default,  Choose,   Fallthru,
    430453                                While, Do,        For,
    431454                                Goto,  Continue,  Break,   Return,  Throw,
     
    457480        void addDeclaration( DeclarationNode *newDecl ) { decl = newDecl; }
    458481        void setCatchRest( bool newVal ) { isCatchRest = newVal; }
     482
     483        bool get_extension() const { return extension; }
     484        StatementNode *set_extension( bool exten ) { extension = exten; return this; }
    459485
    460486        std::string get_target() const;
     
    476502        DeclarationNode *decl;
    477503        bool isCatchRest;
     504        bool extension = false;
    478505}; // StatementNode
    479506
     
    525552        ExpressionNode *get_designators() const { return designator; }
    526553
     554        InitializerNode *set_maybeConstructed( bool value ) { maybeConstructed = value; return this; }
     555        bool get_maybeConstructed() const { return maybeConstructed; }
     556
    527557        InitializerNode *next_init() const { return kids; }
    528558
     
    536566        ExpressionNode *designator; // may be list
    537567        InitializerNode *kids;
     568        bool maybeConstructed;
    538569};
    539570
     
    569600        while ( cur ) {
    570601                try {
    571                         SynTreeType *result = dynamic_cast< SynTreeType *>( cur->build() );
     602//                      SynTreeType *result = dynamic_cast< SynTreeType *>( maybeBuild<typename std::result_of<decltype(&NodeType::build)(NodeType)>::type>( cur ) );
     603                        SynTreeType *result = dynamic_cast< SynTreeType *>( maybeBuild<typename std::pointer_traits<decltype(cur->build())>::element_type>( cur ) );
    572604                        if ( result ) {
    573605                                *out++ = result;
Note: See TracChangeset for help on using the changeset viewer.