Use macro accessors for instance variable accessing in VM
[panda.git] / src / main.c
blob4bae39082d151c51ee2619755d3717c3f43d086f
2 #include <st-types.h>
3 #include <st-symbol.h>
4 #include <st-compiler.h>
5 #include <st-processor.h>
6 #include <st-array.h>
7 #include <st-lexer.h>
8 #include <st-node.h>
9 #include <st-universe.h>
10 #include <st-object.h>
11 #include <st-float.h>
12 #include <optparse.h>
14 #include <stdlib.h>
15 #include <stdio.h>
16 #include <stdbool.h>
17 #include <sys/time.h>
19 #define BUF_SIZE 2000
21 static const char version[] =
22 PACKAGE_STRING"\n"
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},
31 {NULL}
35 static void
36 compile_input (void)
38 st_compiler_error error;
39 char buffer[BUF_SIZE];
40 char *string;
41 char c;
42 int i = 0;
44 while ((c = getchar ()) != EOF && i < (BUF_SIZE - 1))
45 buffer[i++] = c;
46 buffer[i] = '\0';
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);
53 exit (1);
56 st_free (string);
59 static double
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;
65 int
66 main (int argc, char *argv[])
68 st_processor processor;
69 st_oop value;
71 opt_basename(argv[0], '/');
72 opt_parse ("usage: %s [options]", options, argv);
74 st_set_verbosity (verbose);
76 st_bootstrap_universe ();
77 compile_input ();
79 st_processor_initialize (&processor);
81 proc = &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));
91 return 0;