CompileJS.h 944 B

1234567891011121314151617181920212223242526272829303132333435
  1. /*
  2. * Copyright (c) Facebook, Inc. and its affiliates.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. */
  7. #ifndef HERMES_COMPILEJS_H
  8. #define HERMES_COMPILEJS_H
  9. #include <string>
  10. namespace hermes {
  11. /// Compiles JS source \p str and if compilation is successful, returns true
  12. /// and outputs to \p bytecode otherwise returns false.
  13. /// \param sourceURL this will be used as the "file name" of the buffer for
  14. /// errors, stack traces, etc.
  15. /// NOTE: Doesn't throw any exceptions. It's up to the caller to report failure.
  16. ///
  17. /// TODO(30388684): Return opaque object that can be run or serialized.
  18. bool compileJS(
  19. const std::string &str,
  20. const std::string &sourceURL,
  21. std::string &bytecode,
  22. bool optimize = true);
  23. bool compileJS(
  24. const std::string &str,
  25. std::string &bytecode,
  26. bool optimize = true);
  27. } // namespace hermes
  28. #endif