@@ -2241,7 +2241,7 @@ static void print_block(PycRef<ASTBlock> blk, PycModule* mod) {
22412241 print_src (pass, mod);
22422242 }
22432243
2244- for (ASTBlock:: list_t ::const_iterator ln = lines.begin (); ln != lines.end ();) {
2244+ for (auto ln = lines.cbegin (); ln != lines.cend ();) {
22452245 if ((*ln).cast <ASTNode>().type () != ASTNode::NODE_NODELIST) {
22462246 start_line (cur_indent);
22472247 }
@@ -2283,22 +2283,22 @@ void print_src(PycRef<ASTNode> node, PycModule* mod)
22832283 print_src (call->func (), mod);
22842284 fputs (" (" , pyc_output);
22852285 bool first = true ;
2286- for (ASTCall:: pparam_t ::const_iterator p = call-> pparams (). begin (); p != call->pparams (). end (); ++p ) {
2286+ for (const auto & param : call->pparams ()) {
22872287 if (!first)
22882288 fputs (" , " , pyc_output);
2289- print_src (*p , mod);
2289+ print_src (param , mod);
22902290 first = false ;
22912291 }
2292- for (ASTCall:: kwparam_t ::const_iterator p = call-> kwparams (). begin (); p != call->kwparams (). end (); ++p ) {
2292+ for (const auto & param : call->kwparams ()) {
22932293 if (!first)
22942294 fputs (" , " , pyc_output);
2295- if (p-> first .type () == ASTNode::NODE_NAME) {
2296- fprintf (pyc_output, " %s = " , p-> first .cast <ASTName>()->name ()->value ());
2295+ if (param. first .type () == ASTNode::NODE_NAME) {
2296+ fprintf (pyc_output, " %s = " , param. first .cast <ASTName>()->name ()->value ());
22972297 } else {
2298- PycRef<PycString> str_name = p-> first .cast <ASTObject>()->object ().require_cast <PycString>();
2298+ PycRef<PycString> str_name = param. first .cast <ASTObject>()->object ().require_cast <PycString>();
22992299 fprintf (pyc_output, " %s = " , str_name->value ());
23002300 }
2301- print_src (p-> second , mod);
2301+ print_src (param. second , mod);
23022302 first = false ;
23032303 }
23042304 if (call->hasVar ()) {
@@ -2347,17 +2347,16 @@ void print_src(PycRef<ASTNode> node, PycModule* mod)
23472347 break ;
23482348 case ASTNode::NODE_LIST:
23492349 {
2350- ASTList::value_t values = node.cast <ASTList>()->values ();
23512350 fputs (" [" , pyc_output);
23522351 bool first = true ;
23532352 cur_indent++;
2354- for (ASTList:: value_t ::const_iterator b = values. begin (); b != values. end (); ++b ) {
2353+ for (const auto & val : node. cast <ASTList>()-> values () ) {
23552354 if (first)
23562355 fputs (" \n " , pyc_output);
23572356 else
23582357 fputs (" ,\n " , pyc_output);
23592358 start_line (cur_indent);
2360- print_src (*b , mod);
2359+ print_src (val , mod);
23612360 first = false ;
23622361 }
23632362 cur_indent--;
@@ -2367,35 +2366,33 @@ void print_src(PycRef<ASTNode> node, PycModule* mod)
23672366 case ASTNode::NODE_COMPREHENSION:
23682367 {
23692368 PycRef<ASTComprehension> comp = node.cast <ASTComprehension>();
2370- ASTComprehension::generator_t values = comp->generators ();
23712369
23722370 fputs (" [ " , pyc_output);
23732371 print_src (comp->result (), mod);
23742372
2375- for (ASTComprehension:: generator_t ::const_iterator it = values. begin (); it != values. end (); ++it ) {
2373+ for (const auto & gen : comp-> generators () ) {
23762374 fputs (" for " , pyc_output);
2377- print_src ((*it) ->index (), mod);
2375+ print_src (gen ->index (), mod);
23782376 fputs (" in " , pyc_output);
2379- print_src ((*it) ->iter (), mod);
2377+ print_src (gen ->iter (), mod);
23802378 }
23812379 fputs (" ]" , pyc_output);
23822380 }
23832381 break ;
23842382 case ASTNode::NODE_MAP:
23852383 {
2386- ASTMap::map_t values = node.cast <ASTMap>()->values ();
23872384 fputs (" {" , pyc_output);
23882385 bool first = true ;
23892386 cur_indent++;
2390- for (ASTMap:: map_t ::const_iterator b = values. begin (); b != values. end (); ++b ) {
2387+ for (const auto & val : node. cast <ASTMap>()-> values () ) {
23912388 if (first)
23922389 fputs (" \n " , pyc_output);
23932390 else
23942391 fputs (" ,\n " , pyc_output);
23952392 start_line (cur_indent);
2396- print_src (b-> first , mod);
2393+ print_src (val. first , mod);
23972394 fputs (" : " , pyc_output);
2398- print_src (b-> second , mod);
2395+ print_src (val. second , mod);
23992396 first = false ;
24002397 }
24012398 cur_indent--;
@@ -2408,12 +2405,11 @@ void print_src(PycRef<ASTNode> node, PycModule* mod)
24082405 case ASTNode::NODE_NODELIST:
24092406 {
24102407 cur_indent++;
2411- ASTNodeList::list_t lines = node.cast <ASTNodeList>()->nodes ();
2412- for (ASTNodeList::list_t ::const_iterator ln = lines.begin (); ln != lines.end (); ++ln) {
2413- if ((*ln).cast <ASTNode>().type () != ASTNode::NODE_NODELIST) {
2408+ for (const auto & ln : node.cast <ASTNodeList>()->nodes ()) {
2409+ if (ln.cast <ASTNode>().type () != ASTNode::NODE_NODELIST) {
24142410 start_line (cur_indent);
24152411 }
2416- print_src (* ln, mod);
2412+ print_src (ln, mod);
24172413 end_line ();
24182414 }
24192415 cur_indent--;
@@ -2517,10 +2513,10 @@ void print_src(PycRef<ASTNode> node, PycModule* mod)
25172513 PycRef<ASTRaise> raise = node.cast <ASTRaise>();
25182514 fputs (" raise " , pyc_output);
25192515 bool first = true ;
2520- for (ASTRaise:: param_t ::const_iterator p = raise-> params (). begin (); p != raise->params (). end (); ++p ) {
2516+ for (const auto & param : raise->params ()) {
25212517 if (!first)
25222518 fputs (" , " , pyc_output);
2523- print_src (*p , mod);
2519+ print_src (param , mod);
25242520 first = false ;
25252521 }
25262522 }
@@ -2567,25 +2563,26 @@ void print_src(PycRef<ASTNode> node, PycModule* mod)
25672563 print_src (import ->name (), mod);
25682564 fputs (" import " , pyc_output);
25692565
2570- ASTImport::list_t ::const_iterator ii = stores.begin ();
25712566 if (stores.size () == 1 ) {
2572- print_src ((*ii)->src (), mod);
2567+ auto src = stores.front ()->src ();
2568+ auto dest = stores.front ()->dest ();
2569+ print_src (src, mod);
25732570
2574- if ((*ii)-> src () .cast <ASTName>()->name ()->value () != (*ii)-> dest () .cast <ASTName>()->name ()->value ()) {
2571+ if (src.cast <ASTName>()->name ()->value () != dest.cast <ASTName>()->name ()->value ()) {
25752572 fputs (" as " , pyc_output);
2576- print_src ((*ii)-> dest () , mod);
2573+ print_src (dest, mod);
25772574 }
25782575 } else {
25792576 bool first = true ;
2580- for (; ii != stores. end (); ++ii ) {
2577+ for (const auto & st : stores ) {
25812578 if (!first)
25822579 fputs (" , " , pyc_output);
2583- print_src ((*ii) ->src (), mod);
2580+ print_src (st ->src (), mod);
25842581 first = false ;
25852582
2586- if ((*ii) ->src ().cast <ASTName>()->name ()->value () != (*ii) ->dest ().cast <ASTName>()->name ()->value ()) {
2583+ if (st ->src ().cast <ASTName>()->name ()->value () != st ->dest ().cast <ASTName>()->name ()->value ()) {
25872584 fputs (" as " , pyc_output);
2588- print_src ((*ii) ->dest (), mod);
2585+ print_src (st ->dest (), mod);
25892586 }
25902587 }
25912588 }
@@ -2602,7 +2599,7 @@ void print_src(PycRef<ASTNode> node, PycModule* mod)
26022599 PycRef<ASTNode> code = node.cast <ASTFunction>()->code ();
26032600 PycRef<PycCode> code_src = code.cast <ASTObject>()->object ().cast <PycCode>();
26042601 ASTFunction::defarg_t defargs = node.cast <ASTFunction>()->defargs ();
2605- ASTFunction:: defarg_t ::iterator da = defargs.begin ();
2602+ auto da = defargs.cbegin ();
26062603 for (int i=0 ; i<code_src->argCount (); i++) {
26072604 if (i > 0 )
26082605 fputs (" , " , pyc_output);
@@ -2647,7 +2644,7 @@ void print_src(PycRef<ASTNode> node, PycModule* mod)
26472644 }
26482645
26492646 ASTFunction::defarg_t defargs = src.cast <ASTFunction>()->defargs ();
2650- ASTFunction:: defarg_t ::iterator da = defargs.begin ();
2647+ auto da = defargs.cbegin ();
26512648 bool first = true ;
26522649 for (int i=0 ; i<code_src->argCount (); i++) {
26532650 if (!first)
@@ -2699,10 +2696,10 @@ void print_src(PycRef<ASTNode> node, PycModule* mod)
26992696 if (bases->values ().size () > 0 ) {
27002697 fputs (" (" , pyc_output);
27012698 bool first = true ;
2702- for (ASTTuple:: value_t ::const_iterator b = bases-> values (). begin (); b != bases->values (). end (); ++b ) {
2699+ for (const auto & val : bases->values ()) {
27032700 if (!first)
27042701 fputs (" , " , pyc_output);
2705- print_src (*b , mod);
2702+ print_src (val , mod);
27062703 first = false ;
27072704 }
27082705 fputs (" ):\n " , pyc_output);
@@ -2728,11 +2725,10 @@ void print_src(PycRef<ASTNode> node, PycModule* mod)
27282725 if (fromlist.type () == PycObject::TYPE_TUPLE ||
27292726 fromlist.type () == PycObject::TYPE_SMALL_TUPLE) {
27302727 bool first = true ;
2731- PycTuple::value_t ::const_iterator ii = fromlist.cast <PycTuple>()->values ().begin ();
2732- for (; ii != fromlist.cast <PycTuple>()->values ().end (); ++ii) {
2728+ for (const auto & val : fromlist.cast <PycTuple>()->values ()) {
27332729 if (!first)
27342730 fputs (" , " , pyc_output);
2735- fprintf (pyc_output, " %s" , ii-> cast <PycString>()->value ());
2731+ fprintf (pyc_output, " %s" , val. cast <PycString>()->value ());
27362732 first = false ;
27372733 }
27382734 } else {
@@ -2783,10 +2779,10 @@ void print_src(PycRef<ASTNode> node, PycModule* mod)
27832779 if (tuple->requireParens ())
27842780 fputc (' (' , pyc_output);
27852781 bool first = true ;
2786- for (ASTTuple:: value_t ::const_iterator b = values. begin (); b != values. end (); ++b ) {
2782+ for (const auto & val : values) {
27872783 if (!first)
27882784 fputs (" , " , pyc_output);
2789- print_src (*b , mod);
2785+ print_src (val , mod);
27902786 first = false ;
27912787 }
27922788 if (values.size () == 1 )
@@ -2891,11 +2887,10 @@ void decompyle(PycRef<PycCode> code, PycModule* mod)
28912887 start_line (cur_indent + 1 );
28922888 fputs (" global " , pyc_output);
28932889 bool first = true ;
2894- PycCode::globals_t ::iterator it;
2895- for (it = globs.begin (); it != globs.end (); ++it) {
2890+ for (const auto & glob : globs) {
28962891 if (!first)
28972892 fputs (" , " , pyc_output);
2898- fprintf (pyc_output, " %s" , (*it) ->value ());
2893+ fprintf (pyc_output, " %s" , glob ->value ());
28992894 first = false ;
29002895 }
29012896 fputs (" \n " , pyc_output);
0 commit comments