From 21ef4c306d38969e8f5fe821a27d155b855735b9 Mon Sep 17 00:00:00 2001 From: kramm Date: Tue, 2 Dec 2008 17:09:58 +0000 Subject: [PATCH] added GPL headers --- lib/as3/code.c | 23 +++++++++++++++++++++++ lib/as3/code.h | 23 +++++++++++++++++++++++ lib/as3/opcodes.c | 23 +++++++++++++++++++++++ lib/as3/opcodes.h | 23 +++++++++++++++++++++++ lib/as3/parser.y | 33 +++++++++++++++++++++++++++++++-- lib/as3/registry.c | 23 +++++++++++++++++++++++ lib/as3/registry.h | 23 +++++++++++++++++++++++ lib/as3/tokenizer.lex | 41 +++++++++++++++++++++++++++++++++++------ 8 files changed, 204 insertions(+), 8 deletions(-) diff --git a/lib/as3/code.c b/lib/as3/code.c index 02d8975..86bae59 100644 --- a/lib/as3/code.c +++ b/lib/as3/code.c @@ -1,3 +1,26 @@ +/* code.c + + Routines for handling Flash2 AVM2 ABC Actionscript + + Extension module for the rfxswf library. + Part of the swftools package. + + Copyright (c) 2008 Matthias Kramm + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + #include #include "code.h" #include "pool.h" diff --git a/lib/as3/code.h b/lib/as3/code.h index 5acc8d1..159c2b0 100644 --- a/lib/as3/code.h +++ b/lib/as3/code.h @@ -1,3 +1,26 @@ +/* code.h + + Routines for handling Flash2 AVM2 ABC Actionscript + + Extension module for the rfxswf library. + Part of the swftools package. + + Copyright (c) 2008 Matthias Kramm + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + #ifndef __abc_code_h__ #define __abc_code_h__ diff --git a/lib/as3/opcodes.c b/lib/as3/opcodes.c index 4197ec3..5a4cc57 100644 --- a/lib/as3/opcodes.c +++ b/lib/as3/opcodes.c @@ -1,3 +1,26 @@ +/* opcodes.c + + Routines for handling Flash2 AVM2 ABC Actionscript + + Extension module for the rfxswf library. + Part of the swftools package. + + Copyright (c) 2008 Matthias Kramm + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + #include "opcodes.h" code_t* abc_add(code_t*prev) { diff --git a/lib/as3/opcodes.h b/lib/as3/opcodes.h index d068e3c..3633db8 100644 --- a/lib/as3/opcodes.h +++ b/lib/as3/opcodes.h @@ -1,3 +1,26 @@ +/* opcodes.h + + Routines for handling Flash2 AVM2 ABC Actionscript + + Extension module for the rfxswf library. + Part of the swftools package. + + Copyright (c) 2008 Matthias Kramm + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + #ifndef __opcodes_h__ #define __opcodes_h__ #include "abc.h" diff --git a/lib/as3/parser.y b/lib/as3/parser.y index 61bbdfc..35e7abc 100644 --- a/lib/as3/parser.y +++ b/lib/as3/parser.y @@ -1,3 +1,25 @@ +/* parser.lex + + Routines for compiling Flash2 AVM2 ABC Actionscript + + Extension module for the rfxswf library. + Part of the swftools package. + + Copyright (c) 2008 Matthias Kramm + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ %{ #include #include @@ -128,6 +150,7 @@ %type TYPE %type VAR %type VARIABLE +%type VAR_READ %type NEW %type X_IDENTIFIER %type MODIFIER @@ -606,10 +629,10 @@ VARIABLE_DECLARATION : MODIFIERS VAR T_IDENTIFIER MAYBETYPE MAYBEEXPRESSION { MAYBEEXPRESSION : '=' EXPRESSION {$$=$2;} | {$$=code_new();} -EXPRESSION : E %prec prec_none {$$ = $1;} //precendence below '-x' +EXPRESSION : E %prec prec_none /*precendence below '-x'*/ {$$ = $1;} E : CONSTANT -E : VARIABLE %prec T_IDENTIFIER {$$ = abc_pushundefined(0); /* FIXME */} +E : VAR_READ %prec T_IDENTIFIER {$$ = $1;} E : NEW {$$ = abc_pushundefined(0); /* FIXME */} E : T_REGEXP {$$ = abc_pushundefined(0); /* FIXME */} E : FUNCTIONCALL @@ -653,6 +676,12 @@ MAYBE_EXPRESSION_LIST : EXPRESSION_LIST EXPRESSION_LIST : EXPRESSION {$$=list_new();list_append($$,$1);} EXPRESSION_LIST : EXPRESSION_LIST ',' EXPRESSION {list_append($$,$3);} +VAR_READ : T_IDENTIFIER { + int i = array_find(state->vars, $1->text); + if(i<0) + syntaxerror("unknown variable"); + $$ = abc_getlocal(0, i); +} VARIABLE : T_IDENTIFIER VARIABLE : VARIABLE '.' T_IDENTIFIER VARIABLE : VARIABLE ".." T_IDENTIFIER // descendants diff --git a/lib/as3/registry.c b/lib/as3/registry.c index 5a688bd..eb97313 100644 --- a/lib/as3/registry.c +++ b/lib/as3/registry.c @@ -1,3 +1,26 @@ +/* registry.c + + Routines for compiling Flash2 AVM2 ABC Actionscript + + Extension module for the rfxswf library. + Part of the swftools package. + + Copyright (c) 2008 Matthias Kramm + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + #include "pool.h" #include "registry.h" diff --git a/lib/as3/registry.h b/lib/as3/registry.h index f0ea362..6836bd1 100644 --- a/lib/as3/registry.h +++ b/lib/as3/registry.h @@ -1,3 +1,26 @@ +/* registry.h + + Routines for compiling Flash2 AVM2 ABC Actionscript + + Extension module for the rfxswf library. + Part of the swftools package. + + Copyright (c) 2008 Matthias Kramm + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + #ifndef __abc_registry_h__ #define __abc_registry_h__ multiname_t* registry_findclass(const char*package, const char*name); diff --git a/lib/as3/tokenizer.lex b/lib/as3/tokenizer.lex index 5a8ec32..dcae2f2 100644 --- a/lib/as3/tokenizer.lex +++ b/lib/as3/tokenizer.lex @@ -1,4 +1,28 @@ +/* tokenizer.lex + + Routines for compiling Flash2 AVM2 ABC Actionscript + + Extension module for the rfxswf library. + Part of the swftools package. + + Copyright (c) 2008 Matthias Kramm + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ %{ + + #include #include #include @@ -147,8 +171,14 @@ static inline int handlenumber() } } if(yytext[0]=='-') { - avm2_lval.number_int = atoi(s); - return T_INT; + int v = atoi(s); + avm2_lval.number_int = v; + if(v>-128) + return T_BYTE; + else if(v>=-32768) + return T_SHORT; + else + return T_INT; } else { unsigned int v = 0; for(t=0;t