// vuurraaf/v // A complete toolchain for VuurRaaf, in V. This toolchain is made from zero, // and includes a custom compiler, assembler, linker, and runtime. // It is designed to be simple and easy to understand, while still being powerful // enough to compile and run VuurRaaf programs. // // vr run hello.vr compile + link + run // vr compile hello.vr source -> object (.vobj) // vr assemble math.vasm assembly -> object (.vobj) // vr link a.vobj b.vobj objects -> executable (.vbin) // vr debug hello.vr run with an instruction trace // vr test tests.vr run every test_* function // vr bench fib.vr 1000 benchmark main() // vr help everything else module main import os import json2 import time import obj import compiler import assembler import linker import vm const name = 'vuurraaf/v' const version = '0.1.0' const project_root = @VMODROOT fn main() { args := os.args[1..] if args.len == 0 { toolchain_help() return } cmd := args[0] rest := args[1..] match cmd { 'help', '-h', '--help' { toolchain_help() } 'version', '-v', '--version' { toolchain_version() } 'info' { toolchain_info() } 'config' { toolchain_config(rest) or { die('config', err) } } 'compile', 'c' { toolchain_compile(rest) or { die('compile', err) } } 'assemble', 'a' { toolchain_assemble(rest) or { die('assemble', err) } } 'link', 'l' { toolchain_link(rest) or { die('link', err) } } 'run', 'r' { toolchain_run(rest) or { die('run', err) } } 'debug', 'd' { toolchain_debug(rest) or { die('debug', err) } } 'profile', 'p' { toolchain_profile(rest) or { die('profile', err) } } 'fuzz' { toolchain_fuzz(rest) or { die('fuzz', err) } } 'test', 't' { toolchain_test(rest) or { die('test', err) } } 'bench', 'b' { toolchain_bench(rest) or { die('bench', err) } } 'repl', 'i' { toolchain_repl() or { die('repl', err) } } 'lsp' { toolchain_lsp() } 'fmt' { toolchain_fmt(rest) or { die('fmt', err) } } 'init' { toolchain_init(rest) or { die('init', err) } } 'get' { toolchain_get(rest) or { die('get', err) } } 'install' { toolchain_install() or { die('install', err) } } 'list' { toolchain_list() or { die('list', err) } } 'clean' { toolchain_clean() } 'make', 'm', 'build' { toolchain_make(rest) or { die('make', err) } } 'up' { toolchain_up() or { die('up', err) } } 'symlink' { toolchain_symlink() or { die('symlink', err) } } 'loader' { toolchain_loader() } 'alloc' { toolchain_alloc() } 'free' { toolchain_free() } 'unloader' { toolchain_unloader() } else { // direct script execution — this is what makes shebangs work: // `#!/usr/bin/env vr` has the kernel call `vr