diff options
-rw-r--r-- | com.c | 8 | ||||
-rw-r--r-- | dis.c | 2 | ||||
-rw-r--r-- | tests/fizzbuzz.bth | 2 | ||||
-rw-r--r-- | tests/vars.bth | 8 | ||||
-rw-r--r-- | vm.c | 2 | ||||
-rw-r--r-- | vm.h | 2 |
6 files changed, 12 insertions, 12 deletions
@@ -53,10 +53,10 @@ static void compile_node(State *S, Chunk *ch, AstNode a) { char *name = l.vals[0].as.str; - if (0 == strcmp(name, "print")) { - CK(l.len == 2, "print requires exactly 1 argument"); + if (0 == strcmp(name, "puts")) { + CK(l.len == 2, "puts requires exactly 1 argument"); compile_node(S, ch, l.vals[1]); - chunk_wbc(S, ch, OP_PRINT); + chunk_wbc(S, ch, OP_PUTS); } else if (0 == strcmp(name, "set")) { CK(l.len == 3, "set requires exactly 2 arguments"); AstNode ident = l.vals[1]; @@ -174,7 +174,7 @@ int main(int argc, char **argv) { AstNode an = read(); compile_node(S, &ch, an); - chunk_wbc(S, &ch, OP_PRINT); + chunk_wbc(S, &ch, OP_PUTS); chunk_wbc(S, &ch, OP_RET); return runvm(S); @@ -66,7 +66,7 @@ void disasm_chunk(Chunk *ch) { #define SIMPLE_INSTR(opcode, str) \ case opcode: puts(str); break; SIMPLE_INSTR(OP_RET, "ret") - SIMPLE_INSTR(OP_PRINT, "print") + SIMPLE_INSTR(OP_PUTS, "puts") SIMPLE_INSTR(OP_DROP, "drop") SIMPLE_INSTR(OP_ADD, "add") SIMPLE_INSTR(OP_SUB, "sub") diff --git a/tests/fizzbuzz.bth b/tests/fizzbuzz.bth index e70c2c1..82e80cf 100644 --- a/tests/fizzbuzz.bth +++ b/tests/fizzbuzz.bth @@ -1,7 +1,7 @@ (do (set n 1) (while (< n 30) - (print + (puts (if (= 0 (% n 5)) (if (= 0 (% n 3)) "fizzbuzz" "buzz") (if (= 0 (% n 3)) "fizz" n))) diff --git a/tests/vars.bth b/tests/vars.bth index 7799acf..a524ae6 100644 --- a/tests/vars.bth +++ b/tests/vars.bth @@ -2,8 +2,8 @@ (set a 5) (set b 10) (set thethe 1234) - (print (+ a b)) - (print (- thethe a)) - (print (+ (set a 90) b)) - (print a) + (puts (+ a b)) + (puts (- thethe a)) + (puts (+ (set a 90) b)) + (puts a) nil) @@ -85,7 +85,7 @@ int runvm(State *S) { // printf(")\n"); break; } - case OP_PRINT: + case OP_PUTS: println_val(PEEK()); break; case OP_DROP: @@ -38,7 +38,7 @@ Thread thread_new(State *S); typedef enum { OP_RET, OP_LOADK, - OP_PRINT, + OP_PUTS, OP_ADD, OP_SUB, |