Changes in src/Parser/ExpressionNode.cc [630a82a:e04ef3a]
- File:
-
- 1 edited
-
src/Parser/ExpressionNode.cc (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/ExpressionNode.cc
r630a82a re04ef3a 10 10 // Created On : Sat May 16 13:17:07 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Apr 8 15:43:05201613 // Update Count : 29612 // Last Modified On : Mon Jun 13 14:46:17 2016 13 // Update Count : 307 14 14 // 15 15 … … 32 32 using namespace std; 33 33 34 ExpressionNode::ExpressionNode() : ParseNode() , argName( 0 ){}35 36 ExpressionNode::ExpressionNode( const string *name ) : ParseNode( name ) , argName( 0 ){}37 38 ExpressionNode::ExpressionNode( const ExpressionNode &other ) : ParseNode( other.name ) {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 ) { 39 39 if ( other.argName ) { 40 40 argName = other.argName->clone(); … … 344 344 345 345 Expression *DesignatorNode::build() const { 346 Expression * ret = get_argName()->build();346 Expression * ret = maybeBuild<Expression>(get_argName()); 347 347 348 348 if ( isArrayIndex ) { … … 389 389 "Cond", "NCond", 390 390 // diadic 391 "SizeOf", "AlignOf", "OffsetOf", "Attr", " CompLit", "?+?", "?-?", "?*?", "?/?", "?%?", "||", "&&",391 "SizeOf", "AlignOf", "OffsetOf", "Attr", "?+?", "?-?", "?*?", "?/?", "?%?", "||", "&&", 392 392 "?|?", "?&?", "?^?", "Cast", "?<<?", "?>>?", "?<?", "?>?", "?<=?", "?>=?", "?==?", "?!=?", 393 393 "?=?", "?*=?", "?/=?", "?%=?", "?+=?", "?-=?", "?<<=?", "?>>=?", "?&=?", "?^=?", "?|=?", … … 466 466 467 467 if ( ! ( op = dynamic_cast<OperatorNode *>( function ) ) ) { // function as opposed to operator 468 return new UntypedExpr( function->build(), args, maybeBuild< Expression >( get_argName() ));468 return new UntypedExpr( maybeBuild<Expression>(function), args, maybeBuild< Expression >( get_argName() )); 469 469 } // if 470 470 … … 550 550 if ( dynamic_cast< VoidType* >( targetType ) ) { 551 551 delete targetType; 552 return new CastExpr( expr_node->build(), maybeBuild< Expression >( get_argName() ) );552 return new CastExpr( maybeBuild<Expression>(expr_node), maybeBuild< Expression >( get_argName() ) ); 553 553 } else { 554 return new CastExpr( expr_node->build(),targetType, maybeBuild< Expression >( get_argName() ) );554 return new CastExpr( maybeBuild<Expression>(expr_node),targetType, maybeBuild< Expression >( get_argName() ) ); 555 555 } // if 556 556 } … … 621 621 assert( var ); 622 622 if ( ! get_args()->get_link() ) { 623 return new AttrExpr( var->build(), ( Expression*)0);623 return new AttrExpr( maybeBuild<Expression>(var), ( Expression*)0); 624 624 } else if ( TypeValueNode * arg = dynamic_cast<TypeValueNode *>( get_args()->get_link()) ) { 625 return new AttrExpr( var->build(), arg->get_decl()->buildType());625 return new AttrExpr( maybeBuild<Expression>(var), arg->get_decl()->buildType()); 626 626 } else { 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 627 return new AttrExpr( maybeBuild<Expression>(var), args.back()); 628 } // if 629 } 633 630 case OperatorNode::Or: 634 631 case OperatorNode::And: … … 719 716 720 717 Expression *AsmExprNode::build() const { 721 return new AsmExpr( maybeBuild< Expression >( inout ), (ConstantExpr *) constraint->build(), operand->build() );718 return new AsmExpr( maybeBuild< Expression >( inout ), (ConstantExpr *)maybeBuild<Expression>(constraint), maybeBuild<Expression>(operand) ); 722 719 } 723 720 … … 796 793 797 794 Expression *ValofExprNode::build() const { 798 return new UntypedValofExpr ( get_body()->build(), maybeBuild< Expression >( get_argName() ) );795 return new UntypedValofExpr ( maybeBuild<Statement>(get_body()), maybeBuild< Expression >( get_argName() ) ); 799 796 } 800 797 … … 908 905 909 906 Expression *CompoundLiteralNode::build() const { 910 Declaration * newDecl = type->build();// compound literal type907 Declaration * newDecl = maybeBuild<Declaration>(type); // compound literal type 911 908 if ( DeclarationWithType * newDeclWithType = dynamic_cast< DeclarationWithType * >( newDecl ) ) { // non-sue compound-literal type 912 return new CompoundLiteralExpr( newDeclWithType->get_type(), kids->build() );909 return new CompoundLiteralExpr( newDeclWithType->get_type(), maybeBuild<Initializer>(kids) ); 913 910 // these types do not have associated type information 914 911 } else if ( StructDecl * newDeclStructDecl = dynamic_cast< StructDecl * >( newDecl ) ) { 915 return new CompoundLiteralExpr( new StructInstType( Type::Qualifiers(), newDeclStructDecl->get_name() ), kids->build() );912 return new CompoundLiteralExpr( new StructInstType( Type::Qualifiers(), newDeclStructDecl->get_name() ), maybeBuild<Initializer>(kids) ); 916 913 } else if ( UnionDecl * newDeclUnionDecl = dynamic_cast< UnionDecl * >( newDecl ) ) { 917 return new CompoundLiteralExpr( new UnionInstType( Type::Qualifiers(), newDeclUnionDecl->get_name() ), kids->build() );914 return new CompoundLiteralExpr( new UnionInstType( Type::Qualifiers(), newDeclUnionDecl->get_name() ), maybeBuild<Initializer>(kids) ); 918 915 } else if ( EnumDecl * newDeclEnumDecl = dynamic_cast< EnumDecl * >( newDecl ) ) { 919 return new CompoundLiteralExpr( new EnumInstType( Type::Qualifiers(), newDeclEnumDecl->get_name() ), kids->build() );916 return new CompoundLiteralExpr( new EnumInstType( Type::Qualifiers(), newDeclEnumDecl->get_name() ), maybeBuild<Initializer>(kids) ); 920 917 } else { 921 918 assert( false );
Note:
See TracChangeset
for help on using the changeset viewer.