Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/ExpressionNode.cc

    re04ef3a r630a82a  
    1010// Created On       : Sat May 16 13:17:07 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jun 13 14:46:17 2016
    13 // Update Count     : 307
     12// Last Modified On : Fri Apr  8 15:43:05 2016
     13// Update Count     : 296
    1414//
    1515
     
    3232using namespace std;
    3333
    34 ExpressionNode::ExpressionNode() : ParseNode() {}
    35 
    36 ExpressionNode::ExpressionNode( const string *name ) : ParseNode( name ) {}
    37 
    38 ExpressionNode::ExpressionNode( const ExpressionNode &other ) : ParseNode( other.name ), extension( other.extension ) {
     34ExpressionNode::ExpressionNode() : ParseNode(), argName( 0 ) {}
     35
     36ExpressionNode::ExpressionNode( const string *name ) : ParseNode( name ), argName( 0 ) {}
     37
     38ExpressionNode::ExpressionNode( const ExpressionNode &other ) : ParseNode( other.name ) {
    3939        if ( other.argName ) {
    4040                argName = other.argName->clone();
     
    344344
    345345Expression *DesignatorNode::build() const {
    346         Expression * ret = maybeBuild<Expression>(get_argName());
     346        Expression * ret = get_argName()->build();
    347347
    348348        if ( isArrayIndex ) {
     
    389389        "Cond", "NCond",
    390390        // diadic
    391         "SizeOf", "AlignOf", "OffsetOf", "Attr", "?+?", "?-?", "?*?", "?/?", "?%?", "||", "&&",
     391        "SizeOf", "AlignOf", "OffsetOf", "Attr", "CompLit", "?+?", "?-?", "?*?", "?/?", "?%?", "||", "&&",
    392392        "?|?", "?&?", "?^?", "Cast", "?<<?", "?>>?", "?<?", "?>?", "?<=?", "?>=?", "?==?", "?!=?",
    393393        "?=?", "?*=?", "?/=?", "?%=?", "?+=?", "?-=?", "?<<=?", "?>>=?", "?&=?", "?^=?", "?|=?",
     
    466466
    467467        if ( ! ( op = dynamic_cast<OperatorNode *>( function ) ) ) { // function as opposed to operator
    468                 return new UntypedExpr( maybeBuild<Expression>(function), args, maybeBuild< Expression >( get_argName() ));
     468                return new UntypedExpr( function->build(), args, maybeBuild< Expression >( get_argName() ));
    469469        } // if
    470470
     
    550550                        if ( dynamic_cast< VoidType* >( targetType ) ) {
    551551                                delete targetType;
    552                                 return new CastExpr( maybeBuild<Expression>(expr_node), maybeBuild< Expression >( get_argName() ) );
     552                                return new CastExpr( expr_node->build(), maybeBuild< Expression >( get_argName() ) );
    553553                        } else {
    554                                 return new CastExpr( maybeBuild<Expression>(expr_node),targetType, maybeBuild< Expression >( get_argName() ) );
     554                                return new CastExpr( expr_node->build(),targetType, maybeBuild< Expression >( get_argName() ) );
    555555                        } // if
    556556                }
     
    621621                        assert( var );
    622622                        if ( ! get_args()->get_link() ) {
    623                                 return new AttrExpr( maybeBuild<Expression>(var), ( Expression*)0);
     623                                return new AttrExpr( var->build(), ( Expression*)0);
    624624                        } else if ( TypeValueNode * arg = dynamic_cast<TypeValueNode *>( get_args()->get_link()) ) {
    625                                 return new AttrExpr( maybeBuild<Expression>(var), arg->get_decl()->buildType());
     625                                return new AttrExpr( var->build(), arg->get_decl()->buildType());
    626626                        } else {
    627                                 return new AttrExpr( maybeBuild<Expression>(var), args.back());
    628                         } // if
    629                 }
     627                                return new AttrExpr( var->build(), args.back());
     628                        } // if
     629                }
     630          case OperatorNode::CompLit:
     631                throw UnimplementedError( "C99 compound literals" );
     632                // the short-circuited operators
    630633          case OperatorNode::Or:
    631634          case OperatorNode::And:
     
    716719
    717720Expression *AsmExprNode::build() const {
    718         return new AsmExpr( maybeBuild< Expression >( inout ), (ConstantExpr *)maybeBuild<Expression>(constraint), maybeBuild<Expression>(operand) );
     721        return new AsmExpr( maybeBuild< Expression >( inout ), (ConstantExpr *)constraint->build(), operand->build() );
    719722}
    720723
     
    793796
    794797Expression *ValofExprNode::build() const {
    795         return new UntypedValofExpr ( maybeBuild<Statement>(get_body()), maybeBuild< Expression >( get_argName() ) );
     798        return new UntypedValofExpr ( get_body()->build(), maybeBuild< Expression >( get_argName() ) );
    796799}
    797800
     
    905908
    906909Expression *CompoundLiteralNode::build() const {
    907         Declaration * newDecl = maybeBuild<Declaration>(type); // compound literal type
     910        Declaration * newDecl = type->build();                          // compound literal type
    908911        if ( DeclarationWithType * newDeclWithType = dynamic_cast< DeclarationWithType * >( newDecl ) ) { // non-sue compound-literal type
    909                 return new CompoundLiteralExpr( newDeclWithType->get_type(), maybeBuild<Initializer>(kids) );
     912                return new CompoundLiteralExpr( newDeclWithType->get_type(), kids->build() );
    910913        // these types do not have associated type information
    911914        } else if ( StructDecl * newDeclStructDecl = dynamic_cast< StructDecl * >( newDecl )  ) {
    912                 return new CompoundLiteralExpr( new StructInstType( Type::Qualifiers(), newDeclStructDecl->get_name() ), maybeBuild<Initializer>(kids) );
     915                return new CompoundLiteralExpr( new StructInstType( Type::Qualifiers(), newDeclStructDecl->get_name() ), kids->build() );
    913916        } else if ( UnionDecl * newDeclUnionDecl = dynamic_cast< UnionDecl * >( newDecl )  ) {
    914                 return new CompoundLiteralExpr( new UnionInstType( Type::Qualifiers(), newDeclUnionDecl->get_name() ), maybeBuild<Initializer>(kids) );
     917                return new CompoundLiteralExpr( new UnionInstType( Type::Qualifiers(), newDeclUnionDecl->get_name() ), kids->build() );
    915918        } else if ( EnumDecl * newDeclEnumDecl = dynamic_cast< EnumDecl * >( newDecl )  ) {
    916                 return new CompoundLiteralExpr( new EnumInstType( Type::Qualifiers(), newDeclEnumDecl->get_name() ), maybeBuild<Initializer>(kids) );
     919                return new CompoundLiteralExpr( new EnumInstType( Type::Qualifiers(), newDeclEnumDecl->get_name() ), kids->build() );
    917920        } else {
    918921                assert( false );
Note: See TracChangeset for help on using the changeset viewer.