#ifndef vm_BytecodeIterator_h
#define vm_BytecodeIterator_h
#include "vm/BytecodeLocation.h"
namespace js {
class BytecodeIterator {
BytecodeLocation current_;
public:
explicit BytecodeIterator(const JSScript* script);
explicit BytecodeIterator(BytecodeLocation loc) : current_(loc) {}
bool operator==(const BytecodeIterator& other) const {
return other.current_ == current_;
}
bool operator!=(const BytecodeIterator& other) const {
return !(other.current_ == current_);
}
const BytecodeLocation& operator*() const { return current_; }
const BytecodeLocation* operator->() const { return ¤t_; }
BytecodeIterator& operator++() {
current_ = current_.next();
return *this;
}
BytecodeIterator operator++(int) {
current_ = current_.next();
return *this;
}
};
class AllBytecodesIterable {
const JSScript* script_;
public:
explicit AllBytecodesIterable(const JSScript* script) : script_(script) {}
BytecodeIterator begin();
BytecodeIterator end();
};
}
#endif