]> gitweb @ CieloNegro.org - youtube-dl.git/commitdiff
[swfinterp] Add support for void methods
authorPhilipp Hagemeister <phihag@phihag.de>
Mon, 17 Nov 2014 03:36:23 +0000 (04:36 +0100)
committerPhilipp Hagemeister <phihag@phihag.de>
Mon, 17 Nov 2014 03:36:23 +0000 (04:36 +0100)
test/swftests/PrivateVoidCall.as [new file with mode: 0644]
youtube_dl/swfinterp.py

diff --git a/test/swftests/PrivateVoidCall.as b/test/swftests/PrivateVoidCall.as
new file mode 100644 (file)
index 0000000..2cc0167
--- /dev/null
@@ -0,0 +1,22 @@
+// input: []
+// output: 9
+
+package {
+public class PrivateVoidCall {
+    public static function main():int{
+        var f:OtherClass = new OtherClass();
+        f.func();
+        return 9;
+    }
+}
+}
+
+class OtherClass {
+    private function pf():void {
+        ;
+    }
+
+    public function func():void {
+        this.pf();
+    }
+}
index dd4dd060ad1fa8041c6351408ab9f79996390e0c..f4ee022f4e3fc3052f6ca9fbb9e19c5653b08a93 100644 (file)
@@ -504,6 +504,9 @@ class SWFInterpreter(object):
                     raise NotImplementedError(
                         'Unsupported property %r on %r'
                         % (mname, obj))
+                elif opcode == 71:  # returnvoid
+                    res = None
+                    return res
                 elif opcode == 72:  # returnvalue
                     res = stack.pop()
                     return res
@@ -527,6 +530,17 @@ class SWFInterpreter(object):
                     args = list(reversed(
                         [stack.pop() for _ in range(arg_count)]))
                     obj = stack.pop()
+                    if isinstance(obj, _AVMClass_Object):
+                        func = self.extract_function(obj.avm_class, mname)
+                        res = func(args)
+                        assert res is None
+                        continue
+                    if isinstance(obj, _ScopeDict):
+                        assert mname in obj.avm_class.method_names
+                        func = self.extract_function(obj.avm_class, mname)
+                        res = func(args)
+                        assert res is None
+                        continue
                     if mname == 'reverse':
                         assert isinstance(obj, list)
                         obj.reverse()
@@ -603,7 +617,8 @@ class SWFInterpreter(object):
                         obj = stack.pop()
                         assert isinstance(obj, (dict, _ScopeDict)), \
                             'Accessing member %r on %r' % (pname, obj)
-                        stack.append(obj[pname])
+                        res = obj.get(pname, None)
+                        stack.append(res)
                     else:  # Assume attribute access
                         idx = stack.pop()
                         assert isinstance(idx, int)