Changeset 630a82a for src/Parser/ExpressionNode.cc
- Timestamp:
- Apr 8, 2016, 5:22:29 PM (9 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
- Children:
- 3da470c
- Parents:
- 3d9b5da
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/ExpressionNode.cc
r3d9b5da r630a82a 10 10 // Created On : Sat May 16 13:17:07 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Mar 13 12:34:38201613 // Update Count : 2 7212 // Last Modified On : Fri Apr 8 15:43:05 2016 13 // Update Count : 296 14 14 // 15 15 … … 22 22 23 23 #include "ParseNode.h" 24 #include "TypeData.h" 24 25 #include "SynTree/Constant.h" 25 26 #include "SynTree/Expression.h" 27 #include "SynTree/Declaration.h" 26 28 #include "Common/UnimplementedError.h" 27 29 #include "parseutility.h" … … 872 874 } 873 875 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 type 911 if ( DeclarationWithType * newDeclWithType = dynamic_cast< DeclarationWithType * >( newDecl ) ) { // non-sue compound-literal type 912 return new CompoundLiteralExpr( newDeclWithType->get_type(), kids->build() ); 913 // these types do not have associated type information 914 } 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 } // if 923 } 924 925 874 926 ExpressionNode *flattenCommas( ExpressionNode *list ) { 875 927 if ( CompositeExprNode *composite = dynamic_cast< CompositeExprNode * >( list ) ) {
Note: See TracChangeset
for help on using the changeset viewer.