diff --git a/.gitignore b/.gitignore index 76fe259..7204966 100644 --- a/.gitignore +++ b/.gitignore @@ -11,7 +11,9 @@ build/* build_debug/* build_release/* cmake_install.cmake +compile_commands.json database.sqlite +defines.txt demo_* dist/ downloaded.png diff --git a/src/bytecode.h b/src/bytecode.h index ad816f2..40f9b43 100644 --- a/src/bytecode.h +++ b/src/bytecode.h @@ -15,7 +15,7 @@ * instruction representation (@ref Instruction), and the owning bytecode * container (@ref Bytecode) together with minimal constructor/manipulation * helpers. The concrete execution semantics for each opcode are implemented - * in the VM (see vm.c and vm/* handlers). + * in the VM (see vm.c and vm/some_file.c handlers). */ #ifndef FUN_BYTECODE_H #define FUN_BYTECODE_H diff --git a/src/parser.c b/src/parser.c index d040f88..1494e8a 100644 --- a/src/parser.c +++ b/src/parser.c @@ -38,9 +38,6 @@ * vm_run(&vm, bc); * bytecode_free(bc); * } - * - * @author Johannes Findeisen - * @date 2025-09-16 */ #include "parser.h" diff --git a/src/parser_utils.c b/src/parser_utils.c index e09152c..94cc9bf 100644 --- a/src/parser_utils.c +++ b/src/parser_utils.c @@ -82,7 +82,7 @@ static void skip_line(const char *src, size_t len, size_t *pos) { } /** - * @brief Skip whitespace, then line (//) and block (/* ... */) comments. + * @brief Skip whitespace, then line and block comments. * Continues until the next non-comment, non-whitespace character. */ static void skip_comments(const char *src, size_t len, size_t *pos) { diff --git a/src/vm/arithmetic/add.c b/src/vm/arithmetic/add.c index f8d0090..3da5df2 100644 --- a/src/vm/arithmetic/add.c +++ b/src/vm/arithmetic/add.c @@ -27,9 +27,9 @@ * - Exits with an error if memory allocation fails during string concatenation. * * Example: - * // Bytecode: OP_ADD - * // Stack before: [2, 3] - * // Stack after: [5] + * - Bytecode: OP_ADD + * - Stack before: [2, 3] + * - Stack after: [5] */ case OP_ADD: { diff --git a/src/vm/arithmetic/div.c b/src/vm/arithmetic/div.c index f2c9018..ddce280 100644 --- a/src/vm/arithmetic/div.c +++ b/src/vm/arithmetic/div.c @@ -26,11 +26,11 @@ * - Raises a runtime error on division by zero (both integer and floating cases). * * Example: - * // Bytecode: OP_DIV - * // Stack before: [10, 2] - * // Stack after: [5] - * // Stack before: [5.0, 2] - * // Stack after: [2.5] + * - Bytecode: OP_DIV + * - Stack before: [10, 2] + * - Stack after: [5] + * - Stack before: [5.0, 2] + * - Stack after: [2.5] */ case OP_DIV: { diff --git a/src/vm/arithmetic/mul.c b/src/vm/arithmetic/mul.c index cd63051..95c1f4b 100644 --- a/src/vm/arithmetic/mul.c +++ b/src/vm/arithmetic/mul.c @@ -25,11 +25,11 @@ * - Raises a runtime error and aborts execution if operands are not numeric. * * Example: - * // Bytecode: OP_MUL - * // Stack before: [3, 4] - * // Stack after: [12] - * // Stack before: [2.5, 4] - * // Stack after: [10.0] + * - Bytecode: OP_MUL + * - Stack before: [3, 4] + * - Stack after: [12] + * - Stack before: [2.5, 4] + * - Stack after: [10.0] */ case OP_MUL: { diff --git a/src/vm/arithmetic/sub.c b/src/vm/arithmetic/sub.c index 8ccbeb5..5e62c77 100644 --- a/src/vm/arithmetic/sub.c +++ b/src/vm/arithmetic/sub.c @@ -25,11 +25,11 @@ * - Raises a runtime error and aborts execution if operands are not numeric. * * Example: - * // Bytecode: OP_SUB - * // Stack before: [10, 4] - * // Stack after: [6] - * // Stack before: [10.0, 3] - * // Stack after: [7.0] + * - Bytecode: OP_SUB + * - Stack before: [10, 4] + * - Stack after: [6] + * - Stack before: [10.0, 3] + * - Stack after: [7.0] */ case OP_SUB: { diff --git a/src/vm/arrays/apop.c b/src/vm/arrays/apop.c index ec3cfb6..e6f2f5e 100644 --- a/src/vm/arrays/apop.c +++ b/src/vm/arrays/apop.c @@ -24,9 +24,9 @@ * - Exits with an error if the array is empty. * * Example: - * // Bytecode: OP_APOP - * // Stack before: [[10, 20, 30]] - * // Stack after: [30] + * - Bytecode: OP_APOP + * - Stack before: [[10, 20, 30]] + * - Stack after: [30] */ case OP_APOP: { diff --git a/src/vm/arrays/clear.c b/src/vm/arrays/clear.c index eb3ccfd..47a5c72 100644 --- a/src/vm/arrays/clear.c +++ b/src/vm/arrays/clear.c @@ -24,9 +24,9 @@ * - Exits with a runtime error if the operand is not an array. * Example: - * // Bytecode: OP_CLEAR - * // Stack before: [[10, 20, 30]] - * // Stack after: [0] + * - Bytecode: OP_CLEAR + * - Stack before: [[10, 20, 30]] + * - Stack after: [0] */ case OP_CLEAR: { diff --git a/src/vm/arrays/contains.c b/src/vm/arrays/contains.c index 1e36a75..8722750 100644 --- a/src/vm/arrays/contains.c +++ b/src/vm/arrays/contains.c @@ -23,9 +23,9 @@ * - Exits with an error if the array is of the wrong type. * * Example: - * // Bytecode: OP_CONTAINS - * // Stack before: [20, [10, 20, 30]] - * // Stack after: [1] + * - Bytecode: OP_CONTAINS + * - Stack before: [20, [10, 20, 30]] + * - Stack after: [1] */ case OP_CONTAINS: { diff --git a/src/vm/arrays/enumerate.c b/src/vm/arrays/enumerate.c index a42c129..aa4cb56 100644 --- a/src/vm/arrays/enumerate.c +++ b/src/vm/arrays/enumerate.c @@ -23,9 +23,9 @@ * - Exits with an error if the array is of the wrong type. * * Example: - * // Bytecode: OP_ENUMERATE - * // Stack before: [[10, 20, 30]] - * // Stack after: [[[0, 10], [1, 20], [2, 30]]] + * - Bytecode: OP_ENUMERATE + * - Stack before: [[10, 20, 30]] + * - Stack after: [[[0, 10], [1, 20], [2, 30]]] */ case OP_ENUMERATE: { diff --git a/src/vm/arrays/index_get.c b/src/vm/arrays/index_get.c index 52a460b..ce02832 100644 --- a/src/vm/arrays/index_get.c +++ b/src/vm/arrays/index_get.c @@ -25,9 +25,9 @@ * is of the wrong type, or if the index is out of bounds. * * Example: - * // Bytecode: OP_INDEX_GET - * // Stack before: [1, [10, 20, 30]] - * // Stack after: [20] + * - Bytecode: OP_INDEX_GET + * - Stack before: [1, [10, 20, 30]] + * - Stack after: [20] */ case OP_INDEX_GET: { diff --git a/src/vm/arrays/index_of.c b/src/vm/arrays/index_of.c index f1bb38f..031e835 100644 --- a/src/vm/arrays/index_of.c +++ b/src/vm/arrays/index_of.c @@ -23,9 +23,9 @@ * - Exits with an error if the array is of the wrong type. * * Example: - * // Bytecode: OP_INDEX_OF - * // Stack before: [20, [10, 20, 30]] - * // Stack after: [1] + * - Bytecode: OP_INDEX_OF + * - Stack before: [20, [10, 20, 30]] + * - Stack after: [1] */ case OP_INDEX_OF: { diff --git a/src/vm/arrays/index_set.c b/src/vm/arrays/index_set.c index 2691ddd..06aa671 100644 --- a/src/vm/arrays/index_set.c +++ b/src/vm/arrays/index_set.c @@ -24,9 +24,9 @@ * is of the wrong type, or if the index is out of bounds. * * Example: - * // Bytecode: OP_INDEX_SET - * // Stack before: [42, 1, [10, 20, 30]] - * // Stack after: [[10, 42, 30]] + * - Bytecode: OP_INDEX_SET + * - Stack before: [42, 1, [10, 20, 30]] + * - Stack after: [[10, 42, 30]] */ case OP_INDEX_SET: { diff --git a/src/vm/arrays/insert.c b/src/vm/arrays/insert.c index 49beed7..6d7ee71 100644 --- a/src/vm/arrays/insert.c +++ b/src/vm/arrays/insert.c @@ -25,9 +25,9 @@ * - Exits with an error if memory allocation fails during the insertion. * * Example: - * // Bytecode: OP_INSERT - * // Stack before: [42, 1, [10, 20, 30]] - * // Stack after: [4] + * - Bytecode: OP_INSERT + * - Stack before: [42, 1, [10, 20, 30]] + * - Stack after: [4] */ case OP_INSERT: { diff --git a/src/vm/arrays/join.c b/src/vm/arrays/join.c index a5031ef..52eb118 100644 --- a/src/vm/arrays/join.c +++ b/src/vm/arrays/join.c @@ -24,9 +24,9 @@ * - Exits with an error if the array or separator is of the wrong type. * * Example: - * // Bytecode: OP_JOIN - * // Stack before: [", ", ["a", "b", "c"]] - * // Stack after: ["a, b, c"] + * - Bytecode: OP_JOIN + * - Stack before: [", ", ["a", "b", "c"]] + * - Stack after: ["a, b, c"] */ case OP_JOIN: { diff --git a/src/vm/arrays/make_array.c b/src/vm/arrays/make_array.c index b454f2b..b775d35 100644 --- a/src/vm/arrays/make_array.c +++ b/src/vm/arrays/make_array.c @@ -24,9 +24,9 @@ * - Exits with an error if `n` is invalid or if memory allocation fails. * * Example: - * // Bytecode: OP_MAKE_ARRAY 3 - * // Stack before: [1, 2, 3] - * // Stack after: [[1, 2, 3]] + * - Bytecode: OP_MAKE_ARRAY 3 + * - Stack before: [1, 2, 3] + * - Stack after: [[1, 2, 3]] */ case OP_MAKE_ARRAY: { diff --git a/src/vm/arrays/push.c b/src/vm/arrays/push.c index 2dd74c9..7d7c45c 100644 --- a/src/vm/arrays/push.c +++ b/src/vm/arrays/push.c @@ -25,9 +25,9 @@ * - Exits with a runtime error if memory allocation fails. * * Example: - * // Bytecode: OP_PUSH - * // Stack before: [42, [10, 20, 30]] - * // Stack after: [4] + * - Bytecode: OP_PUSH + * - Stack before: [42, [10, 20, 30]] + * - Stack after: [4] */ case OP_PUSH: { diff --git a/src/vm/arrays/remove.c b/src/vm/arrays/remove.c index 10da29c..df0fed3 100644 --- a/src/vm/arrays/remove.c +++ b/src/vm/arrays/remove.c @@ -25,9 +25,9 @@ * - Exits with a runtime error if the index is out of bounds. * * Example: - * // Bytecode: OP_REMOVE - * // Stack before: [1, [10, 20, 30]] - * // Stack after: [20] + * - Bytecode: OP_REMOVE + * - Stack before: [1, [10, 20, 30]] + * - Stack after: [20] */ case OP_REMOVE: { diff --git a/src/vm/arrays/set.c b/src/vm/arrays/set.c index bf0e4a5..44c7633 100644 --- a/src/vm/arrays/set.c +++ b/src/vm/arrays/set.c @@ -25,9 +25,9 @@ * - Exits with a runtime error if the index is out of bounds. * * Example: - * // Bytecode: OP_SET - * // Stack before: [42, 1, [10, 20, 30]] - * // Stack after: [42] + * - Bytecode: OP_SET + * - Stack before: [42, 1, [10, 20, 30]] + * - Stack after: [42] */ case OP_SET: { diff --git a/src/vm/arrays/slice.c b/src/vm/arrays/slice.c index e057413..e6aaae8 100644 --- a/src/vm/arrays/slice.c +++ b/src/vm/arrays/slice.c @@ -24,9 +24,9 @@ * - Handles negative indices and out-of-bounds cases gracefully * * Example: - * // Bytecode: OP_SLICE - * // Stack before: [3, 1, [10,20,30,40]] - * // Stack after: [[20,30]] + * - Bytecode: OP_SLICE + * - Stack before: [3, 1, [10,20,30,40]] + * - Stack after: [[20,30]] */ case OP_SLICE: { diff --git a/src/vm/arrays/zip.c b/src/vm/arrays/zip.c index 3a284df..a778689 100644 --- a/src/vm/arrays/zip.c +++ b/src/vm/arrays/zip.c @@ -24,9 +24,9 @@ * - Exits with error if arguments aren't arrays * * Example: - * // Bytecode: OP_ZIP - * // Stack before: [[1,2], ['a','b']] - * // Stack after: [[[1,'a'], [2,'b']]] + * - Bytecode: OP_ZIP + * - Stack before: [[1,2], ['a','b']] + * - Stack after: [[[1,'a'], [2,'b']]] */ case OP_ZIP: { diff --git a/src/vm/core/dup.c b/src/vm/core/dup.c index d6912cc..fc6c95f 100644 --- a/src/vm/core/dup.c +++ b/src/vm/core/dup.c @@ -22,9 +22,9 @@ * - Exits with an error if the stack is empty. * * Example: - * // Bytecode: OP_DUP - * // Stack before: [42] - * // Stack after: [42, 42] + * - Bytecode: OP_DUP + * - Stack before: [42] + * - Stack after: [42, 42] */ case OP_DUP: { diff --git a/src/vm/core/halt.c b/src/vm/core/halt.c index d53a37e..3c8f947 100644 --- a/src/vm/core/halt.c +++ b/src/vm/core/halt.c @@ -18,9 +18,9 @@ * - Stops the VM execution immediately. * * Example: - * // Bytecode: OP_HALT - * // Stack before: [42] - * // Stack after: [42] + * - Bytecode: OP_HALT + * - Stack before: [42] + * - Stack after: [42] */ case OP_HALT: diff --git a/src/vm/core/load_global.c b/src/vm/core/load_global.c index 6c873d8..114855f 100644 --- a/src/vm/core/load_global.c +++ b/src/vm/core/load_global.c @@ -22,9 +22,9 @@ * - Exits with an error if the index is out of bounds. * * Example: - * // Bytecode: OP_LOAD_GLOBAL 0 - * // Stack before: [] - * // Stack after: [global_value] + * - Bytecode: OP_LOAD_GLOBAL 0 + * - Stack before: [] + * - Stack after: [global_value] */ case OP_LOAD_GLOBAL: { diff --git a/src/vm/core/load_local.c b/src/vm/core/load_local.c index b12fcd1..83b5eb2 100644 --- a/src/vm/core/load_local.c +++ b/src/vm/core/load_local.c @@ -22,9 +22,9 @@ * - Exits with an error if the index is out of bounds. * * Example: - * // Bytecode: OP_LOAD_LOCAL 0 - * // Stack before: [] - * // Stack after: [local_value] + * - Bytecode: OP_LOAD_LOCAL 0 + * - Stack before: [] + * - Stack after: [local_value] */ case OP_LOAD_LOCAL: { diff --git a/src/vm/core/nop.c b/src/vm/core/nop.c index eb2331e..f0034e3 100644 --- a/src/vm/core/nop.c +++ b/src/vm/core/nop.c @@ -18,9 +18,9 @@ * - Does nothing. * * Example: - * // Bytecode: OP_NOP - * // Stack before: [42] - * // Stack after: [42] + * - Bytecode: OP_NOP + * - Stack before: [42] + * - Stack after: [42] */ case OP_NOP: diff --git a/src/vm/core/pop.c b/src/vm/core/pop.c index 891b81e..5cc3d02 100644 --- a/src/vm/core/pop.c +++ b/src/vm/core/pop.c @@ -20,9 +20,9 @@ * - Exits with an error if the stack is empty. * * Example: - * // Bytecode: OP_POP - * // Stack before: [42] - * // Stack after: [] + * - Bytecode: OP_POP + * - Stack before: [42] + * - Stack after: [] */ case OP_POP: { diff --git a/src/vm/core/return.c b/src/vm/core/return.c index 32501eb..de442c5 100644 --- a/src/vm/core/return.c +++ b/src/vm/core/return.c @@ -23,9 +23,9 @@ * - Exits with an error if the frame stack is empty. * * Example: - * // Bytecode: OP_RETURN - * // Stack before: [42] - * // Stack after: [42] + * - Bytecode: OP_RETURN + * - Stack before: [42] + * - Stack after: [42] */ case OP_RETURN: { diff --git a/src/vm/core/store_global.c b/src/vm/core/store_global.c index c20b52e..e02deaf 100644 --- a/src/vm/core/store_global.c +++ b/src/vm/core/store_global.c @@ -22,9 +22,9 @@ * - Exits with an error if the index is out of bounds. * * Example: - * // Bytecode: OP_STORE_GLOBAL 0 - * // Stack before: [42] - * // Stack after: [] + * - Bytecode: OP_STORE_GLOBAL 0 + * - Stack before: [42] + * - Stack after: [] */ case OP_STORE_GLOBAL: { diff --git a/src/vm/core/store_local.c b/src/vm/core/store_local.c index 776b713..c731854 100644 --- a/src/vm/core/store_local.c +++ b/src/vm/core/store_local.c @@ -22,9 +22,9 @@ * - Exits with an error if the index is out of bounds. * * Example: - * // Bytecode: OP_STORE_LOCAL 0 - * // Stack before: [42] - * // Stack after: [] + * - Bytecode: OP_STORE_LOCAL 0 + * - Stack before: [42] + * - Stack after: [] */ case OP_STORE_LOCAL: { diff --git a/src/vm/echo.c b/src/vm/echo.c index 1aa041e..148c9aa 100644 --- a/src/vm/echo.c +++ b/src/vm/echo.c @@ -21,8 +21,6 @@ * - Pushes: (none) */ -/* Implements OP_ECHO: print top-of-stack value without trailing newline. */ - case OP_ECHO: { Value v = pop_value(vm); Value snap = deep_copy_value(&v); diff --git a/src/vm/io/input_line.c b/src/vm/io/input_line.c index d6cfb86..66f5e9e 100644 --- a/src/vm/io/input_line.c +++ b/src/vm/io/input_line.c @@ -43,10 +43,10 @@ * - EOF before any character yields an empty string. * * Example: - * // Bytecode: [optional PUSH prompt], OP_INPUT_LINE(operand) - * // operand bit0=1 (has prompt), bit1=2 (hidden) can be combined - * // Stack before (bit0=1): ["Enter password: "] - * // Stack after: ["user-typed-line"] + * - Bytecode: [optional PUSH prompt], OP_INPUT_LINE(operand) + * - operand bit0=1 (has prompt), bit1=2 (hidden) can be combined + * - Stack before (bit0=1): ["Enter password: "] + * - Stack after: ["user-typed-line"] */ case OP_INPUT_LINE: { diff --git a/src/vm/io/read_file.c b/src/vm/io/read_file.c index 8813368..f7b5ed7 100644 --- a/src/vm/io/read_file.c +++ b/src/vm/io/read_file.c @@ -23,9 +23,9 @@ * - Exits with an error if the file path is invalid or the file cannot be read. * * Example: - * // Bytecode: OP_READ_FILE - * // Stack before: ["file.txt"] - * // Stack after: ["file contents"] + * - Bytecode: OP_READ_FILE + * - Stack before: ["file.txt"] + * - Stack after: ["file contents"] */ case OP_READ_FILE: { diff --git a/src/vm/io/write_file.c b/src/vm/io/write_file.c index e77812f..bc99e0d 100644 --- a/src/vm/io/write_file.c +++ b/src/vm/io/write_file.c @@ -23,9 +23,9 @@ * - Exits with an error if the file path is invalid or the file cannot be written. * * Example: - * // Bytecode: OP_WRITE_FILE - * // Stack before: ["file.txt", "data"] - * // Stack after: [1] + * - Bytecode: OP_WRITE_FILE + * - Stack before: ["file.txt", "data"] + * - Stack after: [1] */ case OP_WRITE_FILE: { diff --git a/src/vm/len.c b/src/vm/len.c index 06583f0..78a6eb7 100644 --- a/src/vm/len.c +++ b/src/vm/len.c @@ -23,12 +23,9 @@ * - Exits with an error if the operand is not an array or string. * * Example: - * // Bytecode: OP_LEN - * // Stack before: ["hello"] - * // Stack after: [5] - * - * @author Johannes Findeisen - * @date 2025-09-16 + * - Bytecode: OP_LEN + * - Stack before: ["hello"] + * - Stack after: [5] */ case OP_LEN: { diff --git a/src/vm/logic/and.c b/src/vm/logic/and.c index ddb6123..3e0449f 100644 --- a/src/vm/logic/and.c +++ b/src/vm/logic/and.c @@ -23,9 +23,9 @@ * - Exits with an error if the operands are not boolean values. * * Example: - * // Bytecode: OP_AND - * // Stack before: [1, 0] - * // Stack after: [0] + * - Bytecode: OP_AND + * - Stack before: [1, 0] + * - Stack after: [0] */ case OP_AND: { diff --git a/src/vm/logic/eq.c b/src/vm/logic/eq.c index 715a031..4f92022 100644 --- a/src/vm/logic/eq.c +++ b/src/vm/logic/eq.c @@ -23,9 +23,9 @@ * - Exits with an error if the operands are of incompatible types. * * Example: - * // Bytecode: OP_EQ - * // Stack before: [42, 42] - * // Stack after: [1] + * - Bytecode: OP_EQ + * - Stack before: [42, 42] + * - Stack after: [1] */ case OP_EQ: { diff --git a/src/vm/logic/gt.c b/src/vm/logic/gt.c index 3d9691f..9ef2c4f 100644 --- a/src/vm/logic/gt.c +++ b/src/vm/logic/gt.c @@ -23,10 +23,9 @@ * - Exits with an error if the operands are of incompatible types. * * Example: - * ```c - * // Bytecode: OP_GT - * // Stack before: [42, 10] - * // Stack after: [1] + * - Bytecode: OP_GT + * - Stack before: [42, 10] + * - Stack after: [1] */ case OP_GT: { diff --git a/src/vm/logic/gte.c b/src/vm/logic/gte.c index 1121777..67b6c0c 100644 --- a/src/vm/logic/gte.c +++ b/src/vm/logic/gte.c @@ -23,9 +23,9 @@ * - Exits with an error if the operands are of incompatible types. * * Example: - * // Bytecode: OP_GTE - * // Stack before: [42, 42] - * // Stack after: [1] + * - Bytecode: OP_GTE + * - Stack before: [42, 42] + * - Stack after: [1] */ case OP_GTE: { diff --git a/src/vm/logic/lt.c b/src/vm/logic/lt.c index 103f334..6c52085 100644 --- a/src/vm/logic/lt.c +++ b/src/vm/logic/lt.c @@ -23,9 +23,9 @@ * - Exits with an error if the operands are of incompatible types. * * Example: - * // Bytecode: OP_LT - * // Stack before: [10, 42] - * // Stack after: [1] + * - Bytecode: OP_LT + * - Stack before: [10, 42] + * - Stack after: [1] */ case OP_LT: { diff --git a/src/vm/logic/lte.c b/src/vm/logic/lte.c index 721d000..2b9dbf1 100644 --- a/src/vm/logic/lte.c +++ b/src/vm/logic/lte.c @@ -23,9 +23,9 @@ * - Exits with an error if the operands are of incompatible types. * * Example: - * // Bytecode: OP_LTE - * // Stack before: [42, 42] - * // Stack after: [1] + * - Bytecode: OP_LTE + * - Stack before: [42, 42] + * - Stack after: [1] */ case OP_LTE: { diff --git a/src/vm/logic/neq.c b/src/vm/logic/neq.c index 92720a9..8b2b7f2 100644 --- a/src/vm/logic/neq.c +++ b/src/vm/logic/neq.c @@ -23,9 +23,9 @@ * - Exits with an error if the operands are of incompatible types. * * Example: - * // Bytecode: OP_NEQ - * // Stack before: [42, 10] - * // Stack after: [1] + * - Bytecode: OP_NEQ + * - Stack before: [42, 10] + * - Stack after: [1] */ case OP_NEQ: { diff --git a/src/vm/logic/not.c b/src/vm/logic/not.c index 8a78370..133c9e3 100644 --- a/src/vm/logic/not.c +++ b/src/vm/logic/not.c @@ -23,9 +23,9 @@ * - Exits with an error if the operand is not a boolean value. * * Example: - * // Bytecode: OP_NOT - * // Stack before: [0] - * // Stack after: [1] + * - Bytecode: OP_NOT + * - Stack before: [0] + * - Stack after: [1] */ case OP_NOT: { diff --git a/src/vm/logic/or.c b/src/vm/logic/or.c index 6c89029..8d1b888 100644 --- a/src/vm/logic/or.c +++ b/src/vm/logic/or.c @@ -23,9 +23,9 @@ * - Exits with an error if the operands are not boolean values. * * Example: - * // Bytecode: OP_OR - * // Stack before: [1, 0] - * // Stack after: [1] + * - Bytecode: OP_OR + * - Stack before: [1, 0] + * - Stack after: [1] */ case OP_OR: { diff --git a/src/vm/maps/keys.c b/src/vm/maps/keys.c index 074342e..bdc75ad 100644 --- a/src/vm/maps/keys.c +++ b/src/vm/maps/keys.c @@ -23,9 +23,9 @@ * - Exits with an error if the map is of the wrong type. * * Example: - * // Bytecode: OP_KEYS - * // Stack before: [{"a": 1, "b": 2}] - * // Stack after: [["a", "b"]] + * - Bytecode: OP_KEYS + * - Stack before: [{"a": 1, "b": 2}] + * - Stack after: [["a", "b"]] */ case OP_KEYS: { diff --git a/src/vm/maps/make_map.c b/src/vm/maps/make_map.c index b39f433..11af895 100644 --- a/src/vm/maps/make_map.c +++ b/src/vm/maps/make_map.c @@ -25,9 +25,9 @@ * or if map construction fails. * * Example: - * // Bytecode: OP_MAKE_MAP 2 - * // Stack before: ["key1", 1, "key2", 2] - * // Stack after: [{"key1": 1, "key2": 2}] + * - Bytecode: OP_MAKE_MAP 2 + * - Stack before: ["key1", 1, "key2", 2] + * - Stack after: [{"key1": 1, "key2": 2}] */ case OP_MAKE_MAP: { diff --git a/src/vm/maps/values.c b/src/vm/maps/values.c index 3a2838a..34e405f 100644 --- a/src/vm/maps/values.c +++ b/src/vm/maps/values.c @@ -23,9 +23,9 @@ * - Exits with an error if the map is of the wrong type. * * Example: - * // Bytecode: OP_VALUES - * // Stack before: [{"a": 1, "b": 2}] - * // Stack after: [[1, 2]] + * - Bytecode: OP_VALUES + * - Stack before: [{"a": 1, "b": 2}] + * - Stack after: [[1, 2]] */ case OP_VALUES: { diff --git a/src/vm/math/abs.c b/src/vm/math/abs.c index 537a998..88b2261 100644 --- a/src/vm/math/abs.c +++ b/src/vm/math/abs.c @@ -20,9 +20,6 @@ * * Error Handling: * - Exits if not integer - * - * @author Johannes Findeisen - * @date 2025-10-16 */ case OP_ABS: { diff --git a/src/vm/math/clamp.c b/src/vm/math/clamp.c index c155596..e6cc88f 100644 --- a/src/vm/math/clamp.c +++ b/src/vm/math/clamp.c @@ -21,9 +21,6 @@ * Error Handling: * - Exits if arguments wrong types * - Handles hi < lo case - * - * @author Johannes Findeisen - * @date 2025-10-16 */ case OP_CLAMP: { diff --git a/src/vm/math/max.c b/src/vm/math/max.c index 7b8913a..04421c5 100644 --- a/src/vm/math/max.c +++ b/src/vm/math/max.c @@ -23,9 +23,9 @@ * - Exits with an error if the operands are not integers. * * Example: - * // Bytecode: OP_MAX - * // Stack before: [10, 42] - * // Stack after: [42] + * - Bytecode: OP_MAX + * - Stack before: [10, 42] + * - Stack after: [42] */ case OP_MAX: { diff --git a/src/vm/math/min.c b/src/vm/math/min.c index 4e0086b..fcef72a 100644 --- a/src/vm/math/min.c +++ b/src/vm/math/min.c @@ -23,9 +23,9 @@ * - Exits with an error if the operands are not integers. * * Example: - * // Bytecode: OP_MIN - * // Stack before: [10, 42] - * // Stack after: [10] + * - Bytecode: OP_MIN + * - Stack before: [10, 42] + * - Stack after: [10] */ case OP_MIN: { diff --git a/src/vm/math/mod.c b/src/vm/math/mod.c index e5213c6..e91d757 100644 --- a/src/vm/math/mod.c +++ b/src/vm/math/mod.c @@ -24,9 +24,9 @@ * - Exits with an error if the second operand is zero. * * Example: - * // Bytecode: OP_MOD - * // Stack before: [10, 3] - * // Stack after: [1] + * - Bytecode: OP_MOD + * - Stack before: [10, 3] + * - Stack after: [1] */ case OP_MOD: { diff --git a/src/vm/math/pow.c b/src/vm/math/pow.c index a2c9b16..a217c00 100644 --- a/src/vm/math/pow.c +++ b/src/vm/math/pow.c @@ -23,9 +23,9 @@ * - Exits with an error if the operands are not integers. * * Example: - * // Bytecode: OP_POW - * // Stack before: [2, 3] - * // Stack after: [8] + * - Bytecode: OP_POW + * - Stack before: [2, 3] + * - Stack after: [8] */ case OP_POW: { diff --git a/src/vm/math/random_int.c b/src/vm/math/random_int.c index 4b7811d..25574e2 100644 --- a/src/vm/math/random_int.c +++ b/src/vm/math/random_int.c @@ -25,9 +25,9 @@ * - Exits with an error if the lower bound is greater than the upper bound. * * Example: - * // Bytecode: OP_RANDOM_INT - * // Stack before: [10, 1] - * // Stack after: [7] + * - Bytecode: OP_RANDOM_INT + * - Stack before: [10, 1] + * - Stack after: [7] */ case OP_RANDOM_INT: { diff --git a/src/vm/math/random_seed.c b/src/vm/math/random_seed.c index c59df89..714f4cf 100644 --- a/src/vm/math/random_seed.c +++ b/src/vm/math/random_seed.c @@ -22,9 +22,9 @@ * - Exits with an error if the seed is not an integer. * * Example: - * // Bytecode: OP_RANDOM_SEED - * // Stack before: [42] - * // Stack after: [] + * - Bytecode: OP_RANDOM_SEED + * - Stack before: [42] + * - Stack after: [] */ case OP_RANDOM_SEED: { diff --git a/src/vm/os/clock_mono_ms.c b/src/vm/os/clock_mono_ms.c index be09e0b..b2aa720 100644 --- a/src/vm/os/clock_mono_ms.c +++ b/src/vm/os/clock_mono_ms.c @@ -11,8 +11,10 @@ * @file clock_mono_ms.c * @brief Implements OP_CLOCK_MONO_MS to push monotonic clock in ms. * - * Stack before: [] - * Stack after: [int ms] + * Example: + * - OP_CLOCK_MONO_MS + * - Stack before: [] + * - Stack after: [int ms] */ #include diff --git a/src/vm/pcsc/connect.c b/src/vm/pcsc/connect.c index 3f79293..5712f67 100644 --- a/src/vm/pcsc/connect.c +++ b/src/vm/pcsc/connect.c @@ -14,9 +14,7 @@ * Connects to a smart card in the specified reader using an existing PC/SC * context. On success, allocates/returns a card handle id from the internal * registry. When PCSC support is disabled at build time, this opcode returns 0. - */ - -/** + * * OP_PCSC_CONNECT: (ctx_id:int, reader_name:any) -> int * * - Pops: reader_name (converted to string), then ctx_id. diff --git a/src/vm/pcsc/disconnect.c b/src/vm/pcsc/disconnect.c index 4c01da2..0f62e3a 100644 --- a/src/vm/pcsc/disconnect.c +++ b/src/vm/pcsc/disconnect.c @@ -14,9 +14,7 @@ * Disconnects a previously connected smart-card handle and frees the * corresponding registry slot. When PCSC support is disabled at build time, * this opcode returns 0 after consuming its argument. - */ - -/** + * * OP_PCSC_DISCONNECT: (handle_id:int) -> int * * - Pops: handle_id. @@ -24,6 +22,10 @@ * - Notes: Uses SCardDisconnect(..., SCARD_LEAVE_CARD). */ +/** + + */ + /* PCSC disconnect */ case OP_PCSC_DISCONNECT: { #ifdef FUN_WITH_PCSC diff --git a/src/vm/pcsc/establish.c b/src/vm/pcsc/establish.c index d6af7c2..a5c0f59 100644 --- a/src/vm/pcsc/establish.c +++ b/src/vm/pcsc/establish.c @@ -15,9 +15,7 @@ * and registers it in the internal PCSC context registry when FUN_WITH_PCSC * is enabled. Returns the allocated context id on success, or 0 on failure. * When PCSC support is disabled at build time, this opcode returns 0. - */ - -/** + * * OP_PCSC_ESTABLISH: () -> int * * - Returns: context id (>0) on success; 0 on error or when disabled. diff --git a/src/vm/pcsc/list_readers.c b/src/vm/pcsc/list_readers.c index 8cbf7e1..f6ff1f7 100644 --- a/src/vm/pcsc/list_readers.c +++ b/src/vm/pcsc/list_readers.c @@ -14,9 +14,7 @@ * Lists available PC/SC reader names for a given context. On success returns * an array of strings. When PCSC support is disabled at build time, returns an * empty array after consuming its argument to keep the stack balanced. - */ - -/** + * * OP_PCSC_LIST_READERS: (ctx_id:int) -> array * * - Pops: ctx_id. diff --git a/src/vm/pcsc/release.c b/src/vm/pcsc/release.c index 72d2c58..179e27f 100644 --- a/src/vm/pcsc/release.c +++ b/src/vm/pcsc/release.c @@ -14,9 +14,7 @@ * Releases a previously established PC/SC context and frees its registry slot. * When PCSC support is disabled at build time, this opcode returns 0 after * consuming its argument. - */ - -/** + * * OP_PCSC_RELEASE: (ctx_id:int) -> int * * - Pops: ctx_id. diff --git a/src/vm/pcsc/transmit.c b/src/vm/pcsc/transmit.c index 5d37368..f1642fa 100644 --- a/src/vm/pcsc/transmit.c +++ b/src/vm/pcsc/transmit.c @@ -15,9 +15,7 @@ * handle. Returns a map with the response bytes and status words. When PCSC * support is disabled at build time, consumes its arguments and returns a map * with code = -2. - */ - -/** + * * OP_PCSC_TRANSMIT: (handle_id:int, apdu:array) -> map * * - Pops: apdu array, then handle_id. diff --git a/src/vm/print.c b/src/vm/print.c index 0c4a78b..ba4e79e 100644 --- a/src/vm/print.c +++ b/src/vm/print.c @@ -19,12 +19,9 @@ * - Prints the value to the output buffer. * * Example: - * // Bytecode: OP_PRINT - * // Stack before: [42] - * // Stack after: [] - * - * @author Johannes Findeisen - * @date 2025-09-16 + * - Bytecode: OP_PRINT + * - Stack before: [42] + * - Stack after: [] */ case OP_PRINT: { diff --git a/src/vm/rust/get_sp.c b/src/vm/rust/get_sp.c index 09c3b42..6cd864c 100644 --- a/src/vm/rust/get_sp.c +++ b/src/vm/rust/get_sp.c @@ -14,9 +14,7 @@ * Delegates to a Rust helper to read the VM's current stack pointer (sp). * When Rust support is disabled, this raises a runtime error and pushes -1 to * signal unavailability. - */ - -/** + * * OP_RUST_GET_SP: () -> int | Nil * * Behavior (FUN_WITH_RUST=ON): @@ -28,6 +26,7 @@ * - Raises a runtime error indicating missing Rust support. * - Pushes integer -1 as a sentinel value. */ + case OP_RUST_GET_SP: { #ifdef FUN_WITH_RUST extern int fun_op_rget_sp(VM * vm); diff --git a/src/vm/rust/hello.c b/src/vm/rust/hello.c index 8cfaa04..c3dc799 100644 --- a/src/vm/rust/hello.c +++ b/src/vm/rust/hello.c @@ -16,9 +16,7 @@ * Rust and pushes it as a VAL_STRING onto the VM stack. When Rust support is * disabled, a runtime error is raised and Nil is pushed to keep stack * consistency. - */ - -/** + * * OP_RUST_HELLO: () -> string | Nil * * Behavior (FUN_WITH_RUST=ON): diff --git a/src/vm/rust/hello_args.c b/src/vm/rust/hello_args.c index 09f9703..104f4ce 100644 --- a/src/vm/rust/hello_args.c +++ b/src/vm/rust/hello_args.c @@ -15,9 +15,6 @@ * string, calls into Rust to print/log it, and pushes Nil. When Rust support is * disabled, the argument is still popped and freed to keep the stack sane, * then Nil is pushed after raising an error message. - */ - -/** * OP_RUST_HELLO_ARGS: (msg:any) -> Nil * * Behavior (FUN_WITH_RUST=ON): @@ -31,6 +28,7 @@ * - Raises a runtime error indicating missing Rust support. * - Pushes Nil. */ + case OP_RUST_HELLO_ARGS: { #ifdef FUN_WITH_RUST Value vmsg = pop_value(vm); diff --git a/src/vm/rust/hello_args_return.c b/src/vm/rust/hello_args_return.c index 8b06521..7b73247 100644 --- a/src/vm/rust/hello_args_return.c +++ b/src/vm/rust/hello_args_return.c @@ -15,9 +15,7 @@ * converts it to a C string, passes it to Rust, and pushes back the string * returned by Rust. If Rust returns NULL or Rust support is disabled, Nil is * pushed. - */ - -/** + * * OP_RUST_HELLO_ARGS_RETURN: (msg:any) -> string | Nil * * Behavior (FUN_WITH_RUST=ON): @@ -33,6 +31,7 @@ * - Raises a runtime error indicating missing Rust support. * - Pushes Nil. */ + case OP_RUST_HELLO_ARGS_RETURN: { #ifdef FUN_WITH_RUST Value vmsg = pop_value(vm); diff --git a/src/vm/rust/set_exit.c b/src/vm/rust/set_exit.c index 27622e0..cd24a9e 100644 --- a/src/vm/rust/set_exit.c +++ b/src/vm/rust/set_exit.c @@ -15,9 +15,7 @@ * vm.exit_code. Pushes Nil afterwards. When Rust support is disabled, the * argument is still popped/freed, a runtime error is raised, and Nil is * pushed to maintain stack discipline. - */ - -/** + * * OP_RUST_SET_EXIT: (code:int) -> Nil * * Behavior (FUN_WITH_RUST=ON): @@ -30,6 +28,7 @@ * - Raises a runtime error indicating missing Rust support. * - Pushes Nil. */ + case OP_RUST_SET_EXIT: { #ifdef FUN_WITH_RUST extern int fun_op_rset_exit(VM * vm); diff --git a/src/vm/sqlite/close.c b/src/vm/sqlite/close.c index 3b5ecc7..f31312f 100644 --- a/src/vm/sqlite/close.c +++ b/src/vm/sqlite/close.c @@ -13,11 +13,10 @@ * * Closes a registered SQLite database handle and unregisters it when * FUN_WITH_SQLITE is enabled. No-op when SQLite support is disabled. - */ - -/** + * * OP_SQLITE_CLOSE: (handle:int) -> Nil */ + case OP_SQLITE_CLOSE: { #ifdef FUN_WITH_SQLITE Value vh = pop_value(vm); diff --git a/src/vm/sqlite/exec.c b/src/vm/sqlite/exec.c index 9ebff9d..3f64c6b 100644 --- a/src/vm/sqlite/exec.c +++ b/src/vm/sqlite/exec.c @@ -13,11 +13,10 @@ * * Executes a SQL statement against an open SQLite handle when * FUN_WITH_SQLITE is enabled. Returns the SQLite result code. - */ - -/** + * * OP_SQLITE_EXEC: (handle:int, sql:string) -> int rc (0=OK) */ + case OP_SQLITE_EXEC: { #ifdef FUN_WITH_SQLITE Value vsql = pop_value(vm); diff --git a/src/vm/sqlite/open.c b/src/vm/sqlite/open.c index ff71228..26ec63b 100644 --- a/src/vm/sqlite/open.c +++ b/src/vm/sqlite/open.c @@ -13,11 +13,10 @@ * * Opens a SQLite database and registers a handle when FUN_WITH_SQLITE is * enabled. On failure or when SQLite support is disabled, pushes 0. - */ - -/** + * * OP_SQLITE_OPEN: (path:string) -> handle:int (>0) or 0 on error */ + case OP_SQLITE_OPEN: { #ifdef FUN_WITH_SQLITE Value vpath = pop_value(vm); diff --git a/src/vm/sqlite/query.c b/src/vm/sqlite/query.c index 1f6fe09..3b4d960 100644 --- a/src/vm/sqlite/query.c +++ b/src/vm/sqlite/query.c @@ -13,11 +13,10 @@ * * Prepares and steps through a SQLite statement to produce an array of row * maps when FUN_WITH_SQLITE is enabled. Returns an empty array otherwise. - */ - -/** + * * OP_SQLITE_QUERY: (handle:int, sql:string) -> array> */ + case OP_SQLITE_QUERY: { #ifdef FUN_WITH_SQLITE Value vsql = pop_value(vm); diff --git a/src/vm/strings/find.c b/src/vm/strings/find.c index 6a1248d..3fdb60d 100644 --- a/src/vm/strings/find.c +++ b/src/vm/strings/find.c @@ -24,12 +24,9 @@ * - Exits with an error if the operands are not strings. * * Example: - * // Bytecode: OP_FIND - * // Stack before: ["world", "hello world"] - * // Stack after: [6] - * - * @author Johannes Findeisen - * @date 2025-10-16 + * - Bytecode: OP_FIND + * - Stack before: ["world", "hello world"] + * - Stack after: [6] */ case OP_FIND: { diff --git a/src/vm/strings/regex_match.c b/src/vm/strings/regex_match.c index d0cab8f..1a785f1 100644 --- a/src/vm/strings/regex_match.c +++ b/src/vm/strings/regex_match.c @@ -31,6 +31,7 @@ * - pattern = "[a-z]+", input = "hello" -> 1 * - pattern = "[a-z]+", input = "hello!" -> 0 (not a full match) */ + /* Regex full-match opcode using POSIX regex */ #ifdef __unix__ #include diff --git a/src/vm/strings/regex_replace.c b/src/vm/strings/regex_replace.c index 368fd28..73f7e87 100644 --- a/src/vm/strings/regex_replace.c +++ b/src/vm/strings/regex_replace.c @@ -31,6 +31,7 @@ * Example: * - pattern = "[0-9]+", repl = "#", input = "a1b22c" -> "a#b#c" */ + /* Regex global replace opcode using POSIX regex */ #ifdef __unix__ #include diff --git a/src/vm/strings/regex_search.c b/src/vm/strings/regex_search.c index 7149729..3ac0ddf 100644 --- a/src/vm/strings/regex_search.c +++ b/src/vm/strings/regex_search.c @@ -34,6 +34,7 @@ * - pattern = "h(ell)o", input = "oh hello!" -> * { match: "hello", start: 3, end: 8, groups: ["ell"] } */ + /* Regex search (first match) opcode using POSIX regex */ #ifdef __unix__ #include diff --git a/src/vm/strings/split.c b/src/vm/strings/split.c index 6806bcb..45a1995 100644 --- a/src/vm/strings/split.c +++ b/src/vm/strings/split.c @@ -24,12 +24,9 @@ * - Exits with an error if the operands are not strings. * * Example: - * // Bytecode: OP_SPLIT - * // Stack before: [", ", "a, b, c"] - * // Stack after: [["a", "b", "c"]] - * - * @author Johannes Findeisen - * @date 2025-10-16 + * - Bytecode: OP_SPLIT + * - Stack before: [", ", "a, b, c"] + * - Stack after: [["a", "b", "c"]] */ case OP_SPLIT: { diff --git a/src/vm/strings/substr.c b/src/vm/strings/substr.c index 6875932..9a5d939 100644 --- a/src/vm/strings/substr.c +++ b/src/vm/strings/substr.c @@ -25,12 +25,9 @@ * - Exits with an error if the start index or length is out of bounds. * * Example: - * // Bytecode: OP_SUBSTR - * // Stack before: [5, 6, "hello world"] - * // Stack after: ["world"] - * - * @author Johannes Findeisen - * @date 2025-10-16 + * - Bytecode: OP_SUBSTR + * - Stack before: [5, 6, "hello world"] + * - Stack after: ["world"] */ case OP_SUBSTR: { diff --git a/src/vm/to_number.c b/src/vm/to_number.c index aa8c135..e17cd43 100644 --- a/src/vm/to_number.c +++ b/src/vm/to_number.c @@ -23,12 +23,9 @@ * - Exits with an error if the conversion fails. * * Example: - * // Bytecode: OP_TO_NUMBER - * // Stack before: ["42"] - * // Stack after: [42] - * - * @author Johannes Findeisen - * @date 2025-10-16 + * - Bytecode: OP_TO_NUMBER + * - Stack before: ["42"] + * - Stack after: [42] */ case OP_TO_NUMBER: { diff --git a/src/vm/to_string.c b/src/vm/to_string.c index 3f34b51..4174f84 100644 --- a/src/vm/to_string.c +++ b/src/vm/to_string.c @@ -29,12 +29,9 @@ * - Exits with an error if memory allocation fails during string creation. * * Example: - * // Bytecode: OP_TO_STRING - * // Stack before: [42] - * // Stack after: ["42"] - * - * @author Johannes Findeisen - * @date 2025-10-16 + * - Bytecode: OP_TO_STRING + * - Stack before: [42] + * - Stack after: ["42"] */ case OP_TO_STRING: { diff --git a/src/vm/xml/name.c b/src/vm/xml/name.c index df2d56b..383b644 100644 --- a/src/vm/xml/name.c +++ b/src/vm/xml/name.c @@ -30,9 +30,10 @@ * stack as usual. * * Example - * // ... stack: [ node_handle ] - * OP_XML_NAME // → [ "book" ] + * - stack: [ node_handle ] + * - OP_XML_NAME → [ "book" ] */ + /* OP_XML_NAME: pops node handle; pushes string */ case OP_XML_NAME: { #ifdef FUN_WITH_XML2 diff --git a/src/vm/xml/parse.c b/src/vm/xml/parse.c index 6f69b95..83bf353 100644 --- a/src/vm/xml/parse.c +++ b/src/vm/xml/parse.c @@ -28,9 +28,10 @@ * - The parser is invoked with XML_PARSE_NONET to disallow network access. * * Example - * // stack: [ "" ] - * OP_XML_PARSE // → [ 1 ] (example handle) + * - stack: [ "" ] + * - OP_XML_PARSE → [ 1 ] (example handle) */ + /* OP_XML_PARSE: pops text string; pushes doc handle (>0) or 0 */ case OP_XML_PARSE: { #ifdef FUN_WITH_XML2 diff --git a/src/vm/xml/root.c b/src/vm/xml/root.c index 68eacc0..70297cd 100644 --- a/src/vm/xml/root.c +++ b/src/vm/xml/root.c @@ -26,9 +26,10 @@ * released by corresponding XML VM opcodes to avoid leaks. * * Example - * // stack: [ doc_handle ] - * OP_XML_ROOT // → [ node_handle ] or [ 0 ] + * - stack: [ doc_handle ] + * - OP_XML_ROOT → [ node_handle ] or [ 0 ] */ + /* OP_XML_ROOT: pops doc handle; pushes node handle (>0) or 0 */ case OP_XML_ROOT: { #ifdef FUN_WITH_XML2 diff --git a/src/vm/xml/text.c b/src/vm/xml/text.c index c03e5a8..33938b2 100644 --- a/src/vm/xml/text.c +++ b/src/vm/xml/text.c @@ -27,9 +27,10 @@ * freed immediately after use. * * Example - * // stack: [ node_handle ] - * OP_XML_TEXT // → [ "Hello world" ] + * - stack: [ node_handle ] + * - OP_XML_TEXT → [ "Hello world" ] */ + /* OP_XML_TEXT: pops node handle; pushes string (concatenate text node children) */ case OP_XML_TEXT: { #ifdef FUN_WITH_XML2 diff --git a/web/images/fun-inverted.png b/web/images/fun-inverted.png new file mode 100644 index 0000000..033e5de Binary files /dev/null and b/web/images/fun-inverted.png differ diff --git a/web/images/fun-square-inverted.png b/web/images/fun-square-inverted.png new file mode 100644 index 0000000..4fdeba1 Binary files /dev/null and b/web/images/fun-square-inverted.png differ