summaryrefslogtreecommitdiff
path: root/com.c
diff options
context:
space:
mode:
Diffstat (limited to 'com.c')
-rw-r--r--com.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/com.c b/com.c
index fbc93ac..93b0b59 100644
--- a/com.c
+++ b/com.c
@@ -47,7 +47,7 @@ static void compile_node(State *S, Chunk *ch, AstNode a) {
}
case AST_LIST: {
AstVec l = a.as.list;
- #define CK(cond, msg) if (!(cond)) { puts(msg); exit(1); }
+ #define CK(cond, msg) if (!(cond)) { fputs(msg "\n", stderr); exit(1); }
CK(l.len > 0, "can't handle empty list");
CK(l.vals[0].ty == AST_IDENT, "can only call ops");
@@ -150,7 +150,7 @@ static void compile_node(State *S, Chunk *ch, AstNode a) {
}
-int main() {
+int main(int argc, char **argv) {
State st = state_new();
State *S = &st;
Thread th = thread_new(S);
@@ -158,12 +158,14 @@ int main() {
Chunk ch = chunk_new(S);
th.ch = &ch;
+ S->do_disasm = (argc > 1 && 0 == strcmp(argv[1], "-l"));
+
char n1[] = "foo";
char n2[] = "bar";
char n3[] = "baz";
- ObjString *o1 = objstring_copy(S, n1, 3);
- ObjString *o2 = objstring_copy(S, n2, 3);
- ObjString *o3 = objstring_copy(S, n3, 3);
+ ObjString *o1 = objstring_copy_cstr(S, n1);
+ ObjString *o2 = objstring_copy_cstr(S, n2);
+ ObjString *o3 = objstring_copy_cstr(S, n3);
ht_put(S, &st.globals, o1, VAL_NUM(69));
ht_put(S, &st.globals, o2, VAL_NUM(2));
@@ -175,7 +177,6 @@ int main() {
chunk_wbc(S, &ch, OP_PRINT);
chunk_wbc(S, &ch, OP_RET);
- puts("compile done");
return runvm(S);
}