ilusm.dev

Syscall ABI

Complete specification of ilusm's syscall interface, VM opcodes, and host builtin functions.

Overview

ilusm uses two platform paths for system interaction:

  • Dedicated VM opcodes - Core operations (strings, file I/O) implemented in the reference VM
  • Host builtins - Extension interface for advanced operations (networking, crypto, system calls)

There is no generic syscall(id, …) opcode. The syscall table is reserved for future extensions.

VM Opcodes

These opcodes touch the platform and are implemented in the reference VM:

OpcodeNameHost Dependency
21str_attxtat (stdlib/txt.ilu)
22str_subtxtsub
23str_lenstring len
24str_cattxtjn
25file_read__sys_read_file(path)
26file_write__sys_write_file(path, content)

Opcodes 27 (callv) and 15 (call) invoke builtins or user functions.

Host Builtins

Hosts must implement these exact names for a conforming runner. These are called via bytecode call instructions.

File Operations

NameArgsReturns
__sys_read_filepath strcontent str or err
__sys_write_filepath str, content strnil or err
__sys_read_dirdir strlist of names or err
__sys_statpath strbool (exists)
__sys_removepath strnil or err
__sys_mkdirdir strnil or err

Network Operations

NameArgsReturns
__sys_tcp_dialhost str, port numsock handle or err
__sys_tcp_sendsock, data strnil or err
__sys_tcp_recvsock, timeout numdata str or err
__sys_tcp_closesocknil
__http_geturl str, headers objresponse obj or err
__http_posturl str, headers obj, body strresponse obj or err

System Operations

NameArgsReturns
__sys_get_envkey strvalue str or nil
__sys_set_envkey str, value strnil or err
__sys_run_commandcmd str, args listresult obj or err
__sys_get_timenonetimestamp num
__sys_sleepms numnil

Cryptographic Operations

NameArgsReturns
__cry_hashdata str, alg strhash str or err
__cry_hmacdata str, key str, alg strhmac str or err
__cry_aes_encryptdata str, key str, iv strencrypted str or err
__cry_aes_decryptdata str, key str, iv strdecrypted str or err
__cry_randomlen numrandom str or err

Implementation Notes

  • Reference VM: See lib/backend/ilusm_vm.ilu for the canonical implementation
  • Bytecode Spec: Complete opcode definitions in lib/backend/mcde.ilu
  • Host Contract: All hosts must implement the exact names and signatures above
  • Error Handling: Failed syscalls should return error objects, not raise exceptions
  • Security: File operations are sandboxed to the program's working directory by default

Stdlib Integration

Standard library modules wire to these syscalls:

  • net.*__http_* / __net_* / __sys_tcp_*
  • syn / buf / obs__sys_* / __buf_* / __obs_*
  • cry.*__cry_*
  • fs.*__sys_* file operations

See lib/stdlib/ and Stdlib overview for complete module documentation.