Changeset 5bf685f for src/Parser
- Timestamp:
- Jan 17, 2024, 3:13:56 PM (5 months ago)
- Branches:
- master
- Children:
- 11f65b3
- Parents:
- e891349
- Location:
- src/Parser
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
re891349 r5bf685f 35 35 #include "Common/SemanticError.h" // for SemanticError 36 36 #include "Common/UniqueName.h" // for UniqueName 37 #include "Common/utility.h" // for maybeClone37 #include "Common/utility.h" // for copy, spliceBegin 38 38 #include "Parser/ExpressionNode.h" // for ExpressionNode 39 39 #include "Parser/InitializerNode.h"// for InitializerNode … … 41 41 #include "TypeData.h" // for TypeData, TypeData::Aggregate_t 42 42 #include "TypedefTable.h" // for TypedefTable 43 44 class Initializer;45 43 46 44 extern TypedefTable typedefTable; … … 101 99 DeclarationNode * DeclarationNode::clone() const { 102 100 DeclarationNode * newnode = new DeclarationNode; 103 newnode->set_next( maybeC lone( get_next() ) );101 newnode->set_next( maybeCopy( get_next() ) ); 104 102 newnode->name = name ? new string( *name ) : nullptr; 105 103 106 104 newnode->builtin = NoBuiltinType; 107 newnode->type = maybeC lone( type );105 newnode->type = maybeCopy( type ); 108 106 newnode->inLine = inLine; 109 107 newnode->storageClasses = storageClasses; 110 108 newnode->funcSpecs = funcSpecs; 111 newnode->bitfieldWidth = maybeC lone( bitfieldWidth );112 newnode->enumeratorValue.reset( maybeC lone( enumeratorValue.get() ) );109 newnode->bitfieldWidth = maybeCopy( bitfieldWidth ); 110 newnode->enumeratorValue.reset( maybeCopy( enumeratorValue.get() ) ); 113 111 newnode->hasEllipsis = hasEllipsis; 114 112 newnode->linkage = linkage; 115 113 newnode->asmName = maybeCopy( asmName ); 116 114 newnode->attributes = attributes; 117 newnode->initializer = maybeC lone( initializer );115 newnode->initializer = maybeCopy( initializer ); 118 116 newnode->extension = extension; 119 newnode->asmStmt = maybeC lone( asmStmt );117 newnode->asmStmt = maybeCopy( asmStmt ); 120 118 newnode->error = error; 121 119 122 120 // newnode->variable.name = variable.name ? new string( *variable.name ) : nullptr; 123 121 newnode->variable.tyClass = variable.tyClass; 124 newnode->variable.assertions = maybeC lone( variable.assertions );125 newnode->variable.initializer = maybeC lone( variable.initializer );126 127 newnode->assert.condition = maybeC lone( assert.condition );122 newnode->variable.assertions = maybeCopy( variable.assertions ); 123 newnode->variable.initializer = maybeCopy( variable.initializer ); 124 125 newnode->assert.condition = maybeCopy( assert.condition ); 128 126 newnode->assert.message = maybeCopy( assert.message ); 129 127 return newnode; … … 664 662 dst->base->aggInst.aggregate = src; 665 663 if ( src->kind == TypeData::Aggregate ) { 666 dst->base->aggInst.params = maybeC lone( src->aggregate.actuals );664 dst->base->aggInst.params = maybeCopy( src->aggregate.actuals ); 667 665 } // if 668 666 dst->base->qualifiers |= src->qualifiers; … … 694 692 if ( o->type->kind == TypeData::Aggregate ) { 695 693 type->aggInst.hoistType = o->type->aggregate.body; 696 type->aggInst.params = maybeC lone( o->type->aggregate.actuals );694 type->aggInst.params = maybeCopy( o->type->aggregate.actuals ); 697 695 } else { 698 696 type->aggInst.hoistType = o->type->enumeration.body; … … 860 858 p->type->base->aggInst.aggregate = type; 861 859 if ( type->kind == TypeData::Aggregate ) { 862 p->type->base->aggInst.params = maybeC lone( type->aggregate.actuals );860 p->type->base->aggInst.params = maybeCopy( type->aggregate.actuals ); 863 861 } // if 864 862 p->type->base->qualifiers |= type->qualifiers; … … 897 895 lastArray->base->aggInst.aggregate = type; 898 896 if ( type->kind == TypeData::Aggregate ) { 899 lastArray->base->aggInst.params = maybeC lone( type->aggregate.actuals );897 lastArray->base->aggInst.params = maybeCopy( type->aggregate.actuals ); 900 898 } // if 901 899 lastArray->base->qualifiers |= type->qualifiers; … … 950 948 DeclarationNode * DeclarationNode::cloneType( string * name ) { 951 949 DeclarationNode * newnode = newName( name ); 952 newnode->type = maybeC lone( type );950 newnode->type = maybeCopy( type ); 953 951 newnode->copySpecifiers( this ); 954 952 return newnode; … … 984 982 } // if 985 983 986 newType->forall = maybeC lone( type->forall );984 newType->forall = maybeCopy( type->forall ); 987 985 if ( ! o->type ) { 988 986 o->type = newType; -
src/Parser/ParseNode.h
re891349 r5bf685f 30 30 #include "Common/SemanticError.h" // for SemanticError 31 31 #include "Common/UniqueName.h" // for UniqueName 32 #include "Common/utility.h" // for maybeClone33 32 #include "Parser/parserutility.h" // for maybeBuild, maybeCopy 34 33 -
src/Parser/TypeData.cc
re891349 r5bf685f 167 167 TypeData * newtype = new TypeData( kind ); 168 168 newtype->qualifiers = qualifiers; 169 newtype->base = maybeC lone( base );170 newtype->forall = maybeC lone( forall );169 newtype->base = maybeCopy( base ); 170 newtype->forall = maybeCopy( forall ); 171 171 172 172 switch ( kind ) { … … 185 185 break; 186 186 case Array: 187 newtype->array.dimension = maybeC lone( array.dimension );187 newtype->array.dimension = maybeCopy( array.dimension ); 188 188 newtype->array.isVarLen = array.isVarLen; 189 189 newtype->array.isStatic = array.isStatic; 190 190 break; 191 191 case Function: 192 newtype->function.params = maybeC lone( function.params );193 newtype->function.idList = maybeC lone( function.idList );194 newtype->function.oldDeclList = maybeC lone( function.oldDeclList );195 newtype->function.body = maybeC lone( function.body );196 newtype->function.withExprs = maybeC lone( function.withExprs );192 newtype->function.params = maybeCopy( function.params ); 193 newtype->function.idList = maybeCopy( function.idList ); 194 newtype->function.oldDeclList = maybeCopy( function.oldDeclList ); 195 newtype->function.body = maybeCopy( function.body ); 196 newtype->function.withExprs = maybeCopy( function.withExprs ); 197 197 break; 198 198 case Aggregate: 199 199 newtype->aggregate.kind = aggregate.kind; 200 200 newtype->aggregate.name = aggregate.name ? new string( *aggregate.name ) : nullptr; 201 newtype->aggregate.params = maybeC lone( aggregate.params );202 newtype->aggregate.actuals = maybeC lone( aggregate.actuals );203 newtype->aggregate.fields = maybeC lone( aggregate.fields );201 newtype->aggregate.params = maybeCopy( aggregate.params ); 202 newtype->aggregate.actuals = maybeCopy( aggregate.actuals ); 203 newtype->aggregate.fields = maybeCopy( aggregate.fields ); 204 204 newtype->aggregate.body = aggregate.body; 205 205 newtype->aggregate.anon = aggregate.anon; … … 208 208 break; 209 209 case AggregateInst: 210 newtype->aggInst.aggregate = maybeC lone( aggInst.aggregate );211 newtype->aggInst.params = maybeC lone( aggInst.params );210 newtype->aggInst.aggregate = maybeCopy( aggInst.aggregate ); 211 newtype->aggInst.params = maybeCopy( aggInst.params ); 212 212 newtype->aggInst.hoistType = aggInst.hoistType; 213 213 break; 214 214 case Enum: 215 215 newtype->enumeration.name = enumeration.name ? new string( *enumeration.name ) : nullptr; 216 newtype->enumeration.constants = maybeC lone( enumeration.constants );216 newtype->enumeration.constants = maybeCopy( enumeration.constants ); 217 217 newtype->enumeration.body = enumeration.body; 218 218 newtype->enumeration.anon = enumeration.anon; … … 221 221 case SymbolicInst: 222 222 newtype->symbolic.name = symbolic.name ? new string( *symbolic.name ) : nullptr; 223 newtype->symbolic.params = maybeC lone( symbolic.params );224 newtype->symbolic.actuals = maybeC lone( symbolic.actuals );225 newtype->symbolic.assertions = maybeC lone( symbolic.assertions );223 newtype->symbolic.params = maybeCopy( symbolic.params ); 224 newtype->symbolic.actuals = maybeCopy( symbolic.actuals ); 225 newtype->symbolic.assertions = maybeCopy( symbolic.assertions ); 226 226 newtype->symbolic.isTypedef = symbolic.isTypedef; 227 227 break; 228 228 case Tuple: 229 newtype->tuple = maybeC lone( tuple );229 newtype->tuple = maybeCopy( tuple ); 230 230 break; 231 231 case Typeof: 232 232 case Basetypeof: 233 newtype->typeexpr = maybeC lone( typeexpr );233 newtype->typeexpr = maybeCopy( typeexpr ); 234 234 break; 235 235 case Vtable: … … 240 240 break; 241 241 case Qualified: 242 newtype->qualified.parent = maybeC lone( qualified.parent );243 newtype->qualified.child = maybeC lone( qualified.child );242 newtype->qualified.parent = maybeCopy( qualified.parent ); 243 newtype->qualified.child = maybeCopy( qualified.child ); 244 244 break; 245 245 } // switch -
src/Parser/parser.yy
re891349 r5bf685f 1960 1960 // Append the return type at the start (left-hand-side) to each identifier in the list. 1961 1961 DeclarationNode * ret = new DeclarationNode; 1962 ret->type = maybeC lone( $1->type->base );1962 ret->type = maybeCopy( $1->type->base ); 1963 1963 $$ = $1->appendList( DeclarationNode::newFunction( $3, ret, $6, nullptr ) ); 1964 1964 } -
src/Parser/parserutility.h
re891349 r5bf685f 36 36 37 37 template<typename node_t> 38 node_t * maybeCopy( node_t const * node ) {38 static inline node_t * maybeCopy( node_t const * node ) { 39 39 return node ? ast::shallowCopy( node ) : nullptr; 40 40 }
Note: See TracChangeset
for help on using the changeset viewer.