From e24823924a74546f01ca9f9c48870aa6b7864f57 Mon Sep 17 00:00:00 2001 From: Kayne Ruse Date: Sun, 12 Apr 2026 15:02:07 +1000 Subject: [PATCH] Comment tweaks --- scripts/hello_world.toy | 11 ++++++++++- source/toy_compiler.c | 2 ++ source/toy_vm.c | 2 -- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/scripts/hello_world.toy b/scripts/hello_world.toy index 4e1be26..aaa244a 100644 --- a/scripts/hello_world.toy +++ b/scripts/hello_world.toy @@ -1,4 +1,13 @@ +fn swap(a, b) { + return b, a; +} -print 1; \ No newline at end of file +var a = 42; +var b = 69; +var c; +var d; + +//TODO: reverse the assignment bytecode order? +c, d = swap(a, b); \ No newline at end of file diff --git a/source/toy_compiler.c b/source/toy_compiler.c index 99deeab..f64759a 100644 --- a/source/toy_compiler.c +++ b/source/toy_compiler.c @@ -801,6 +801,8 @@ static unsigned int writeInstructionVarDeclare(Toy_Bytecode** mb, Toy_AstVarDecl static unsigned int writeInstructionAssign(Toy_Bytecode** mb, Toy_AstVarAssign ast, bool chainedAssignment) { unsigned int result = 0; + //TODO: flip the order of target & value, to allow chained assignment AND multiple return values + //target is a variable name if (ast.target->type == TOY_AST_VALUE && TOY_VALUE_IS_STRING(ast.target->value.value)) { //name string diff --git a/source/toy_vm.c b/source/toy_vm.c index ce1b6b7..1e8d81e 100644 --- a/source/toy_vm.c +++ b/source/toy_vm.c @@ -356,8 +356,6 @@ static void processAccess(Toy_VM* vm) { return; } - //URGENT: should I loop functions into the reference system? - //in the event of a certain subset of types, create references instead (these should only exist on the stack) if (TOY_VALUE_IS_REFERENCE(*valuePtr) || TOY_VALUE_IS_ARRAY(*valuePtr) || TOY_VALUE_IS_TABLE(*valuePtr) || TOY_VALUE_IS_FUNCTION(*valuePtr)) { Toy_Value ref = TOY_REFERENCE_FROM_POINTER(valuePtr);