Changes in src/Parser/DeclarationNode.cc [984dce6:4040425]
- File:
-
- 1 edited
-
src/Parser/DeclarationNode.cc (modified) (25 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
r984dce6 r4040425 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Mar 21 21:04:23201613 // Update Count : 1 4212 // Last Modified On : Wed Mar 2 17:26:24 2016 13 // Update Count : 134 14 14 // 15 15 … … 42 42 UniqueName DeclarationNode::anonymous( "__anonymous" ); 43 43 44 extern LinkageSpec::Type linkage; // defined in parser.yy44 extern LinkageSpec::Type linkage; /* defined in cfa.y */ 45 45 46 46 DeclarationNode *DeclarationNode::clone() const { … … 55 55 newnode->linkage = linkage; 56 56 return newnode; 57 } // DeclarationNode::clone57 } 58 58 59 59 DeclarationNode::DeclarationNode() : type( 0 ), bitfieldWidth( 0 ), initializer( 0 ), hasEllipsis( false ), linkage( ::linkage ) { … … 117 117 newnode->type->function->newStyle = newStyle; 118 118 newnode->type->function->body = body; 119 typedefTable.addToEnclosingScope( newnode->name, TypedefTable::ID );120 119 121 120 if ( body ) { … … 130 129 131 130 return newnode; 132 } // DeclarationNode::newFunction131 } 133 132 134 133 DeclarationNode *DeclarationNode::newQualifier( Qualifier q ) { … … 137 136 newnode->type->qualifiers.push_back( q ); 138 137 return newnode; 139 } // DeclarationNode::newQualifier138 } 140 139 141 140 DeclarationNode *DeclarationNode::newStorageClass( DeclarationNode::StorageClass sc ) { … … 143 142 newnode->storageClasses.push_back( sc ); 144 143 return newnode; 145 } // DeclarationNode::newStorageClass144 } 146 145 147 146 DeclarationNode *DeclarationNode::newBasicType( BasicType bt ) { … … 150 149 newnode->type->basic->typeSpec.push_back( bt ); 151 150 return newnode; 152 } // DeclarationNode::newBasicType151 } 153 152 154 153 DeclarationNode *DeclarationNode::newBuiltinType( BuiltinType bt ) { … … 157 156 newnode->type->builtin->type = bt; 158 157 return newnode; 159 } // DeclarationNode::newBuiltinType158 } 160 159 161 160 DeclarationNode *DeclarationNode::newModifier( Modifier mod ) { … … 164 163 newnode->type->basic->modifiers.push_back( mod ); 165 164 return newnode; 166 } // DeclarationNode::newModifier165 } 167 166 168 167 DeclarationNode *DeclarationNode::newForall( DeclarationNode *forall ) { … … 171 170 newnode->type->forall = forall; 172 171 return newnode; 173 } // DeclarationNode::newForall172 } 174 173 175 174 DeclarationNode *DeclarationNode::newFromTypedef( std::string *name ) { … … 180 179 newnode->type->symbolic->params = 0; 181 180 return newnode; 182 } // DeclarationNode::newFromTypedef181 } 183 182 184 183 DeclarationNode *DeclarationNode::newAggregate( Aggregate kind, const std::string *name, ExpressionNode *actuals, DeclarationNode *fields ) { … … 189 188 if ( newnode->type->aggregate->name == "" ) { // anonymous aggregate ? 190 189 newnode->type->aggregate->name = DeclarationNode::anonymous.newName(); 191 } else if ( ! typedefTable.exists( newnode->type->aggregate->name ) ) { 192 // SKULLDUGGERY: Generate a typedef for the aggregate name so the aggregate does not have to be qualified by 193 // "struct". Only generate the typedef, if the name is not in use. The typedef is implicitly (silently) removed 194 // if the name is explicitly used. 190 } else { 191 // SKULLDUGGERY: generate a typedef for the aggregate name so that the aggregate does not have to be qualified 192 // by "struct" 195 193 typedefTable.addToEnclosingScope( newnode->type->aggregate->name, TypedefTable::TD ); 196 194 DeclarationNode *typedf = new DeclarationNode; … … 201 199 newnode->type->aggregate->fields = fields; 202 200 return newnode; 203 } // DeclarationNode::newAggregate201 } 204 202 205 203 DeclarationNode *DeclarationNode::newEnum( std::string *name, DeclarationNode *constants ) { … … 210 208 if ( newnode->type->enumeration->name == "" ) { // anonymous enumeration ? 211 209 newnode->type->enumeration->name = DeclarationNode::anonymous.newName(); 212 } else if ( ! typedefTable.exists( newnode->type->enumeration->name ) ) { 213 // SKULLDUGGERY: Generate a typedef for the enumeration name so the enumeration does not have to be qualified by 214 // "enum". Only generate the typedef, if the name is not in use. The typedef is implicitly (silently) removed if 215 // the name is explicitly used. 210 } else { 211 // SKULLDUGGERY: generate a typedef for the enumeration name so that the enumeration does not have to be 212 // qualified by "enum" 216 213 typedefTable.addToEnclosingScope( newnode->type->enumeration->name, TypedefTable::TD ); 217 214 DeclarationNode *typedf = new DeclarationNode; … … 221 218 newnode->type->enumeration->constants = constants; 222 219 return newnode; 223 } // DeclarationNode::newEnum220 } 224 221 225 222 DeclarationNode *DeclarationNode::newEnumConstant( std::string *name, ExpressionNode *constant ) { … … 227 224 newnode->name = assign_strptr( name ); 228 225 newnode->enumeratorValue = constant; 229 typedefTable.addToEnclosingScope( newnode->name, TypedefTable::ID ); 230 return newnode; 231 } // DeclarationNode::newEnumConstant 226 return newnode; 227 } 232 228 233 229 DeclarationNode *DeclarationNode::newName( std::string *name ) { … … 235 231 newnode->name = assign_strptr( name ); 236 232 return newnode; 237 } // DeclarationNode::newName233 } 238 234 239 235 DeclarationNode *DeclarationNode::newFromTypeGen( std::string *name, ExpressionNode *params ) { … … 244 240 newnode->type->symbolic->actuals = params; 245 241 return newnode; 246 } // DeclarationNode::newFromTypeGen242 } 247 243 248 244 DeclarationNode *DeclarationNode::newTypeParam( TypeClass tc, std::string *name ) { … … 253 249 newnode->type->variable->name = newnode->name; 254 250 return newnode; 255 } // DeclarationNode::newTypeParam251 } 256 252 257 253 DeclarationNode *DeclarationNode::newTrait( std::string *name, DeclarationNode *params, DeclarationNode *asserts ) { … … 263 259 newnode->type->aggregate->name = assign_strptr( name ); 264 260 return newnode; 265 } // DeclarationNode::newTrait261 } 266 262 267 263 DeclarationNode *DeclarationNode::newTraitUse( std::string *name, ExpressionNode *params ) { … … 273 269 newnode->type->aggInst->params = params; 274 270 return newnode; 275 } // DeclarationNode::newTraitUse271 } 276 272 277 273 DeclarationNode *DeclarationNode::newTypeDecl( std::string *name, DeclarationNode *typeParams ) { … … 283 279 newnode->type->symbolic->name = newnode->name; 284 280 return newnode; 285 } // DeclarationNode::newTypeDecl281 } 286 282 287 283 DeclarationNode *DeclarationNode::newPointer( DeclarationNode *qualifiers ) { … … 289 285 newnode->type = new TypeData( TypeData::Pointer ); 290 286 return newnode->addQualifiers( qualifiers ); 291 } // DeclarationNode::newPointer287 } 292 288 293 289 DeclarationNode *DeclarationNode::newArray( ExpressionNode *size, DeclarationNode *qualifiers, bool isStatic ) { … … 302 298 } // if 303 299 return newnode->addQualifiers( qualifiers ); 304 } // DeclarationNode::newArray300 } 305 301 306 302 DeclarationNode *DeclarationNode::newVarArray( DeclarationNode *qualifiers ) {
Note:
See TracChangeset
for help on using the changeset viewer.