200f9809335d0cc79f6de65a81136ee26d576a13
[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     [calculate Math.random(100), gives us two stack values]
70     dup2 [a.k.a. setlocal tmp, dup , getlocal tmp, swap, getlocal tmp]
71     getproperty (consumes two stack values)
72     [code for adding 10]
73     setlocal tmp (we don't have *any* kind of useful stack exchange operations, so no way around a local register)
74     setproperty (consumes two stack values again)
75     getlocal tmp
76     kill tmp (so the verifier is happy)
77     setlocal x (finally!)
78
79 -----------------------------------------------------------------------
80
81 VerifyError: Error #1030: Stack depth is unbalanced. 0 != 1.
82
83 0 : local position
84 1 : position I'm jumping to
85
86 -----------------------------------------------------------------------
87
88 Verifier is buggy:
89
90 verify test.package::Main()
91                         stack:
92                         scope: [global Object$ flash.events::EventDispatcher$ flash.display::DisplayObject$ flash.display::InteractiveObject$ flash.display::DisplayObjectContainer$ flash.display::Sprite$ flash.display::MovieClip$ test.package::Main$] 
93                          locals: test.package::Main 
94   0:getlocal0
95                         stack: test.package::Main
96                         scope: [global Object$ flash.events::EventDispatcher$ flash.display::DisplayObject$ flash.display::InteractiveObject$ flash.display::DisplayObjectContainer$ flash.display::Sprite$ flash.display::MovieClip$ test.package::Main$] 
97                          locals: test.package::Main 
98   1:pushscope
99                         stack:
100                         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 
101                          locals: test.package::Main 
102   2:jump 7
103 B0:
104                         stack:
105                         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 
106                          locals: test.package::Main? 
107   6:label
108 B1:
109                         stack:
110                         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? 
111                          locals: test.package::Main? 
112   7:label
113                         stack:
114                         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? 
115                          locals: test.package::Main? 
116   8:pushfalse
117                         stack: Boolean
118                         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? 
119                          locals: test.package::Main? 
120   9:iftrue 6
121 VerifyError: Error #1068: test.package.Main and test.package.Main cannot be reconciled.
122
123         at test.package::Main()
124
125
126 static void xx_scopetest() 
127 {
128     /* findpropstrict doesn't just return a scope object- it
129        also makes it "active" somehow. Push local_0 on the
130        scope stack and read it back with findpropstrict, it'll
131        contain properties like "trace". Trying to find the same
132        property on a "vanilla" local_0 yields only a "undefined" */
133     //c = abc_findpropstrict(c, "[package]::trace");
134     
135     /*c = abc_getlocal_0(c);
136     c = abc_findpropstrict(c, "[package]::trace");
137     c = abc_coerce_a(c);
138     c = abc_setlocal_1(c);
139
140     c = abc_pushbyte(c, 0);
141     c = abc_setlocal_2(c);
142    
143     code_t*xx = c = abc_label(c);
144     c = abc_findpropstrict(c, "[package]::trace");
145     c = abc_pushstring(c, "prop:");
146     c = abc_hasnext2(c, 1, 2);
147     c = abc_dup(c);
148     c = abc_setlocal_3(c);
149     c = abc_callpropvoid(c, "[package]::trace", 2);
150     c = abc_getlocal_3(c);
151     c = abc_kill(c, 3);
152     c = abc_iftrue(c,xx);*/
153 }