|
@@ -1,8 +1,37 @@
|
|
|
|
+#include <stdio.h>
|
|
|
|
+#include <string.h>
|
|
|
|
+#include <time.h>
|
|
|
|
+
|
|
|
|
+#include "Compiler.h"
|
|
|
|
+#include "Script.h"
|
|
#include "Test.h"
|
|
#include "Test.h"
|
|
|
|
+#include "Tokenizer.h"
|
|
|
|
+
|
|
|
|
+long getNanos() {
|
|
|
|
+ struct timespec time;
|
|
|
|
+ clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &time);
|
|
|
|
+ return time.tv_nsec + time.tv_sec * 1000000000l;
|
|
|
|
+}
|
|
|
|
|
|
int main(int argAmount, const char** args) {
|
|
int main(int argAmount, const char** args) {
|
|
- if(argAmount >= 2) {
|
|
|
|
- tsStart(args[1]);
|
|
|
|
|
|
+ if(argAmount >= 3 && strcmp(args[1], "test") == 0) {
|
|
|
|
+ tsStart(args[2]);
|
|
|
|
+ } else if(argAmount >= 2) {
|
|
|
|
+ if(tTokenize(args[1])) {
|
|
|
|
+ puts(tGetError());
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ ByteCode* code = cCompile();
|
|
|
|
+ if(code == NULL) {
|
|
|
|
+ puts(tGetError());
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ Script* sc = sInit(code);
|
|
|
|
+ long time = -getNanos();
|
|
|
|
+ sRun(sc);
|
|
|
|
+ time += getNanos();
|
|
|
|
+ printf("----------------\n%ld ns\n", time);
|
|
|
|
+ sDelete(sc);
|
|
}
|
|
}
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|