X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fas3%2Fmain.c;h=4901e43812d0cd654b5f3d69f0b71b54cb9fe88f;hb=3e1312c39052252e112f435ba3193f550cf891cb;hp=e17f62775eca5ffbc038a9e738cfa2814698e096;hpb=818266df7c2107eb7c4c65fb47002815cf3e6f72;p=swftools.git diff --git a/lib/as3/main.c b/lib/as3/main.c index e17f627..4901e43 100644 --- a/lib/as3/main.c +++ b/lib/as3/main.c @@ -30,17 +30,21 @@ #include "tokenizer.h" #include "parser.tab.h" #include "parser.h" +#include "compiler.h" -void test_lexer() +void test_lexer(char*filename) { + char*fullfilename = enter_file(filename, 0); + FILE*fi = fopen(fullfilename, "rb"); + as3_set_in(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)); } } } @@ -54,43 +58,41 @@ int main(int argn, char*argv[]) fprintf(stderr, "please supply a filename\n"); exit(1); } - filename=argv[1]; - - registry_init(); - - add_include_dir(getcwd(buf, 512)); - char*fullfilename = enter_file(filename, 0); - - FILE*fi = fopen(fullfilename, "rb"); - if(!fi) { - perror(fullfilename); - return 1; + filename=argv[argn-1]; + + int t=0; + for(t=1;t2 && !strcmp(argv[2], "-lex")) { - test_lexer(); - return 0; - } - avm2_parse(); - void*code = finalize_state(); + //extern int avm2_debug; + //avm2_debug = 1; + + as3_add_include_dir(getcwd(buf, 512)); + as3_parse_file(filename); + void*code = as3_getcode(); SWF swf; memset(&swf, 0, sizeof(swf)); swf.fileVersion = 9; swf.frameRate = 0x2500; swf.movieSize.xmin = swf.movieSize.ymin = 0; - swf.movieSize.xmax = 1024*20; - swf.movieSize.ymax = 768*20; + swf.movieSize.xmax = 20*20; + swf.movieSize.ymax = 10*20; 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); + swf_SetString(tag, as3_getglobalclass()); } else { printf("Warning: no global public MovieClip subclass\n"); } @@ -104,5 +106,7 @@ int main(int argn, char*argv[]) swf_WriteSWF(f,&swf); close(f); + swf_FreeTags(&swf); + return 0; }