Home | History | Annotate | Download | only in dex
      1 /*
      2  * Copyright (C) 2013 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 #ifndef ART_COMPILER_DEX_DATAFLOW_ITERATOR_INL_H_
     18 #define ART_COMPILER_DEX_DATAFLOW_ITERATOR_INL_H_
     19 
     20 #include "dataflow_iterator.h"
     21 
     22 namespace art {
     23 
     24 inline BasicBlock* DataflowIterator::NextBody(bool had_change) {
     25   changed_ |= had_change;
     26   BasicBlock* res = NULL;
     27   if (reverse_) {
     28     if (is_iterative_ && changed_ && (idx_ < 0)) {
     29       idx_ = start_idx_;
     30       changed_ = false;
     31     }
     32     if (idx_ >= 0) {
     33       int bb_id = block_id_list_->Get(idx_--);
     34       res = mir_graph_->GetBasicBlock(bb_id);
     35     }
     36   } else {
     37     if (is_iterative_ && changed_ && (idx_ >= end_idx_)) {
     38       idx_ = start_idx_;
     39       changed_ = false;
     40     }
     41     if (idx_ < end_idx_) {
     42       int bb_id = block_id_list_->Get(idx_++);
     43       res = mir_graph_->GetBasicBlock(bb_id);
     44     }
     45   }
     46   return res;
     47 }
     48 
     49 // AllNodes uses the existing GrowableArray iterator, so use different NextBody().
     50 inline BasicBlock* AllNodesIterator::NextBody(bool had_change) {
     51   changed_ |= had_change;
     52   BasicBlock* res = NULL;
     53   bool keep_looking = true;
     54   while (keep_looking) {
     55     res = all_nodes_iterator_->Next();
     56     if (is_iterative_ && changed_ && (res == NULL)) {
     57       all_nodes_iterator_->Reset();
     58       changed_ = false;
     59     } else if ((res == NULL) || (!res->hidden)) {
     60       keep_looking = false;
     61     }
     62   }
     63   return res;
     64 }
     65 
     66 }  // namespace art
     67 
     68 #endif  // ART_COMPILER_DEX_DATAFLOW_ITERATOR_INL_H_
     69