Changeset 47498bd for src/Parser
- Timestamp:
- Jun 19, 2018, 2:11:38 PM (6 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, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
- Children:
- 9a7a3b6
- Parents:
- 704d11e
- Location:
- src/Parser
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
r704d11e r47498bd 253 253 return newnode; 254 254 } // DeclarationNode::newFromTypedef 255 256 DeclarationNode * DeclarationNode::newFromGlobalScope() { 257 DeclarationNode * newnode = new DeclarationNode; 258 newnode->type = new TypeData( TypeData::GlobalScope ); 259 return newnode; 260 } 255 261 256 262 DeclarationNode * DeclarationNode::newQualifiedType( DeclarationNode * parent, DeclarationNode * child) { … … 998 1004 try { 999 1005 Declaration * decl = cur->build(); 1000 if ( decl ) {1001 1002 1003 1004 1005 StructInstType * inst = new StructInstType( Type::Qualifiers(), agg->name );1006 auto obj = new ObjectDecl( "", Type::StorageClasses(), linkage, nullptr, inst, nullptr);1007 obj->location = cur->location;1008 * out++ = obj;1009 delete agg;1010 } else if ( UnionDecl * agg = dynamic_cast< UnionDecl * >( decl ) ) {1011 UnionInstType * inst = new UnionInstType( Type::Qualifiers(), agg->name );1012 auto obj = new ObjectDecl( "", Type::StorageClasses(), linkage, nullptr, inst, nullptr);1013 obj->location = cur->location;1014 * out++ = obj;1015 } // if1006 assert( decl ); 1007 if ( DeclarationWithType * dwt = dynamic_cast< DeclarationWithType * >( decl ) ) { 1008 dwt->location = cur->location; 1009 * out++ = dwt; 1010 } else if ( StructDecl * agg = dynamic_cast< StructDecl * >( decl ) ) { 1011 // xxx - this might be where anonymous struct members are added - should be conditional on struct name 1012 StructInstType * inst = new StructInstType( Type::Qualifiers(), agg->name ); 1013 auto obj = new ObjectDecl( "", Type::StorageClasses(), linkage, nullptr, inst, nullptr ); 1014 obj->location = cur->location; 1015 * out++ = obj; 1016 delete agg; 1017 } else if ( UnionDecl * agg = dynamic_cast< UnionDecl * >( decl ) ) { 1018 UnionInstType * inst = new UnionInstType( Type::Qualifiers(), agg->name ); 1019 auto obj = new ObjectDecl( "", Type::StorageClasses(), linkage, nullptr, inst, nullptr ); 1020 obj->location = cur->location; 1021 * out++ = obj; 1016 1022 } // if 1017 1023 } catch( SemanticErrorException &e ) { -
src/Parser/ParseNode.h
r704d11e r47498bd 231 231 static DeclarationNode * newForall( DeclarationNode * ); 232 232 static DeclarationNode * newFromTypedef( const std::string * ); 233 static DeclarationNode * newFromGlobalScope(); 233 234 static DeclarationNode * newQualifiedType( DeclarationNode *, DeclarationNode * ); 234 235 static DeclarationNode * newFunction( const std::string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body ); -
src/Parser/TypeData.cc
r704d11e r47498bd 37 37 case Reference: 38 38 case EnumConstant: 39 case GlobalScope: 39 40 // nothing else to initialize 40 41 break; … … 112 113 case Reference: 113 114 case EnumConstant: 115 case GlobalScope: 114 116 // nothing to destroy 115 117 break; … … 180 182 case Pointer: 181 183 case Reference: 184 case GlobalScope: 182 185 // nothing else to copy 183 186 break; -
src/Parser/TypeData.h
r704d11e r47498bd 27 27 struct TypeData { 28 28 enum Kind { Basic, Pointer, Array, Reference, Function, Aggregate, AggregateInst, Enum, EnumConstant, Symbolic, 29 SymbolicInst, Tuple, Typeof, Builtin, Unknown };29 SymbolicInst, Tuple, Typeof, Builtin, GlobalScope, Unknown }; 30 30 31 31 struct Aggregate_t { … … 88 88 DeclarationNode * forall; 89 89 90 // Basic_t basic;91 90 Aggregate_t aggregate; 92 91 AggInst_t aggInst; 93 92 Array_t array; 94 93 Enumeration_t enumeration; 95 // Variable_t variable;96 94 Function_t function; 97 95 Symbolic_t symbolic; -
src/Parser/parser.yy
r704d11e r47498bd 1792 1792 { $$ = DeclarationNode::newFromTypedef( $1 ); } 1793 1793 | '.' TYPEDEFname 1794 { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; }1794 { $$ = DeclarationNode::newQualifiedType( DeclarationNode::newFromGlobalScope(), DeclarationNode::newFromTypedef( $2 ) ); } 1795 1795 | type_name '.' TYPEDEFname 1796 1796 { $$ = DeclarationNode::newQualifiedType( $1, DeclarationNode::newFromTypedef( $3 ) ); } 1797 1797 | typegen_name 1798 1798 | '.' typegen_name 1799 { SemanticError( yylloc, "Qualified name is currently unimplemented." ); $$ = nullptr; }1799 { $$ = DeclarationNode::newQualifiedType( DeclarationNode::newFromGlobalScope(), $2 ); } 1800 1800 | type_name '.' typegen_name 1801 1801 { $$ = DeclarationNode::newQualifiedType( $1, $3 ); }
Note: See TracChangeset
for help on using the changeset viewer.