initial prototype of ruby interface
[swftools.git] / lib / as3 / notes.txt
1 -----------------------------------------------------------------------
2
3     var x = a
4     [ExcludeClass(...)]
5
6 [x=a at [ExcludeClass(...)] or x=a, then embed command?]
7
8 -----------------------------------------------------------------------
9
10     if(1==2)
11         return
12     i++
13
14 [return i++ or just return?]
15
16 -----------------------------------------------------------------------
17
18     x = 3
19     /abc/
20     y++
21
22 [x=3;regexp abc;y++ or x divided by abc divided by y++?]
23
24 -----------------------------------------------------------------------
25
26     x = 5
27     -obj
28
29 [x=5, evaluate "minus obj" or x=5-obj?]
30
31 -----------------------------------------------------------------------
32
33     x = y as X.z
34
35 [coerce y to static field z of X, or coerce y to X, then evaluate member z?]
36
37 -----------------------------------------------------------------------
38     if(1==2)
39         return
40     { myloop: i++;}
41
42 [return object:{myloop:i++} or execute code block with myloop label?]
43
44
45 -----------------------------------------------------------------------
46
47     for(i in a in a; ...)
48
49 [only after encountering the first ; it becomes clear that this is in
50  fact *not* a for-in loop]
51
52 -----------------------------------------------------------------------
53
54     var x = 
55     namespace1 ++ namespace2
56     function test()
57     {
58     }
59
60 [x = namespace1, increment namespace2? or is test in namespace2?]
61
62 -----------------------------------------------------------------------
63
64
65     x = (a[Math.random(100)] += 10)
66
67 code needed for this:
68
69     push a
70     calculate Math.random(100), push
71     dup2 [a.k.a. setlocal tmp, dup , getlocal tmp, swap, getlocal tmp]
72     getproperty (consumes two stack values)
73     [code for adding 10]
74     setlocal tmp (we don't have *any* kind of useful stack exchange operations, so no way around a local register)
75     setproperty (consumes two stack values again)
76     getlocal tmp
77     kill tmp (so the verifier is happy)
78     setlocal x (finally!)
79
80 -----------------------------------------------------------------------
81
82 VerifyError: Error #1030: Stack depth is unbalanced. 0 != 1.
83
84 0 : local position
85 1 : position I'm jumping to
86
87 -----------------------------------------------------------------------
88
89 Verifier is buggy:
90
91 verify test.package::Main()
92                         stack:
93                         scope: [global Object$ flash.events::EventDispatcher$ flash.display::DisplayObject$ flash.display::InteractiveObject$ flash.display::DisplayObjectContainer$ flash.display::Sprite$ flash.display::MovieClip$ test.package::Main$] 
94                          locals: test.package::Main 
95   0:getlocal0
96                         stack: test.package::Main
97                         scope: [global Object$ flash.events::EventDispatcher$ flash.display::DisplayObject$ flash.display::InteractiveObject$ flash.display::DisplayObjectContainer$ flash.display::Sprite$ flash.display::MovieClip$ test.package::Main$] 
98                          locals: test.package::Main 
99   1:pushscope
100                         stack:
101                         scope: [global Object$ flash.events::EventDispatcher$ flash.display::DisplayObject$ flash.display::InteractiveObject$ flash.display::DisplayObjectContainer$ flash.display::Sprite$ flash.display::MovieClip$ test.package::Main$] test.package::Main 
102                          locals: test.package::Main 
103   2:jump 7
104 B0:
105                         stack:
106                         scope: [global Object$ flash.events::EventDispatcher$ flash.display::DisplayObject$ flash.display::InteractiveObject$ flash.display::DisplayObjectContainer$ flash.display::Sprite$ flash.display::MovieClip$ test.package::Main$] test.package::Main 
107                          locals: test.package::Main? 
108   6:label
109 B1:
110                         stack:
111                         scope: [global Object$ flash.events::EventDispatcher$ flash.display::DisplayObject$ flash.display::InteractiveObject$ flash.display::DisplayObjectContainer$ flash.display::Sprite$ flash.display::MovieClip$ test.package::Main$] test.package::Main? 
112                          locals: test.package::Main? 
113   7:label
114                         stack:
115                         scope: [global Object$ flash.events::EventDispatcher$ flash.display::DisplayObject$ flash.display::InteractiveObject$ flash.display::DisplayObjectContainer$ flash.display::Sprite$ flash.display::MovieClip$ test.package::Main$] test.package::Main? 
116                          locals: test.package::Main? 
117   8:pushfalse
118                         stack: Boolean
119                         scope: [global Object$ flash.events::EventDispatcher$ flash.display::DisplayObject$ flash.display::InteractiveObject$ flash.display::DisplayObjectContainer$ flash.display::Sprite$ flash.display::MovieClip$ test.package::Main$] test.package::Main? 
120                          locals: test.package::Main? 
121   9:iftrue 6
122 VerifyError: Error #1068: test.package.Main and test.package.Main cannot be reconciled.
123
124         at test.package::Main()
125
126
127 static void xx_scopetest() 
128 {
129     /* findpropstrict doesn't just return a scope object- it
130        also makes it "active" somehow. Push local_0 on the
131        scope stack and read it back with findpropstrict, it'll
132        contain properties like "trace". Trying to find the same
133        property on a "vanilla" local_0 yields only a "undefined" */
134     //c = abc_findpropstrict(c, "[package]::trace");
135     
136     /*c = abc_getlocal_0(c);
137     c = abc_findpropstrict(c, "[package]::trace");
138     c = abc_coerce_a(c);
139     c = abc_setlocal_1(c);
140
141     c = abc_pushbyte(c, 0);
142     c = abc_setlocal_2(c);
143    
144     code_t*xx = c = abc_label(c);
145     c = abc_findpropstrict(c, "[package]::trace");
146     c = abc_pushstring(c, "prop:");
147     c = abc_hasnext2(c, 1, 2);
148     c = abc_dup(c);
149     c = abc_setlocal_3(c);
150     c = abc_callpropvoid(c, "[package]::trace", 2);
151     c = abc_getlocal_3(c);
152     c = abc_kill(c, 3);
153     c = abc_iftrue(c,xx);*/
154 }