Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
2506c49
initial prims
pjcavalcanti Feb 9, 2026
574df7d
small refactor
pjcavalcanti Feb 9, 2026
b4802fe
lread_file that properly handles SUP,INC,ERA
pjcavalcanti Feb 9, 2026
01660f2
fix bug in log: now can handle %log(&L{'a','b'}<>[])
pjcavalcanti Feb 9, 2026
04ea424
prim refactor
pjcavalcanti Feb 9, 2026
1466462
refactor
pjcavalcanti Feb 9, 2026
8b38fb5
read/write_file/byte all dealing with INC/SUP/ERA
pjcavalcanti Feb 9, 2026
eec7d78
WIP: panic and rand dealing with INC/ERA/SUP
pjcavalcanti Feb 9, 2026
8bf01bf
timer primitive
Lorenzobattistela Feb 10, 2026
0861ab8
timer prim tests
Lorenzobattistela Feb 10, 2026
338bc1f
process primitives and tests
Lorenzobattistela Feb 10, 2026
12854b3
refactor
pjcavalcanti Feb 10, 2026
696db05
2 arg prims also deal with INC/ERA/SUP
pjcavalcanti Feb 10, 2026
1437969
env prim
pjcavalcanti Feb 10, 2026
0e17e92
env in hvm4.c
pjcavalcanti Feb 10, 2026
e94bd6d
stream prim
Lorenzobattistela Feb 10, 2026
ecafd16
standardizing responses
Lorenzobattistela Feb 10, 2026
8c038da
updating tests
Lorenzobattistela Feb 10, 2026
d3ed29a
prims: uid/uuid
pjcavalcanti Feb 10, 2026
ce5e76a
stream file
Lorenzobattistela Feb 10, 2026
f98dd25
argv, chdir, cwd
pjcavalcanti Feb 10, 2026
9f3f84e
https prim
Lorenzobattistela Feb 10, 2026
b6fe81d
http prims
Lorenzobattistela Feb 11, 2026
c62920e
tcp prims
Lorenzobattistela Feb 11, 2026
94b6c69
init, docs and tests
Lorenzobattistela Feb 11, 2026
64b675e
prim tests
pjcavalcanti Feb 11, 2026
457d701
fixes
Lorenzobattistela Feb 11, 2026
03e04f0
stdlib
Lorenzobattistela Feb 11, 2026
2c20334
examples
Lorenzobattistela Feb 16, 2026
b97d4e6
stdlib
Lorenzobattistela Feb 16, 2026
41e4b59
stdlib
Lorenzobattistela Feb 16, 2026
2108363
rm
Lorenzobattistela Feb 16, 2026
a73f1fa
prims: use table symbols for async ctor names
Lorenzobattistela Feb 17, 2026
173ce65
prims: switch prim ctor symbols to SYM and add argv echo test
pjcavalcanti Feb 25, 2026
96f2761
Align prim and stdlib constructor shapes with pseudotypes
pjcavalcanti Feb 26, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions clang/hvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <errno.h>
#include <sched.h>
#include <stdatomic.h>
#include <pthread.h>
Expand Down Expand Up @@ -226,6 +227,15 @@ static u64 STEPS_ITRS_LIM = 0;
static u64 STEPS_ROOT_LOC = 0;
static str STEPS_LAST_ITR = NULL;

// Program args (tokens after bare `--` in CLI).
static int PRIM_ARGC = 0;
static char **PRIM_ARGV = NULL;

fn void prim_set_argv(int argc, char **argv) {
PRIM_ARGC = argc;
PRIM_ARGV = argv;
}

// Nick Alphabet
// =============

Expand Down Expand Up @@ -358,10 +368,28 @@ static int PARSE_FORK_SIDE = -1; // -1 = off, 0 = left branch (DP0), 1 =
#include "print/name.c"
#include "print/utf8.c"
#include "prim/register.c"
#include "prim/string.c"
#include "prim/fn/log.c"
#include "prim/fn/log_go_0.c"
#include "prim/fn/log_go_1.c"
#include "prim/fn/log_go_2.c"
#include "prim/fn/panic.c"
#include "prim/fn/argv.c"
#include "prim/fn/env.c"
#include "prim/fn/cwd.c"
#include "prim/fn/chdir.c"
#include "prim/fn/rand.c"
#include "prim/fn/uuid.c"
#include "prim/fn/uid.c"
#include "prim/fn/process/_.c"
#include "prim/fn/stream/_.c"
#include "prim/fn/http/_.c"
#include "prim/fn/tcp/_.c"
#include "prim/fn/read_bytes.c"
#include "prim/fn/write_bytes.c"
#include "prim/fn/read_file.c"
#include "prim/fn/write_file.c"
#include "prim/fn/timer/_.c"
#include "prim/init.c"
#include "print/term.c"

Expand Down
13 changes: 11 additions & 2 deletions clang/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ typedef struct {
u32 ffi_loads_len;
RuntimeFfiLoad ffi_loads[RUNTIME_FFI_MAX];
char *file;
int prog_argc;
char **prog_argv;
} CliOpts;

// Returns the executable basename for help text.
Expand Down Expand Up @@ -154,11 +156,17 @@ fn CliOpts parse_opts(int argc, char **argv) {
.to_c = 0,
.output = NULL,
.ffi_loads_len = 0,
.file = NULL
.file = NULL,
.prog_argc = 0,
.prog_argv = NULL
};

for (int i = 1; i < argc; i++) {
if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) {
if (strcmp(argv[i], "--") == 0) {
opts.prog_argc = argc - (i + 1);
opts.prog_argv = &argv[i + 1];
break;
} else if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) {
opts.help = 1;
} else if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--version") == 0) {
opts.version = 1;
Expand Down Expand Up @@ -330,6 +338,7 @@ int main(int argc, char **argv) {
threads = 1;
}
runtime_init(threads, opts.debug, opts.silent, opts.step_by_step);
prim_set_argv(opts.prog_argc, opts.prog_argv);

// Load FFI libraries before parsing (needed for arity checks and overrides).
int suppress_build_warnings = opts.as_c || opts.to_c || opts.output != NULL;
Expand Down
8 changes: 8 additions & 0 deletions clang/nick/names.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,19 @@ static u32 SYM_SUC = 0;
static u32 SYM_NIL = 0;
static u32 SYM_CON = 0;
static u32 SYM_CHR = 0;
static u32 SYM_U8 = 0;
static u32 SYM_BYT = 0;
static u32 SYM_OK = 0;
static u32 SYM_ERR = 0;

fn void symbols_init(void) {
SYM_ZER = table_find("ZER", 3);
SYM_SUC = table_find("SUC", 3);
SYM_NIL = table_find("NIL", 3);
SYM_CON = table_find("CON", 3);
SYM_CHR = table_find("CHR", 3);
SYM_U8 = table_find("U8", 2);
SYM_BYT = table_find("BYT", 3);
SYM_OK = table_find("OK", 2);
SYM_ERR = table_find("ERR", 3);
}
33 changes: 33 additions & 0 deletions clang/prim/fn/argv.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// %argv(dummy)
// ------------
// List<String> with CLI args passed after bare `--`.
fn Term prim_fn_argv(Term *args) {
(void)args[0];

Term nil = term_new_ctr(SYM_NIL, 0, 0);
Term out = nil;
Term cur = nil;
u8 has_node = 0;

for (int i = 0; i < PRIM_ARGC; i++) {
const char *arg = PRIM_ARGV[i];

Term str = term_string_from_utf8(arg);
Term h_t[2] = {str, nil};
Term node = term_new_ctr(SYM_CON, 2, h_t);

if (!has_node) {
out = node;
has_node = 1;
} else {
heap_set(term_val(cur) + 1, node);
}
cur = node;
}

return out;
}

fn void prim_argv_init(void) {
prim_register("argv", 4, 1, prim_fn_argv);
}
Loading