4 #include <st-compiler.h>
5 #include <st-processor.h>
9 #include <st-universe.h>
10 #include <st-object.h>
21 static const char version
[] =
23 "Copyright (C) 2007-2008 Vincent Geddes";
25 static bool verbose
= false;
27 struct opt_spec options
[] = {
28 {opt_help
, "h", "--help", NULL
, "Show help information", NULL
},
29 {opt_version
, "V", "--version", NULL
, "Show version information" , (char *) version
},
30 {opt_store_1
, "v", "--verbose", NULL
, "Show verbose messages" , &verbose
},
38 st_compiler_error error
;
39 char buffer
[BUF_SIZE
];
44 while ((c
= getchar ()) != EOF
&& i
< (BUF_SIZE
- 1))
48 string
= st_strconcat ("doIt ^ [", buffer
, "] value", NULL
);
50 if (!st_compile_string (st_undefined_object_class
, string
, &error
)) {
51 fprintf (stderr
, "test-processor:%i: %s\n",
52 error
.line
, error
.message
);
60 get_elapsed_time (struct timeval before
, struct timeval after
)
62 return after
.tv_sec
- before
.tv_sec
+ (after
.tv_usec
- before
.tv_usec
) / 1.e6
;
66 main (int argc
, char *argv
[])
68 st_processor processor
;
71 opt_basename(argv
[0], '/');
72 opt_parse ("usage: %s [options]", options
, argv
);
74 st_set_verbosity (verbose
);
76 st_bootstrap_universe ();
79 st_processor_initialize (&processor
);
83 st_processor_main (&processor
);
85 /* inspect the returned value on top of the stack */
86 value
= ST_STACK_PEEK ((&processor
));
88 fprintf (stdout
, "\n");
89 fprintf (stdout
, "result: %s\n", st_object_printString (value
));