- Timestamp:
- Sep 10, 2018, 5:17:34 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
- Children:
- 67982887, 9fce933a
- Parents:
- 0cf9ffd (diff), e15ba975 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- src
- Files:
-
- 3 edited
-
Parser/lex.ll (modified) (2 diffs)
-
Parser/parser.yy (modified) (8 diffs)
-
SymTab/Validate.cc (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/lex.ll
r0cf9ffd rbedb40e 10 10 * Created On : Sat Sep 22 08:58:10 2001 11 11 * Last Modified By : Peter A. Buhr 12 * Last Modified On : Wed Aug 8 17:23:17201813 * Update Count : 68 512 * Last Modified On : Wed Aug 29 15:02:41 2018 13 * Update Count : 686 14 14 */ 15 15 … … 410 410 ">>=" { NAMEDOP_RETURN(RSassign); } 411 411 412 "~=" { NAMEDOP_RETURN(Erange); } // CFA413 412 "@=" { NAMEDOP_RETURN(ATassign); } // CFA 413 "~=" { NAMEDOP_RETURN(ErangeUpEq); } // CFA 414 "-~" { NAMEDOP_RETURN(ErangeDown); } // CFA 415 "-~=" { NAMEDOP_RETURN(ErangeDownEq); } // CFA 414 416 415 417 /* CFA, operator identifier */ -
src/Parser/parser.yy
r0cf9ffd rbedb40e 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Aug 8 17:50:07201813 // Update Count : 399812 // Last Modified On : Thu Aug 30 17:02:25 2018 13 // Update Count : 4029 14 14 // 15 15 … … 186 186 } // fieldDecl 187 187 188 ExpressionNode *forInc( const OperKinds op ) { 189 return new ExpressionNode( build_constantInteger( *new string( op == OperKinds::LThan || op == OperKinds::LEThan ? "1" : "-1" ) ) ); 190 } // forInc 191 188 192 ForCtrl * forCtrl( ExpressionNode * type, string * index, ExpressionNode * start, enum OperKinds compop, ExpressionNode * comp, ExpressionNode * inc ) { 193 ConstantExpr *constant = dynamic_cast<ConstantExpr *>(type->get_expr()); 194 if ( constant && (constant->get_constant()->get_value() == "0" || constant->get_constant()->get_value() == "1") ) { 195 type = new ExpressionNode( new CastExpr( maybeMoveBuild< Expression >(type), new BasicType( Type::Qualifiers(), BasicType::SignedInt ) ) ); 196 } // if 189 197 return new ForCtrl( 190 198 distAttr( DeclarationNode::newTypeof( type ), DeclarationNode::newName( index )->addInitializer( new InitializerNode( start ) ) ), … … 214 222 215 223 // Types declaration for productions 216 %union 217 { 224 %union { 218 225 Token tok; 219 226 ParseNode * pn; … … 290 297 %token ANDassign ERassign ORassign // &= ^= |= 291 298 292 %token Erange //~=299 %token ErangeUpEq ErangeDown ErangeDownEq // ~= -~ -~= 293 300 %token ATassign // @= 294 301 … … 1138 1145 $$ = new ForCtrl( (ExpressionNode * )nullptr, (ExpressionNode * )nullptr, (ExpressionNode * )nullptr ); 1139 1146 } else { 1140 $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ), OperKinds::LThan, $1->clone(),1141 new ExpressionNode( build_constantInteger( *new string( "1" ) )) );1147 $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ), 1148 OperKinds::LThan, $1->clone(), forInc( OperKinds::LThan ) ); 1142 1149 } // if 1143 1150 } 1144 1151 | constant_expression inclexcl constant_expression // CFA 1145 { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, new ExpressionNode( build_constantInteger( *new string( "1" ) )) ); }1152 { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, forInc( $2 ) ); } 1146 1153 | constant_expression inclexcl constant_expression '~' constant_expression // CFA 1147 1154 { $$ = forCtrl( $1, new string( DeclarationNode::anonymous.newName() ), $1->clone(), $2, $3, $5 ); } … … 1154 1161 } else { 1155 1162 if ( NameExpr *identifier = dynamic_cast<NameExpr *>($1->get_expr()) ) { 1156 $$ = forCtrl( $3, new string( identifier->name ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ), OperKinds::LThan, $3->clone(),1157 new ExpressionNode( build_constantInteger( *new string( "1" ) )) );1163 $$ = forCtrl( $3, new string( identifier->name ), new ExpressionNode( build_constantInteger( *new string( "0" ) ) ), 1164 OperKinds::LThan, $3->clone(), forInc( OperKinds::LThan ) ); 1158 1165 } else { 1159 1166 SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed" ); $$ = nullptr; … … 1167 1174 } else { 1168 1175 if ( NameExpr *identifier = dynamic_cast<NameExpr *>($1->get_expr()) ) { 1169 $$ = forCtrl( $3, new string( identifier->name ), $3->clone(), $4, $5, new ExpressionNode( build_constantInteger( *new string( "1" ) )) );1176 $$ = forCtrl( $3, new string( identifier->name ), $3->clone(), $4, $5, forInc( $4 ) ); 1170 1177 } else { 1171 1178 SemanticError( yylloc, "Expression disallowed. Only loop-index name allowed" ); $$ = nullptr; … … 1194 1201 '~' 1195 1202 { $$ = OperKinds::LThan; } 1196 | Erange 1203 | ErangeUpEq 1197 1204 { $$ = OperKinds::LEThan; } 1205 | ErangeDown 1206 { $$ = OperKinds::GThan; } 1207 | ErangeDownEq 1208 { $$ = OperKinds::GEThan; } 1198 1209 ; 1199 1210 -
src/SymTab/Validate.cc
r0cf9ffd rbedb40e 403 403 assert( aggr ); // TODO: need to handle forward declarations 404 404 for ( Declaration * member : aggr->members ) { 405 if ( StructInstType * inst = dynamic_cast< StructInstType * >( child ) ) { 406 if ( StructDecl * aggr = dynamic_cast< StructDecl * >( member ) ) { 407 if ( aggr->name == inst->name ) { 408 // TODO: is this case, and other non-TypeInstType cases, necessary? 409 return new StructInstType( qualType->get_qualifiers(), aggr ); 410 } 411 } 412 } else if ( UnionInstType * inst = dynamic_cast< UnionInstType * >( child ) ) { 413 if ( UnionDecl * aggr = dynamic_cast< UnionDecl * > ( member ) ) { 414 if ( aggr->name == inst->name ) { 415 return new UnionInstType( qualType->get_qualifiers(), aggr ); 416 } 417 } 418 } else if ( EnumInstType * inst = dynamic_cast< EnumInstType * >( child ) ) { 419 if ( EnumDecl * aggr = dynamic_cast< EnumDecl * > ( member ) ) { 420 if ( aggr->name == inst->name ) { 421 return new EnumInstType( qualType->get_qualifiers(), aggr ); 422 } 423 } 424 } else if ( TypeInstType * inst = dynamic_cast< TypeInstType * >( child ) ) { 405 if ( TypeInstType * inst = dynamic_cast< TypeInstType * >( child ) ) { 425 406 // name on the right is a typedef 426 407 if ( NamedTypeDecl * aggr = dynamic_cast< NamedTypeDecl * > ( member ) ) { … … 429 410 Type * ret = aggr->base->clone(); 430 411 ret->get_qualifiers() = qualType->get_qualifiers(); 412 TypeSubstitution sub = parent->genericSubstitution(); 413 sub.apply(ret); 431 414 return ret; 432 415 }
Note:
See TracChangeset
for help on using the changeset viewer.