| 143 | Derived& self() { return static_cast<Derived&>(*this); } |
| 144 | |
| 145 | ResultT RunLoop() { |
| 146 | while (!stack_.empty()) { |
| 147 | auto& f = stack_.back(); |
| 148 | bool pushed = false; |
| 149 | while (f.child_idx < f.NumChildren()) { |
| 150 | size_t idx = f.child_idx++; |
| 151 | ResultT r{}; |
| 152 | if (self().TryVisitChild(f, idx, &r)) { |
| 153 | if (self().FeedChild(f, r)) { |
| 154 | return self().OnTerminate(std::move(r)); |
| 155 | } |
| 156 | } else { |
| 157 | auto maybe = self().PushChildFrame(f, idx); |
| 158 | if (maybe.has_value()) { |
| 159 | if (self().FeedChild(f, *maybe)) { |
| 160 | return self().OnTerminate(std::move(*maybe)); |
| 161 | } |
| 162 | } else { |
| 163 | pushed = true; |
| 164 | break; |
| 165 | } |
| 166 | } |
| 167 | } |
| 168 | if (pushed) continue; |
| 169 | ResultT result = self().FinalizeFrame(f); |
| 170 | self().OnFrameComplete(f); |
| 171 | stack_.pop_back(); |
| 172 | if (stack_.empty()) return result; |
| 173 | if (self().FeedChild(stack_.back(), result)) { |
| 174 | return self().OnTerminate(std::move(result)); |
| 175 | } |
| 176 | } |
| 177 | TVM_FFI_UNREACHABLE(); |
| 178 | } |
| 179 | |
| 180 | void EnumerateChildren(FrameBase& frame, const Any& value, const Object* obj, int32_t ti) { |
| 181 | using details::AnyUnsafe; |
no test coverage detected