X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=blobdiff_plain;f=lib%2Fas3%2Fmain.c;h=1ce83a67e446b4d473a59a7defcb5aef9eca100d;hp=a5a4b6259d88b5bd90235a796142ff920831e90f;hb=9ed9a87914fc9a590967d46de404e0f6290b7bb2;hpb=c84fad6221c2d2b214bb5d438376977b350a327e diff --git a/lib/as3/main.c b/lib/as3/main.c index a5a4b62..1ce83a6 100644 --- a/lib/as3/main.c +++ b/lib/as3/main.c @@ -27,28 +27,32 @@ #include "../rfxswf.h" #include "../os.h" #include "files.h" +#include "common.h" #include "tokenizer.h" #include "parser.tab.h" #include "parser.h" #include "compiler.h" +#include "import.h" void test_lexer(char*filename) { - char*fullfilename = enter_file(filename, 0); + char*fullfilename = find_file(filename, 1); + enter_file(filename, fullfilename, 0); FILE*fi = fopen(fullfilename, "rb"); - avm2_set_in(fi); + 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)); } } } +extern int a3_debug; int main(int argn, char*argv[]) { char*filename = 0; @@ -58,18 +62,61 @@ int main(int argn, char*argv[]) fprintf(stderr, "please supply a filename\n"); exit(1); } - filename=argv[1]; - - if(argn>2 && !strcmp(argv[2], "-lex")) { - test_lexer(filename); - return 0; + filename=argv[argn-1]; + +#ifdef BISONDEBUG + a3_debug = 1; //if bison was called with -t +#endif + + as3_add_include_dir(getcwd(buf, 512)); + + registry_init(); + + int t=0; + char*mainclass = 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; @@ -79,14 +126,23 @@ int main(int argn, char*argv[]) swf.movieSize.xmin = swf.movieSize.ymin = 0; swf.movieSize.xmax = 20*20; swf.movieSize.ymax = 10*20; - TAG*tag = swf.firstTag = swf_InsertTag(0, ST_DOABC); + TAG*tag = (TAG*)as3_getassets(0); + if(!swf.firstTag && tag) swf.firstTag = tag; + + while(tag && tag->next) tag = tag->next; + + tag = swf_InsertTag(tag, ST_DOABC); + if(!swf.firstTag && tag) swf.firstTag = tag; swf_WriteABC(tag, code); - if(as3_getglobalclass()) { + if(!mainclass) + mainclass = as3_getglobalclass(); + + if(mainclass) { tag = swf_InsertTag(tag, ST_SYMBOLCLASS); swf_SetU16(tag, 1); swf_SetU16(tag, 0); - swf_SetString(tag, as3_getglobalclass()); + swf_SetString(tag, mainclass); } else { printf("Warning: no global public MovieClip subclass\n"); }