Changeset ddfd945 for src/Parser
- Timestamp:
- Mar 16, 2017, 8:47:36 AM (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:
- fb04321
- Parents:
- 26ba208
- Location:
- src/Parser
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
r26ba208 rddfd945 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Mar 16 0 7:59:40201713 // Update Count : 100 312 // Last Modified On : Thu Mar 16 08:37:57 2017 13 // Update Count : 1006 14 14 // 15 15 … … 33 33 34 34 // These must remain in the same order as the corresponding DeclarationNode enumerations. 35 const char * DeclarationNode::FuncSpecifiers::Names[] = { "inline", "fortran", "_Noreturn", "NoFunctionSpecifierNames" };36 35 const char * DeclarationNode::basicTypeNames[] = { "void", "_Bool", "char", "int", "float", "double", "long double", "NoBasicTypeNames" }; 37 36 const char * DeclarationNode::complexTypeNames[] = { "_Complex", "_Imaginary", "NoComplexTypeNames" }; … … 186 185 } // DeclarationNode::newStorageClass 187 186 188 DeclarationNode * DeclarationNode::newFuncSpecifier( FuncSpecifiers fs ) {187 DeclarationNode * DeclarationNode::newFuncSpecifier( Type::FuncSpecifiers fs ) { 189 188 DeclarationNode * newnode = new DeclarationNode; 190 189 newnode->funcSpecs = fs; … … 448 447 void DeclarationNode::checkSpecifiers( DeclarationNode * src ) { 449 448 if ( (funcSpecs.val & src->funcSpecs.val) != 0 ) { // duplicates ? 450 for ( unsigned int i = 0; i < NumFuncSpecifier; i += 1 ) { // find duplicates449 for ( unsigned int i = 0; i < Type::NumFuncSpecifier; i += 1 ) { // find duplicates 451 450 if ( funcSpecs[i] && src->funcSpecs[i] ) { 452 appendError( error, string( "duplicate " ) + FuncSpecifiers::Names[i] );451 appendError( error, string( "duplicate " ) + Type::FuncSpecifiers::Names[i] ); 453 452 } // if 454 453 } // for -
src/Parser/ParseNode.h
r26ba208 rddfd945 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Mar 16 0 7:46:33 201713 // Update Count : 77 212 // Last Modified On : Thu Mar 16 08:32:43 2017 13 // Update Count : 776 14 14 // 15 15 … … 201 201 class DeclarationNode : public ParseNode { 202 202 public: 203 enum { Inline = 1 << 0, Noreturn = 1 << 1, Fortran = 1 << 2, NumFuncSpecifier = 3 };204 union FuncSpecifiers {205 static const char * Names[];206 unsigned int val;207 struct {208 bool is_inline : 1;209 bool is_noreturn : 1;210 bool is_fortran : 1;211 };212 FuncSpecifiers() : val( 0 ) {}213 FuncSpecifiers( unsigned int val ) : val( val ) {}214 bool operator[]( unsigned int i ) const { return val & (1 << i); }215 bool any() const { return val != 0; }216 void print( std::ostream & os ) const {217 if ( (*this).any() ) { // any function specifiers ?218 for ( unsigned int i = 0; i < NumFuncSpecifier; i += 1 ) {219 if ( (*this)[i] ) {220 os << FuncSpecifiers::Names[i] << ' ';221 } // if222 } // for223 } // if224 }225 }; // FuncSpecifiers226 227 203 enum BasicType { Void, Bool, Char, Int, Float, Double, LongDouble, NoBasicType }; 228 204 enum ComplexType { Complex, Imaginary, NoComplexType }; … … 242 218 243 219 static DeclarationNode * newStorageClass( Type::StorageClasses ); 244 static DeclarationNode * newFuncSpecifier( FuncSpecifiers );220 static DeclarationNode * newFuncSpecifier( Type::FuncSpecifiers ); 245 221 static DeclarationNode * newTypeQualifier( Type::Qualifiers ); 246 222 static DeclarationNode * newBasicType( BasicType ); … … 339 315 TypeData * type; 340 316 317 Type::FuncSpecifiers funcSpecs; 341 318 Type::StorageClasses storageClasses; 342 FuncSpecifiers funcSpecs;343 319 344 320 ExpressionNode * bitfieldWidth; -
src/Parser/TypeData.cc
r26ba208 rddfd945 10 10 // Created On : Sat May 16 15:12:51 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Mar 16 0 7:54:50201713 // Update Count : 55 812 // Last Modified On : Thu Mar 16 08:32:42 2017 13 // Update Count : 559 14 14 // 15 15 … … 778 778 } // buildTypeof 779 779 780 Declaration * buildDecl( const TypeData * td, const string &name, Type::StorageClasses scs, Expression * bitfieldWidth, DeclarationNode::FuncSpecifiers funcSpec, LinkageSpec::Spec linkage, ConstantExpr *asmName, Initializer * init, std::list< Attribute * > attributes ) {780 Declaration * buildDecl( const TypeData * td, const string &name, Type::StorageClasses scs, Expression * bitfieldWidth, Type::FuncSpecifiers funcSpec, LinkageSpec::Spec linkage, ConstantExpr *asmName, Initializer * init, std::list< Attribute * > attributes ) { 781 781 if ( td->kind == TypeData::Function ) { 782 782 if ( td->function.idList ) { // KR function ? … … 814 814 break; 815 815 default: 816 ft->get_returnVals().push_back( dynamic_cast< DeclarationWithType * >( buildDecl( td->base, "", Type::StorageClasses(), nullptr, DeclarationNode::FuncSpecifiers(), LinkageSpec::Cforall, nullptr ) ) );816 ft->get_returnVals().push_back( dynamic_cast< DeclarationWithType * >( buildDecl( td->base, "", Type::StorageClasses(), nullptr, Type::FuncSpecifiers(), LinkageSpec::Cforall, nullptr ) ) ); 817 817 } // switch 818 818 } else { -
src/Parser/TypeData.h
r26ba208 rddfd945 10 10 // Created On : Sat May 16 15:18:36 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Mar 16 0 7:53:41201713 // Update Count : 18 412 // Last Modified On : Thu Mar 16 08:32:39 2017 13 // Update Count : 185 14 14 // 15 15 … … 109 109 TupleType * buildTuple( const TypeData * ); 110 110 TypeofType * buildTypeof( const TypeData * ); 111 Declaration * buildDecl( const TypeData *, const std::string &, Type::StorageClasses, Expression *, DeclarationNode::FuncSpecifiers funcSpec, LinkageSpec::Spec, ConstantExpr *asmName, Initializer * init = nullptr, std::list< class Attribute * > attributes = std::list< class Attribute * >() );111 Declaration * buildDecl( const TypeData *, const std::string &, Type::StorageClasses, Expression *, Type::FuncSpecifiers funcSpec, LinkageSpec::Spec, ConstantExpr *asmName, Initializer * init = nullptr, std::list< class Attribute * > attributes = std::list< class Attribute * >() ); 112 112 FunctionType * buildFunction( const TypeData * ); 113 113 void buildKRFunction( const TypeData::Function_t & function ); -
src/Parser/parser.yy
r26ba208 rddfd945 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Mar 16 08: 00:59201713 // Update Count : 23 0912 // Last Modified On : Thu Mar 16 08:36:17 2017 13 // Update Count : 2310 14 14 // 15 15 … … 1460 1460 // Put function specifiers here to simplify parsing rules, but separate them semantically. 1461 1461 | INLINE // C99 1462 { $$ = DeclarationNode::newFuncSpecifier( DeclarationNode::Inline ); }1462 { $$ = DeclarationNode::newFuncSpecifier( Type::Inline ); } 1463 1463 | FORTRAN // C99 1464 { $$ = DeclarationNode::newFuncSpecifier( DeclarationNode::Fortran ); }1464 { $$ = DeclarationNode::newFuncSpecifier( Type::Fortran ); } 1465 1465 | NORETURN // C11 1466 { $$ = DeclarationNode::newFuncSpecifier( DeclarationNode::Noreturn ); }1466 { $$ = DeclarationNode::newFuncSpecifier( Type::Noreturn ); } 1467 1467 ; 1468 1468
Note: See TracChangeset
for help on using the changeset viewer.