aboutsummaryrefslogtreecommitdiff
path: root/interpreter.c
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2017-05-26 20:25:02 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2017-05-26 20:25:02 +0200
commitdd957483ac35b6651c00de04d982c85723975eb2 (patch)
treeee8677a33eabed1dbfe7736084e07696ba1cf7a0 /interpreter.c
parent3e68a09ae1617551ca1cbf3b5b72621170b4aa0c (diff)
downloadell-dd957483ac35b6651c00de04d982c85723975eb2.tar.gz
ell-dd957483ac35b6651c00de04d982c85723975eb2.tar.xz
ell-dd957483ac35b6651c00de04d982c85723975eb2.zip
interpreter: forward "argv"
Diffstat (limited to 'interpreter.c')
-rw-r--r--interpreter.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/interpreter.c b/interpreter.c
index 1ca2744..7be4fc7 100644
--- a/interpreter.c
+++ b/interpreter.c
@@ -50,9 +50,13 @@ main (int argc, char *argv[]) {
if (!init_runtime_library (&ctx))
printf ("%s\n", "runtime library initialization failed");
+ // In this one place we optimistically expect allocation to succeed
+ struct item *args = NULL, **tail = &args;
+ for (int i = 2; i < argc; i++)
+ tail = &(*tail = new_string (argv[i], strlen (argv[i])))->next;
+
struct item *result = NULL;
- // TODO: pass argv as the list of arguments
- (void) execute_block (&ctx, program, NULL, &result);
+ (void) execute_block (&ctx, program, args, &result);
item_free_list (result);
item_free_list (program);