Function run

Source
pub fn run() -> ExitCode
Expand description

Compiles and executes a JSON-based program using the Jsonpiler. This function performs the following steps:

  1. Parses the first CLI argument as the input JSON file path.
  2. Reads the file content into a string.
  3. Parses the string into a Json structure.
  4. Compiles the structure into assembly code.
  5. Assembles it into an .obj file.
  6. Links it into an .exe.
  7. Executes the resulting binary.
  8. Returns its exit code.

§Panics

This function will panic if:

  • The platform is not Windows.
  • CLI arguments are invalid.
  • File reading, parsing, compilation, assembling, linking, or execution fails.
  • The working directory or executable filename is invalid.

§Requirements

  • as and ld must be available in the system PATH.
  • On failure, exits with code 1 using error_exit.

§Example

./jsonpiler test.json

§Platform

Windows only.