Executable.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibJS/Bytecode/Executable.h>
  7. #include <LibJS/SourceCode.h>
  8. namespace JS::Bytecode {
  9. Executable::Executable(
  10. NonnullOwnPtr<IdentifierTable> identifier_table,
  11. NonnullOwnPtr<StringTable> string_table,
  12. NonnullOwnPtr<RegexTable> regex_table,
  13. NonnullRefPtr<SourceCode const> source_code,
  14. size_t number_of_property_lookup_caches,
  15. size_t number_of_global_variable_caches,
  16. size_t number_of_registers,
  17. Vector<NonnullOwnPtr<BasicBlock>> basic_blocks,
  18. bool is_strict_mode)
  19. : basic_blocks(move(basic_blocks))
  20. , string_table(move(string_table))
  21. , identifier_table(move(identifier_table))
  22. , regex_table(move(regex_table))
  23. , source_code(move(source_code))
  24. , number_of_registers(number_of_registers)
  25. , is_strict_mode(is_strict_mode)
  26. {
  27. property_lookup_caches.resize(number_of_property_lookup_caches);
  28. global_variable_caches.resize(number_of_global_variable_caches);
  29. }
  30. Executable::~Executable() = default;
  31. void Executable::dump() const
  32. {
  33. dbgln("\033[33;1mJS::Bytecode::Executable\033[0m ({})", name);
  34. for (auto& block : basic_blocks)
  35. block->dump(*this);
  36. if (!string_table->is_empty()) {
  37. outln();
  38. string_table->dump();
  39. }
  40. if (!identifier_table->is_empty()) {
  41. outln();
  42. identifier_table->dump();
  43. }
  44. }
  45. }