4 #include <st-compiler.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
},
36 read_compile_stdin (void)
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
[])
70 opt_basename (argv
[0], '/');
71 // opt_message ("Read Smalltalk expressions from standard input and evaluate them.");
72 opt_parse ("Usage: %s [options]", options
, argv
);
74 st_set_verbosity (verbose
);
76 st_bootstrap_universe ();
77 read_compile_stdin ();
82 /* inspect the returned value on top of the stack */
83 value
= ST_STACK_PEEK ((&__cpu
));
84 if (st_object_format (value
) != ST_FORMAT_BYTE_ARRAY
)
88 printf ("result: %s\n", (char *) st_byte_array_bytes (value
));