added GPL headers
authorkramm <kramm>
Tue, 2 Dec 2008 17:09:58 +0000 (17:09 +0000)
committerkramm <kramm>
Tue, 2 Dec 2008 17:09:58 +0000 (17:09 +0000)
lib/as3/code.c
lib/as3/code.h
lib/as3/opcodes.c
lib/as3/opcodes.h
lib/as3/parser.y
lib/as3/registry.c
lib/as3/registry.h
lib/as3/tokenizer.lex

index 02d8975..86bae59 100644 (file)
@@ -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 <kramm@quiss.org>
+   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 <assert.h>
 #include "code.h"
 #include "pool.h"
index 5acc8d1..159c2b0 100644 (file)
@@ -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 <kramm@quiss.org>
+   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__
 
index 4197ec3..5a4cc57 100644 (file)
@@ -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 <kramm@quiss.org>
+   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)
 {
index d068e3c..3633db8 100644 (file)
@@ -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 <kramm@quiss.org>
+   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"
index 61bbdfc..35e7abc 100644 (file)
@@ -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 <kramm@quiss.org>
+   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 <stdlib.h>
 #include <stdio.h>
 %type <multiname> TYPE
 %type <token> VAR
 %type <token> VARIABLE
+%type <code> VAR_READ
 %type <token> NEW
 %type <token> X_IDENTIFIER
 %type <token> 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
index 5a688bd..eb97313 100644 (file)
@@ -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 <kramm@quiss.org>
+   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"
 
index f0ea362..6836bd1 100644 (file)
@@ -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 <kramm@quiss.org>
+   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);
index 5a8ec32..dcae2f2 100644 (file)
@@ -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 <kramm@quiss.org>
+   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 <string.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -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<yyleng;t++) {
@@ -156,11 +186,10 @@ static inline int handlenumber()
             v+=yytext[t]-'0';
         }
         avm2_lval.number_uint = v;
-        if(v<256)
+        if(v<128)
             return T_BYTE;
-        /* useless- numbers are usually smaller if stored in the constant pool
-          else if(v<0x80000000u)
-            return T_SHORT;*/
+        else if(v<32768)
+            return T_SHORT;
         else
             return T_UINT;
     }