Changes in src/Parser/ExpressionNode.cc [630a82a:2a4b088]
- File:
-
- 1 edited
-
src/Parser/ExpressionNode.cc (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/ExpressionNode.cc
r630a82a r2a4b088 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 : 2 9612 // Last Modified On : Mon Feb 1 13:32:30 2016 13 // Update Count : 271 14 14 // 15 15 … … 22 22 23 23 #include "ParseNode.h" 24 #include "TypeData.h"25 24 #include "SynTree/Constant.h" 26 25 #include "SynTree/Expression.h" 27 #include "SynTree/Declaration.h"28 26 #include "Common/UnimplementedError.h" 29 27 #include "parseutility.h" … … 489 487 args.front() = new AddressExpr( args.front() ); 490 488 break; 491 default: // do nothing 489 default: 490 /* do nothing */ 492 491 ; 493 } // switch492 } 494 493 495 494 switch ( op->get_type() ) { … … 874 873 } 875 874 876 877 CompoundLiteralNode::CompoundLiteralNode( DeclarationNode *type, InitializerNode *kids ) : type( type ), kids( kids ) {}878 CompoundLiteralNode::CompoundLiteralNode( const CompoundLiteralNode &other ) : ExpressionNode( other ), type( other.type ), kids( other.kids ) {}879 880 CompoundLiteralNode::~CompoundLiteralNode() {881 delete kids;882 delete type;883 }884 885 CompoundLiteralNode *CompoundLiteralNode::clone() const {886 return new CompoundLiteralNode( *this );887 }888 889 void CompoundLiteralNode::print( std::ostream &os, int indent ) const {890 os << string( indent,' ' ) << "CompoundLiteralNode:" << endl;891 892 os << string( indent + 2, ' ' ) << "type:" << endl;893 if ( type != 0 )894 type->print( os, indent + 4 );895 896 os << string( indent + 2, ' ' ) << "initialization:" << endl;897 if ( kids != 0 )898 kids->printList( os, indent + 4 );899 }900 901 void CompoundLiteralNode::printOneLine( std::ostream &os, int indent ) const {902 os << "( ";903 if ( type ) type->print( os );904 os << ", ";905 if ( kids ) kids->printOneLine( os );906 os << ") ";907 }908 909 Expression *CompoundLiteralNode::build() const {910 Declaration * newDecl = type->build(); // compound literal type911 if ( DeclarationWithType * newDeclWithType = dynamic_cast< DeclarationWithType * >( newDecl ) ) { // non-sue compound-literal type912 return new CompoundLiteralExpr( newDeclWithType->get_type(), kids->build() );913 // these types do not have associated type information914 } else if ( StructDecl * newDeclStructDecl = dynamic_cast< StructDecl * >( newDecl ) ) {915 return new CompoundLiteralExpr( new StructInstType( Type::Qualifiers(), newDeclStructDecl->get_name() ), kids->build() );916 } else if ( UnionDecl * newDeclUnionDecl = dynamic_cast< UnionDecl * >( newDecl ) ) {917 return new CompoundLiteralExpr( new UnionInstType( Type::Qualifiers(), newDeclUnionDecl->get_name() ), kids->build() );918 } else if ( EnumDecl * newDeclEnumDecl = dynamic_cast< EnumDecl * >( newDecl ) ) {919 return new CompoundLiteralExpr( new EnumInstType( Type::Qualifiers(), newDeclEnumDecl->get_name() ), kids->build() );920 } else {921 assert( false );922 } // if923 }924 925 926 875 ExpressionNode *flattenCommas( ExpressionNode *list ) { 927 876 if ( CompositeExprNode *composite = dynamic_cast< CompositeExprNode * >( list ) ) {
Note:
See TracChangeset
for help on using the changeset viewer.