fuzz_ops.cpp 992 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #include "fuzz_ops.h"
  2. #include "vm_apply.h"
  3. #include "vm_defs.h"
  4. #include "vm_parse.h"
  5. #include <library/cpp/bit_io/bitinput.h>
  6. #include <library/cpp/scheme/scheme.h>
  7. #include <library/cpp/scheme/scimpl_private.h>
  8. #include <util/generic/maybe.h>
  9. namespace NSc::NUt {
  10. void FuzzOps(TStringBuf wire, bool log) {
  11. if (log) {
  12. NImpl::GetTlsInstance<NImpl::TSelfLoopContext>().ReportingMode = NImpl::TSelfLoopContext::EMode::Stderr;
  13. }
  14. // We start with a single TValue node
  15. TVMState st {wire, 1, 0};
  16. while (auto act = ParseNextAction(st)) {
  17. if (log) {
  18. Cerr << " STATE: " << st.ToString() << Endl;
  19. Cerr << "ACTION: " << (act ? act->ToString() : TString("(empty)")) << Endl;
  20. }
  21. if (!ApplyNextAction(st, *act)) {
  22. break;
  23. }
  24. if (!NSc::TValue::DefaultValue().IsNull()) {
  25. std::terminate();
  26. }
  27. }
  28. }
  29. }