Skip to content

SpecificationXIII · The engine inside

13.7

Native code and the host

A program can also be compiled to a native executable that behaves exactly as in the virtual machine: the same output, the same failures, the same messages.

Markdown version

13.7.1 How it works

pseudo compilar translates the intermediate representation to native code and links it with PseudoLearn's runtime into a single executable: Mach-O on macOS, static ELF on Linux and .exe on Windows. No compiler or linker needs to be installed: PseudoLearn brings its own, and intermediate files are always deleted at the end.

Figure 13.7-1.The same intermediate representation feeds the virtual machine and the native compiler. Both runs are indistinguishable.

The intermediate representation feeds two paths: the virtual machine and native code. An equals sign between them shows they give the same run.

Inside the executable, every value crosses the boundary with the same encoding as in the virtual machine: 64-bit integers, binary64 reals, booleans as 0 or 1 and 32-bit handles for texts, arrays and objects. The collector only examines registered roots, so no live object is lost.

The host —the app, the terminal or the executable— provides input and output, grants capabilities and decides the delivery order of pending effects, which is recorded on the tape. The random source is the same everywhere: xoshiro256** started from the seed with SplitMix64.

ProgramA failure with the previous output kept

Algorithm FalloNativo
  Define cero As Integer <- 0;
  Write "calculando";
  Write 10 Div cero;
EndAlgorithm

Output

calculando

Diagnostics

  • divisionByZero · error · 4:12 · Division by zero

The program finishes with an error.

Compiled, this program writes calculando on standard output and then reports the failure, with the same code and position, on the error output. No language failure becomes an operating-system signal.

In short

  • pseudo compilar produces a standalone native executable.
  • The executable behaves exactly like the virtual machine.
  • Failures are reported with their diagnostic, without system signals.