Running code

edit

The pages of this group cover the two kinds of code that a realm runs, and what happens when they fail:

  • A script is run by realm.Execute, which returns the value of its last statement. The scripts of a realm share their global variables.
  • A module is parsed by realm.ParseModule, then loaded, linked and evaluated. Its import declarations go through the module loader of the engine, and its variables are its own.

In both cases, an uncaught error is thrown to .NET as a JsException, and a script stopped by a limit throws a JsTerminationException.

Pages of this group

  • Scripts: run a script, give it a file name, compile it once and run it in several engines, check its syntax without running it.
  • Modules: write a module loader, load JSON, text and .NET modules, read the exports, use import().
  • Handling errors: catch the errors of the scripts, find where they were thrown, map them to the original sources with source maps, throw JavaScript errors from .NET.
  • Debugging and inspecting scripts: stop at breakpoints, step through the statements, measure the code coverage.
  • CommonJS modules: run code that uses require and module.exports, with a loader that you control.