Changeset 67cf18c for src/Parser
- Timestamp:
- May 26, 2017, 6:37:49 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 01b9928
- Parents:
- ff03f5c
- git-author:
- Rob Schluntz <rschlunt@…> (05/26/17 18:34:50)
- git-committer:
- Rob Schluntz <rschlunt@…> (05/26/17 18:37:49)
- Location:
- src/Parser
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
rff03f5c r67cf18c 57 57 variable.tyClass = NoTypeClass; 58 58 variable.assertions = nullptr; 59 variable.initializer = nullptr; 59 60 60 61 // attr.name = nullptr; … … 70 71 // delete variable.name; 71 72 delete variable.assertions; 73 delete variable.initializer; 72 74 73 75 delete type; … … 101 103 newnode->variable.tyClass = variable.tyClass; 102 104 newnode->variable.assertions = maybeClone( variable.assertions ); 105 newnode->variable.initializer = maybeClone( variable.initializer ); 103 106 104 107 // newnode->attr.name = attr.name ? new string( *attr.name ) : nullptr; … … 857 860 } 858 861 862 DeclarationNode * DeclarationNode::addTypeInitializer( DeclarationNode * init ) { 863 assertf( variable.tyClass != NoTypeClass, "Called addTypeInitializer on something that isn't a type variable." ); 864 variable.initializer = init; 865 return this; 866 } 867 859 868 DeclarationNode * DeclarationNode::cloneType( string * newName ) { 860 869 DeclarationNode * newnode = new DeclarationNode; … … 1014 1023 assertf( sizeof(kindMap)/sizeof(kindMap[0] == NoTypeClass-1), "DeclarationNode::build: kindMap is out of sync." ); 1015 1024 assertf( variable.tyClass < sizeof(kindMap)/sizeof(kindMap[0]), "Variable's tyClass is out of bounds." ); 1016 TypeDecl * ret = new TypeDecl( *name, Type::StorageClasses(), nullptr, kindMap[ variable.tyClass ] );1025 TypeDecl * ret = new TypeDecl( *name, Type::StorageClasses(), nullptr, kindMap[ variable.tyClass ], variable.initializer ? variable.initializer->buildType() : nullptr ); 1017 1026 buildList( variable.assertions, ret->get_assertions() ); 1018 1027 return ret; -
src/Parser/ParseNode.h
rff03f5c r67cf18c 274 274 DeclarationNode * addIdList( DeclarationNode * list ); // old-style functions 275 275 DeclarationNode * addInitializer( InitializerNode * init ); 276 DeclarationNode * addTypeInitializer( DeclarationNode * init ); 276 277 277 278 DeclarationNode * cloneType( std::string * newName ); … … 301 302 DeclarationNode::TypeClass tyClass; 302 303 DeclarationNode * assertions; 304 DeclarationNode * initializer; 303 305 }; 304 306 Variable_t variable; -
src/Parser/parser.yy
rff03f5c r67cf18c 1606 1606 1607 1607 typegen_name: // CFA 1608 TYPEGENname '(' type_list ')' 1608 TYPEGENname '(' ')' 1609 { $$ = DeclarationNode::newFromTypeGen( $1, nullptr ); } 1610 | TYPEGENname '(' type_list ')' 1609 1611 { $$ = DeclarationNode::newFromTypeGen( $1, $3 ); } 1610 1612 ; … … 1983 1985 1984 1986 type_parameter_list: // CFA 1985 type_parameter type_initializer_opt 1986 | type_parameter_list ',' type_parameter type_initializer_opt 1987 type_parameter 1988 { $$ = $1; } 1989 | type_parameter_list ',' type_parameter 1987 1990 { $$ = $1->appendList( $3 ); } 1988 1991 ; … … 1998 2001 type_class no_attr_identifier_or_type_name 1999 2002 { typedefTable.addToEnclosingScope( *$2, TypedefTable::TD ); } 2000 assertion_list_opt2001 { $$ = DeclarationNode::newTypeParam( $1, $2 )->add Assertions( $4); }2003 type_initializer_opt assertion_list_opt 2004 { $$ = DeclarationNode::newTypeParam( $1, $2 )->addTypeInitializer( $4 )->addAssertions( $5 ); } 2002 2005 | type_specifier identifier_parameter_declarator 2003 2006 ;
Note: See TracChangeset
for help on using the changeset viewer.