X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fas3%2Fmain.c;h=0727c1214a379200ef1d835e2cfe3b7ede9976e6;hb=0fd17f47ee30d90181e51f30fc17a6c31646137e;hp=7e318b4cfaf66f059e98d4f23ddb565391dcfe0f;hpb=14a64135ac5da8e5a4dd0a33635df11e9125bf82;p=swftools.git diff --git a/lib/as3/main.c b/lib/as3/main.c index 7e318b4..0727c12 100644 --- a/lib/as3/main.c +++ b/lib/as3/main.c @@ -30,17 +30,23 @@ #include "tokenizer.h" #include "parser.tab.h" #include "parser.h" +#include "compiler.h" +#include "import.h" -void test_lexer() +void test_lexer(char*filename) { + char*fullfilename = find_file(filename, 1); + enter_file(filename, fullfilename, 0); + FILE*fi = fopen(fullfilename, "rb"); + as3_file_input(fi); while(1) { - int token = avm2_lex(); + int token = as3_lex(); if(token==T_EOF) break; if(token>=32 && token<256) { printf("'%c'\n", token); } else { - printf("%s\n", token2string(token, avm2_lval)); + printf("%s\n", token2string(token, a3_lval)); } } } @@ -49,35 +55,50 @@ int main(int argn, char*argv[]) { char*filename = 0; char buf[512]; - void*code=0; if(argn<=1) { fprintf(stderr, "please supply a filename\n"); exit(1); } - filename=argv[1]; - - add_include_dir(getcwd(buf, 512)); - - char*fullfilename = enter_file(filename, 0); - FILE*fi = fopen(fullfilename, "rb"); - if(!fi) { - perror(fullfilename); - return 1; - } - avm2_set_in(fi); + filename=argv[argn-1]; + + as3_add_include_dir(getcwd(buf, 512)); registry_init(); - initialize_state(); - if(argn>2 && !strcmp(argv[2], "-lex")) { - test_lexer(); - return 0; + int t=0; + for(t=1;tdata, m->len); + //memfile_close(m); + if(!strcmp(filename, ".")) { + as3_parse_directory("."); + } else { + as3_parse_file(filename); + } + + void*code = as3_getcode(); SWF swf; memset(&swf, 0, sizeof(swf)); @@ -89,12 +110,11 @@ int main(int argn, char*argv[]) TAG*tag = swf.firstTag = swf_InsertTag(0, ST_DOABC); swf_WriteABC(tag, code); - if(globalclass) { + if(as3_getglobalclass()) { tag = swf_InsertTag(tag, ST_SYMBOLCLASS); swf_SetU16(tag, 1); swf_SetU16(tag, 0); - swf_SetString(tag, globalclass); - free(globalclass);globalclass=0; + swf_SetString(tag, as3_getglobalclass()); } else { printf("Warning: no global public MovieClip subclass\n"); }