2007-06-22 22:47:57 +00:00
|
|
|
#include "common.h"
|
2007-06-20 19:20:25 +00:00
|
|
|
#include "system.h"
|
|
|
|
#include "heap.h"
|
2007-08-10 23:45:47 +00:00
|
|
|
#include "finder.h"
|
2007-09-24 01:39:03 +00:00
|
|
|
#include "processor.h"
|
|
|
|
#include "machine.h"
|
2007-06-20 19:20:25 +00:00
|
|
|
|
|
|
|
using namespace vm;
|
|
|
|
|
2007-10-22 20:56:27 +00:00
|
|
|
extern "C" void __cxa_pure_virtual(void) { abort(); }
|
|
|
|
|
2007-06-20 19:20:25 +00:00
|
|
|
namespace {
|
|
|
|
|
2007-07-16 01:03:02 +00:00
|
|
|
int
|
2007-06-20 19:20:25 +00:00
|
|
|
run(unsigned heapSize, const char* path, const char* class_, int argc,
|
|
|
|
const char** argv)
|
|
|
|
{
|
2007-07-20 14:36:31 +00:00
|
|
|
System* s = makeSystem(heapSize);
|
2007-08-10 23:45:47 +00:00
|
|
|
Finder* f = makeFinder(s, path);
|
2007-07-20 14:36:31 +00:00
|
|
|
Heap* heap = makeHeap(s);
|
2007-09-24 01:39:03 +00:00
|
|
|
Processor* p = makeProcessor(s);
|
2007-06-20 19:20:25 +00:00
|
|
|
|
2007-09-24 01:39:03 +00:00
|
|
|
int exitCode = run(s, heap, f, p, class_, argc, argv);
|
2007-06-20 19:20:25 +00:00
|
|
|
|
2007-09-24 01:39:03 +00:00
|
|
|
p->dispose();
|
2007-06-20 19:20:25 +00:00
|
|
|
heap->dispose();
|
2007-08-10 23:45:47 +00:00
|
|
|
f->dispose();
|
2007-07-20 14:36:31 +00:00
|
|
|
s->dispose();
|
2007-07-16 01:03:02 +00:00
|
|
|
|
|
|
|
return exitCode;
|
2007-06-20 19:20:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
usageAndExit(const char* name)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "usage: %s [-cp <classpath>] [-hs <maximum heap size>] "
|
2007-06-20 21:27:22 +00:00
|
|
|
"<class name> [<argument> ...]\n", name);
|
2007-06-20 19:20:25 +00:00
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
int
|
|
|
|
main(int ac, const char** av)
|
|
|
|
{
|
2007-08-18 21:24:29 +00:00
|
|
|
unsigned heapSize = 128 * 1024 * 1024;
|
2007-06-20 19:20:25 +00:00
|
|
|
const char* path = ".";
|
|
|
|
const char* class_ = 0;
|
|
|
|
int argc = 0;
|
|
|
|
const char** argv = 0;
|
|
|
|
|
|
|
|
for (int i = 1; i < ac; ++i) {
|
|
|
|
if (strcmp(av[i], "-cp") == 0) {
|
|
|
|
path = av[++i];
|
|
|
|
} else if (strcmp(av[i], "-hs") == 0) {
|
|
|
|
heapSize = atoi(av[++i]);
|
|
|
|
} else {
|
|
|
|
class_ = av[i++];
|
|
|
|
if (i < ac) {
|
|
|
|
argc = ac - i;
|
|
|
|
argv = av + i;
|
|
|
|
i = ac;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (class_ == 0) {
|
|
|
|
usageAndExit(av[0]);
|
|
|
|
}
|
|
|
|
|
2007-07-16 01:03:02 +00:00
|
|
|
return run(heapSize, path, class_, argc, argv);
|
2007-06-20 19:20:25 +00:00
|
|
|
}
|