gnash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gnash] Testcases for Gnash


From: Nicolas Cannasse
Subject: Re: [Gnash] Testcases for Gnash
Date: Sat, 04 Feb 2006 11:59:16 +0100
User-agent: Mozilla Thunderbird 1.0.7 (Windows/20050923)

strk wrote:
On Fri, Feb 03, 2006 at 11:06:36PM +0100, Nicolas Cannasse wrote:


AS2 opcodes are almost the same than AS1 one (actually AS2 compiler is generating to AS1 opcodes). There is only a few differences related to object inheritance and interface implementation. That means that most of the tests can be written in pure AS1 without any problem.


We're particularly interested in the inheritance and interface
implementations. I just found that Ming is capable of writing
'instanceof' blocks. That could be enough to test inheritance.
Anyway, I guess that [0x69] Extends and [0x2C] Implements would
actually be the only way to make real use of OO model, am I right ?

How does the '.prototype' thing relates to the new model ?
What happen on extends and implements ?

A test case showing something like this would be nice to have:

        class Base { ... }
        class Derived1 implments Base { .. }
        class Derived2 implments Derived2 { .. }

        var d = Derived2;
        if ( d instanceof Base ) {
                trace("PASSED: derived2 instance of Base");
        } else {
                trace("FAILED: derived2 not instance of Base");
        }

        ....

Is it possible at all with AS1 ?

No, you can't do that in pure AS1.

First in AS2 you can only implements interfaces (like Java). Interfaces are generated as empty classes :

interface MyInterface {
     function foo() : Void;
}

is then equivalent to :

MyInterface = function() {
}

The opcode [Implements] takes a list of interfaces and an AS2 "class" (which is just an AS1 function) and adds theses interfaces to the list of implemented classes. This list is not accessible from code afterwards, but it's used by [InstanceOf] to check the heritance pattern.

Push [MyInterface]
Push [1]; // number of interfaces on the stack
Push [MyClass]
Implements

As for [Extends], in AS1 you would write the following when inheriting :

MyClass.prototype.__proto__ = SuperClass.prototype;
MyClass.prototype.__constructor__ = SuperClass;

While AS2 generates the following bytecode :

Push [SuperClass]
Push [MyClass]
Extends

Which does all the prototype chaining for you.

Theses two opcodes are available starting from Player 6r89, so there is nothing new in terms of virtual machine in players 7 and 8.

Nicolas




reply via email to

[Prev in Thread] Current Thread [Next in Thread]