Merge branch 'as3fixes'
authorMatthias Kramm <kramm@quiss.org>
Fri, 24 Jul 2009 20:08:15 +0000 (22:08 +0200)
committerMatthias Kramm <kramm@quiss.org>
Fri, 24 Jul 2009 20:08:15 +0000 (22:08 +0200)
lib/as3/code.c
lib/as3/code.h
lib/as3/mklib.c
lib/as3/ok/arrays.as
lib/as3/ok/ops.as
lib/as3/ok/this.as
lib/as3/parser.y
lib/as3/test
lib/as3/tokenizer.lex

index 31c986f..8e41f22 100644 (file)
@@ -1225,6 +1225,19 @@ code_t*code_cutlast(code_t*c)
     return code_cut(c);
 }
 
+char is_getlocal(code_t*c)
+{
+    if(!c) return 0;
+    if(c->opcode == OPCODE_GETLOCAL ||
+       c->opcode == OPCODE_GETLOCAL_0 ||
+       c->opcode == OPCODE_GETLOCAL_1 ||
+       c->opcode == OPCODE_GETLOCAL_2 ||
+       c->opcode == OPCODE_GETLOCAL_3) {
+       return 1;
+    }
+    return 0;
+}
+
 code_t* cut_last_push(code_t*c)
 {
     assert(!c->next);
index 4dcd096..d120203 100644 (file)
@@ -102,6 +102,8 @@ code_t* code_append(code_t*code, code_t*toappend);
 
 code_t* cut_last_push(code_t*_c);
 
+char is_getlocal(code_t*c);
+
 #define code_new() (0)
 
 #endif
index b243ffc..1204ed8 100644 (file)
@@ -125,6 +125,7 @@ char*mktype(slotinfo_t*s)
     } else if(s->kind == INFOTYPE_VAR) {
         return "varinfo_t";
     }
+    return "**ERROR**";
 }
 
 void write_slotinfo(FILE*fi, slotinfo_t*s, char*id, char*prefix);
@@ -310,5 +311,5 @@ int main()
     fprintf(fi, "    _Infinity_constant.f = __builtin_inf();\n");
     fprintf(fi, "    return d;\n");
     fprintf(fi, "}\n");
-
+    return 0;
 }
index c56c34d..51aad81 100644 (file)
@@ -5,20 +5,25 @@ package {
     public class Main extends flash.display.MovieClip {
         function Main() {
             var a:Array = new Array(1,2,3);
-            if(a[0]==1) trace("ok 1/8");
-            if(a[1]==2) trace("ok 2/8");
-            if(a[2]==3) trace("ok 3/8");
-            if(a.length==3) trace("ok 4/8");
+            if(a[0]==1) trace("ok 1/10");
+            if(a[1]==2) trace("ok 2/10");
+            if(a[2]==3) trace("ok 3/10");
+            if(a.length==3) trace("ok 4/10");
 
             var b:Array = [1,2,3];
-            if(b[0]==1) trace("ok 5/8");
-            if(b[1]==2) trace("ok 6/8");
-            if(b[2]==3) trace("ok 7/8");
-            if(b.length==3) trace("ok 8/8");
+            if(b[0]==1) trace("ok 5/10");
+            if(b[1]==2) trace("ok 6/10");
+            if(b[2]==3) trace("ok 7/10");
+            if(b.length==3) trace("ok 8/10");
           
             // test for ]+<int> parser bug:
             var check = (3 == a[0]+1);
-            
+
+           var list:Array = ["ok 9/10", "ok 10/10"];
+           for each(var s:String in list) {
+               trace(s);
+           }                    
+
             trace("[exit]");
         }
     }
index 87de785..9f14136 100644 (file)
@@ -3,7 +3,7 @@ package {
     import flash.display.MovieClip
     public class Main extends flash.display.MovieClip {
         var count:int = 1;
-        var num:int = 28;
+        var num:int = 30;
         function assert(b:Boolean) {
             if(b) {
                 trace("ok "+count+"/"+num);
@@ -39,6 +39,13 @@ package {
             assert(2+3==5);
             assert(2-3==-1);
 
+           /* test or */
+           var y = 0;
+           var x = y || 1;
+           assert(x);
+           var z = x && 1;
+           assert(z);
+
             /* test not */
             trace("[not]");
             assert(!false);
index 1668ee9..61c70a5 100644 (file)
@@ -2,10 +2,10 @@ package {
     import flash.display.MovieClip
     public class Main extends flash.display.MovieClip {
         internal var s0;
-        internal var s1:String="ok 3/4";
+        internal var s1:String="ok 3/5";
         internal var s2;
         public function printok1() {
-            trace("ok 1/4");
+            trace("ok 1/5");
         }
         public function printok2(x:uint) {
             trace(this.s0);
@@ -13,18 +13,28 @@ package {
         public function printok3() {
             trace(this.s2);
         }
+
+        public function f() {
+           trace("ok 5/5");
+       }
+        public function get_f() {
+           return this["f"];
+       }                                                                                                         
+
         function Main() {
 
             this.printok1();
-            this.s0 = "ok 2/4";
+            this.s0 = "ok 2/5";
             this.printok2(0);
 
             // member w/ default value:
             trace(this.s1);
 
             //omit "this":
-            s2 = "ok 4/4";
+            s2 = "ok 4/5";
             printok3();
+
+           get_f()();
             
             trace("[exit]");
         }
index 02a968d..b377ba2 100644 (file)
@@ -3129,6 +3129,9 @@ NEW : "new" E XX MAYBE_PARAM_VALUES {
         $$.c = code_append($$.c, paramcode);
         $$.c = abc_constructprop2($$.c, name, $4.number);
         multiname_destroy(name);
+    } else if(is_getlocal($$.c)) {
+        $$.c = code_append($$.c, paramcode);
+        $$.c = abc_construct($$.c, $4.number);
     } else if(TYPE_IS_CLASS(v.t) && v.t->data) {
         code_free($$.c);
         classinfo_t*c = v.t->data;
index a458c3e..1100996 100755 (executable)
@@ -213,7 +213,7 @@ class TestBase:
         return 1
 
     def run(self):
-        ret,output = runcmd("flashplayer",["abc.swf"],wait=cache.runtime)
+        ret,output = runcmd("flashplayer",[os.path.join(os.getcwd(),"abc.swf")],wait=cache.runtime)
         os.system("killall flashplayer")
         self.flash_output = output
         
index 7b57674..3da6c22 100644 (file)
@@ -110,10 +110,10 @@ void handleInclude(char*text, int len, char quotes)
     } else {
         int i1=0,i2=len;
         // find start
-        while(!strchr(" \n\r\t", text[i1])) i1++;
+        while(!strchr(" \n\r\t\xa0", text[i1])) i1++;
         // strip
-        while(strchr(" \n\r\t", text[i1])) i1++;
-        while(strchr(" \n\r\t", text[i2-1])) i2--;
+        while(strchr(" \n\r\t\xa0", text[i1])) i1++;
+        while(strchr(" \n\r\t\xa0", text[i2-1])) i2--;
         if(i2!=len) text[i2]=0;
         filename = strdup(&text[i1]);
     }
@@ -533,7 +533,7 @@ XMLID       [A-Za-z0-9_\x80-\xff]+([:][A-Za-z0-9_\x80-\xff]+)?
 XMLSTRING   ["][^"]*["]
 
 STRING   ["](\\[\x00-\xff]|[^\\"\n])*["]|['](\\[\x00-\xff]|[^\\'\n])*[']
-S       [ \n\r\t]
+S       [ \n\r\t\xa0]
 MULTILINE_COMMENT [/][*]+([*][^/]|[^/*]|[^*][/]|[\x00-\x1f])*[*]+[/]
 SINGLELINE_COMMENT \/\/[^\n\r]*[\n\r]
 REGEXP   [/]([^/\n]|\\[/])*[/][a-zA-Z]*
@@ -545,7 +545,7 @@ REGEXP   [/]([^/\n]|\\[/])*[/][a-zA-Z]*
 [/][*]                       {syntaxerror("syntax error: unterminated comment", yytext);}
 
 ^include{S}+{STRING}{S}*/\n    {l();handleInclude(yytext, yyleng, 1);}
-^include{S}+[^" \t\r\n][\x20-\xff]*{S}*/\n    {l();handleInclude(yytext, yyleng, 0);}
+^include{S}+[^" \t\xa0\r\n][\x20-\xff]*{S}*/\n    {l();handleInclude(yytext, yyleng, 0);}
 {STRING}                     {l(); BEGIN(DEFAULT);handleString(yytext, yyleng);return T_STRING;}
 {CDATA}                      {l(); BEGIN(DEFAULT);handleCData(yytext, yyleng);return T_STRING;}