Changes in src/Parser/ExpressionNode.cc [e04ef3a:630a82a]
- File:
-
- 1 edited
-
src/Parser/ExpressionNode.cc (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/ExpressionNode.cc
re04ef3a r630a82a 10 10 // Created On : Sat May 16 13:17:07 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Jun 13 14:46:17201613 // Update Count : 30712 // Last Modified On : Fri Apr 8 15:43:05 2016 13 // Update Count : 296 14 14 // 15 15 … … 32 32 using namespace std; 33 33 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 ){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 ) { 39 39 if ( other.argName ) { 40 40 argName = other.argName->clone(); … … 344 344 345 345 Expression *DesignatorNode::build() const { 346 Expression * ret = maybeBuild<Expression>(get_argName());346 Expression * ret = get_argName()->build(); 347 347 348 348 if ( isArrayIndex ) { … … 389 389 "Cond", "NCond", 390 390 // diadic 391 "SizeOf", "AlignOf", "OffsetOf", "Attr", " ?+?", "?-?", "?*?", "?/?", "?%?", "||", "&&",391 "SizeOf", "AlignOf", "OffsetOf", "Attr", "CompLit", "?+?", "?-?", "?*?", "?/?", "?%?", "||", "&&", 392 392 "?|?", "?&?", "?^?", "Cast", "?<<?", "?>>?", "?<?", "?>?", "?<=?", "?>=?", "?==?", "?!=?", 393 393 "?=?", "?*=?", "?/=?", "?%=?", "?+=?", "?-=?", "?<<=?", "?>>=?", "?&=?", "?^=?", "?|=?", … … 466 466 467 467 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() )); 469 469 } // if 470 470 … … 550 550 if ( dynamic_cast< VoidType* >( targetType ) ) { 551 551 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() ) ); 553 553 } 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() ) ); 555 555 } // if 556 556 } … … 621 621 assert( var ); 622 622 if ( ! get_args()->get_link() ) { 623 return new AttrExpr( maybeBuild<Expression>(var), ( Expression*)0);623 return new AttrExpr( var->build(), ( Expression*)0); 624 624 } 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()); 626 626 } 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 630 633 case OperatorNode::Or: 631 634 case OperatorNode::And: … … 716 719 717 720 Expression *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() ); 719 722 } 720 723 … … 793 796 794 797 Expression *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() ) ); 796 799 } 797 800 … … 905 908 906 909 Expression *CompoundLiteralNode::build() const { 907 Declaration * newDecl = maybeBuild<Declaration>(type);// compound literal type910 Declaration * newDecl = type->build(); // compound literal type 908 911 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() ); 910 913 // these types do not have associated type information 911 914 } 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() ); 913 916 } 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() ); 915 918 } 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() ); 917 920 } else { 918 921 assert( false );
Note:
See TracChangeset
for help on using the changeset viewer.