made global variable names uppercase
[panda.git] / tests / test-interpreter.c
blob22e8b440fcbf61ba170c1db04e01ab7c60e5efbe
2 #include <st-types.h>
3 #include <st-symbol.h>
4 #include <st-compiler.h>
5 #include <st-cpu.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>
13 #include <stdlib.h>
14 #include <stdio.h>
15 #include <stdbool.h>
17 #define BUF_SIZE 10000
19 int
20 main (int argc, char *argv[])
22 st_compiler_error error;
23 char buffer[BUF_SIZE];
24 char *string;
25 st_oop value;
26 char c;
27 int i = 0;
29 /* the big bang */
30 st_bootstrap_universe ();
32 while ((c = getchar ()) != EOF && i < (BUF_SIZE - 1))
33 buffer[i++] = c;
34 buffer[i] = '\0';
36 string = st_strconcat ("doIt ^ [", buffer, "] value", NULL);
38 bool result = st_compile_string (ST_UNDEFINED_OBJECT_CLASS, string, &error);
39 if (!result) {
40 fprintf (stderr, "test-processor:%i: %s\n",
41 error.line, error.message);
42 return 1;
45 st_cpu_initialize ();
47 struct timeval before, after;
48 double elapsed;
50 gettimeofday (&before, NULL);
52 st_cpu_main ();
54 gettimeofday (&after, NULL);
56 elapsed = after.tv_sec - before.tv_sec +
57 (after.tv_usec - before.tv_usec) / 1.e6;
59 /* inspect the returned value on top of the stack */
60 value = ST_STACK_PEEK ((&__cpu));
62 printf ("result: %s\n", st_object_printString (value));
63 printf ("time %.9f seconds\n", elapsed);
66 return 0;