Commit Graph

1415 Commits

Author SHA1 Message Date
David Wendt 73966f1b31 Make sure that we actually call the super constructor, not our own constructor. 2020-07-13 17:44:17 -04:00
David Wendt 1b67bb94c8 Impl `callsuper`, `callsupervoid`, and `constructsuper`.
This works primarily by retaining the current superclass prototype in the activation object and then using it to retrieve the super method.

For constructors, we implement the `constructor` property, which is probably not the correct way to do this.
2020-07-13 17:44:15 -04:00
David Wendt f3dee5c310 Add (currently failing) test for constructors. 2020-07-13 17:44:14 -04:00
David Wendt a77f676279 `construct` and `constructprop` should push the object that was just constructed. 2020-07-13 17:44:13 -04:00
David Wendt 0fc9b9a287 `construct` and `constructprop` should take their args in reverse-order like the call functions do. 2020-07-13 17:44:13 -04:00
David Wendt 9431e02802 The class function should use the *instance* initializer as it's callable, not the class initializer. 2020-07-13 17:44:13 -04:00
David Wendt bedf5cb459 Add a basic test for function calls. 2020-07-13 17:44:13 -04:00
David Wendt 38868fbdfe Args are pushed onto the stack in normal order, so we need to pop them off in reverse order. 2020-07-13 17:44:12 -04:00
David Wendt a2dfffc56e Add our first AVM2 regression test: hello world! 2020-07-13 17:44:09 -04:00
David Wendt 7d576203c9 Impl `coerce_a`.
This currently treats `coerce_a` as a no-op. Strictly speaking, this is for type verification purposes, but we currently don't type-verify ABC code. Ergo, this requires no VM support at this time.
2020-07-13 17:43:50 -04:00
David Wendt a0ab978bed Impl `callmethod`, `callproperty`, `callproplex`, `callpropvoid`, and `callstatic`.
Also, implement a method table that method traits can optionally add themselves to.

Also also, add the ability to invoke a method without a `this` object. This required a non-trivial refactoring of the activation machinery, and changes to the signature of `NativeFunction`, and all native AVM2 functions.
2020-07-13 17:43:49 -04:00
David Wendt 68cf9e8869 Upon encountering an `Err`, dispose of the current AVM2 stack.
In the future, the `unwrap_stack_frame` mechanism should be expanded upon to allow running exception handlers and recovering from a Rust error - but not today.
2020-07-13 17:43:49 -04:00
David Wendt a7ff2de476 Don't spam the test log with `Resolving Multiname` messages for each scope that gets checked 2020-07-13 17:43:48 -04:00
David Wendt dd6b0a8728 Remove unused reference to slot property fields 2020-07-13 17:43:48 -04:00
David Wendt bf45f7f161 Fix crash when reading or writing a property that redirects to a slot. 2020-07-13 17:43:48 -04:00
David Wendt 7792fd5581 Impl `trace`, which is a free function rather than an opcode this time. 2020-07-13 17:43:48 -04:00
David Wendt a557867c71 Add the entire class hierarchy of `MovieClip` and `Sprite`. 2020-07-13 17:43:47 -04:00
David Wendt f6e2ca1fe5 Clean up the current set of builtins to accurately reflect the namespace hierarchy. 2020-07-13 17:43:47 -04:00
David Wendt 38b1524a49 Fix the error messages for `findpropstrict` and `getlex` to be more informative. 2020-07-13 17:43:47 -04:00
David Wendt 843de29460 Impl `newobject` 2020-07-13 17:43:46 -04:00
David Wendt 7201f6c4fe Impl `debug`, `debugfile` and `debugline`. 2020-07-13 17:43:46 -04:00
David Wendt 1d1bad1ab4 Impl `getglobalscope` 2020-07-13 17:43:46 -04:00
David Wendt 074ba94c17 Impl `newfunction` and `newclass`.
Notably, this also removes `new_closure_scope` as it is not needed. AVM1 does not capture `with` scopes in closures, but AVM2 (as well as modern ECMAScript) does.
2020-07-13 17:43:46 -04:00
David Wendt 1fe73b3329 Impl `dup` 2020-07-13 17:43:45 -04:00
David Wendt 0ff1c04697 Impl `initproperty` 2020-07-13 17:43:45 -04:00
David Wendt 5042fc1bc7 Debug all multiname resolutions 2020-07-13 17:43:44 -04:00
David Wendt 5c0e095ab5 `getlex` does not support runtime multinames according to spec. 2020-07-13 17:43:44 -04:00
David Wendt 9e120c216b Propagate arguments into local registers when calling AVM functions. 2020-07-13 17:43:44 -04:00
David Wendt 5b00c1fd96 Ensure that `this` is properly populated into local registers. 2020-07-13 17:43:44 -04:00
David Wendt b2f5307213 Add `flash.display.Sprite` because Flash Builder tests demand it. 2020-07-13 17:43:42 -04:00
David Wendt 4ab9a46515 Impl `getscopeobject` 2020-07-13 17:43:41 -04:00
David Wendt 5f98a198cb Remove dead code in Activation 2020-07-13 17:43:41 -04:00
David Wendt 279d90ec22 Remove `define_value` from AVM2 objects.
We already have a menagerie of `install_*` functions for adding static properties to a an object; and we don't have to support any kind of asinine nonsense liks `ASSetPropFlags` here. Ergo, we don't need this.
2020-07-13 17:43:39 -04:00
David Wendt cbce8660bc Implement `deleteproperty`. 2020-07-13 17:43:37 -04:00
David Wendt d19d9ef90e Clean up unused variables 2020-07-13 17:43:35 -04:00
David Wendt 8b56973d29 Remove scope methods that aren't necessary.
In AVM1, these are necessary because `ActionGetVariable` et. all directly interface with the scope chain. In AVM2, you `findpropstrict` up the scope chain, which gives you a normal object that you can interact with as you like. Ergo, the scope chain doesn't need set/get property methods.
2020-07-13 17:43:34 -04:00
David Wendt fd275bdcf3 Implement constant slots and traits.
Class and Function traits now generate const slots, too.
2020-07-13 17:43:33 -04:00
David Wendt 412c3d8489 Implement `Function` traits. 2020-07-13 17:43:29 -04:00
David Wendt af70024f62 Implement slot traits. 2020-07-13 17:43:28 -04:00
David Wendt 200c10b4a2 Classes can fit in slots, so let's stick them in there. 2020-07-13 17:43:27 -04:00
David Wendt d42b16f021 Add stub impl of `flash.display.MovieClip`. 2020-07-13 17:43:27 -04:00
David Wendt ebcfee4676 Add specific error messages for unresolvable super classes 2020-07-13 17:43:27 -04:00
David Wendt 362294181f Implement constant pool default values (index 0).
All constant pools in an ABC file are actually numbered starting from one; there's an implicit 0 entry not stored in the file that the runtime is expected to retrieve when pulling constants from the pool.

The AVM2/ABC spec only mentions this in passing.
2020-07-13 17:43:27 -04:00
David Wendt e1916519dd Add debug for trait installs 2020-07-13 17:43:26 -04:00
David Wendt cfe0e333be Fix invalid script index when loading an ABC file. 2020-07-13 17:43:26 -04:00
David Wendt bc0bdf8496 The public namespace appears to just be an unnamed package namespace, not a regular namespace. 2020-07-13 17:43:25 -04:00
David Wendt 04879fc419 Implement class traits.
This allows the AVM to declare classes, which necessitated some refactoring to avoid double-borrows or having to do something "magic" that would dodge virtual properties.
2020-07-13 17:43:25 -04:00
David Wendt ecfd5abb41 Impl `construct` and `constructprop`. 2020-07-13 17:43:24 -04:00
David Wendt 1ab4091050 Implement slots and related opcodes. 2020-07-13 17:43:24 -04:00
David Wendt 88957b2b3d Add stub builtins for Object and Function. These are more-or-less identical to the way we did it in AVM1 (e.g. no fancy player globals file) 2020-07-13 17:43:24 -04:00
David Wendt 1945f36dc0 When running the initial script, also install it's traits onto the global scope. 2020-07-13 17:43:23 -04:00
David Wendt 35c36a807b Always execute the last script when loading an ABC file 2020-07-13 17:43:23 -04:00
David Wendt 560900e708 ABC files are always pre-loaded.
Frame actions are handled as syntactic sugar on top of a `MovieClip` subclass and event handlers. ABC scripts do not live on the normal timeline.
2020-07-13 17:43:23 -04:00
David Wendt 502936f0fe Implement non-slot trait properties (Method, Getter, and Setter) 2020-07-13 17:43:22 -04:00
David Wendt 12e9fbbffb Impl virtual property slots 2020-07-13 17:43:22 -04:00
David Wendt eb0c9dcaec Allow constructing a function around a particular class definition.
I'm writing all this code assuming that classes and traits are syntactic sugar around ES3-style prototype chains on function objects. Hence, `FunctionObject` is still our workhorse object type for implementing typing.
2020-07-13 17:43:21 -04:00
David Wendt cf490bedfb Unstub `proto`. 2020-07-13 17:43:20 -04:00
David Wendt b12c6e0ff1 Implement closure scope stacks. 2020-07-13 17:43:20 -04:00
David Wendt 7d75255a1a Add global scope which is automatically included on all new activations. 2020-07-13 17:43:20 -04:00
David Wendt 984e701142 Swap out `has_property`'s stub impl. 2020-07-13 17:43:19 -04:00
David Wendt e5142e85e9 Replace `get_property` and `set_property` with slightly-less-stub impls. 2020-07-13 17:43:17 -04:00
David Wendt d56db06447 Implement `resolve_multiname`, sort of. 2020-07-13 17:43:16 -04:00
David Wendt 78a1c9a7e3 Implement `pushscope`, `popscope`, and `pushwith`. 2020-07-13 17:43:16 -04:00
David Wendt 5e6fc79f42 Implement `getproperty`, `setproperty` 2020-07-13 17:43:15 -04:00
David Wendt 60c16b0a60 Implement `findproperty`, `findpropstrict`, and `getlex`; which are necessary for interacting with global scope. 2020-07-13 17:43:15 -04:00
David Wendt 3c8035f871 clippy pls 2020-07-13 17:43:14 -04:00
David Wendt 12223d524a Add support methods in `Scope` to support opcodes that traverse the scope chain. 2020-07-13 17:43:14 -04:00
David Wendt 0ff1ba7120 Multiname resolution is another object method. 2020-07-13 17:43:14 -04:00
David Wendt 376d1a8ca6 Add scope support 2020-07-13 17:43:13 -04:00
David Wendt 3b476cba9e Implement `pushnamespace` since that's a value type now 2020-07-13 17:43:13 -04:00
David Wendt 1a6acb9440 Implement late binding and runtime qualifications for names. 2020-07-13 17:43:12 -04:00
David Wendt 2f3a3aff6f Add exact type assertion methods for strings and namespace values. 2020-07-13 17:43:11 -04:00
David Wendt 6d8dc6e63d Pull ABC constant pool methods out of Avm2 and into Value.
The old methods still exist and do the same thing, but the Value methods
accept arbitrary AbcFile references.
2020-07-13 17:42:51 -04:00
David Wendt c65d93d063 Implement multinames, sans runtime namespace support. 2020-07-13 17:42:50 -04:00
David Wendt 6bd94d6bc9 `from_abc_namespace` should accept a namespace index and retrieve it from the file's constant pool itself. 2020-07-13 17:42:50 -04:00
David Wendt 43f1080fab Implement namespaces as a value type 2020-07-13 17:42:49 -04:00
David Wendt 52ac7a6583 Implement call/return for bare functions 2020-07-13 17:42:49 -04:00
David Wendt 115f0393aa Add `call` method to the object trait. Only functions are callable in AVM2, all others error out. 2020-07-13 17:42:48 -04:00
David Wendt d1aeae8e02 Add support for local registers in the interpreter. 2020-07-13 17:42:47 -04:00
David Wendt 4d000e1ce0 Implement `pushxyz` opcodes for all value types that we currently support. 2020-07-13 17:42:46 -04:00
David Wendt 5600ac477c Always execute any AVM2 code that may have been queued as a result of loading ABC files. 2020-07-13 17:42:45 -04:00
David Wendt 7f60fab1e5 Add the bare minimum necessary to get opcodes out of an ABC and into an interpreter loop.
Surprisingly enough, the "bare minimum" includes a stack, object model, and values already.
2020-07-13 17:42:45 -04:00
David Wendt e80c887261 Add a very basic object model to the AVM2 interpreter. 2020-07-13 17:42:44 -04:00
David Wendt b7f257e7c8 Add a path to get from the movie clip to the Avm2. 2020-07-13 17:42:43 -04:00
David Wendt a852a6939a Add an extremely trivial implementation for the AVM2 interpreter state. 2020-07-13 17:42:31 -04:00
Nathan Adams fba8ccda81 avm1: Rename Avm1String to AvmString 2020-07-13 10:12:54 -07:00
Nathan Adams d8f043fa1a avm1: Value::coerce_to_string returns an Avm1String, as it can avoid a clone-and-reallocate 2020-07-13 10:12:54 -07:00
Nathan Adams f0ef68cb16 avm1: Reenabled paused string-value tests during string refactor 2020-07-13 10:12:54 -07:00
Nathan Adams c60b2cf4fc avm1: Implement From<&'static str> for Value 2020-07-13 10:12:54 -07:00
Nathan Adams e03e3f6c4e avm1: Allow Avm1String to contain &'static str 2020-07-13 10:12:54 -07:00
Nathan Adams ad733f2f21 avm1: Add Avm1String which wraps Gc<String> 2020-07-13 10:12:54 -07:00
Nathan Adams 016b9db3c5 avm1: Change Value::String(String) to Value::String(Gc<String>) 2020-07-13 10:12:54 -07:00
CUB3D 0591c0fe4b core: Add functions to prototypes 2020-07-12 15:25:58 -07:00
CUB3D ab022b66e9 chore: Format and cleanup clippy lints 2020-07-12 15:25:58 -07:00
CUB3D 83cca044ad core: Add tests for ContextMenu and ContextMenuItem 2020-07-12 15:25:58 -07:00
CUB3D 46cd8eb507 core: Add ContextMenuItem 2020-07-12 15:25:58 -07:00
CUB3D 04ca652f98 core: ContextMenu fully implemented 2020-07-12 15:25:58 -07:00
CUB3D 73a98c7f78 core: Implement copy() for ContextMenu 2020-07-12 15:25:58 -07:00
CUB3D f3aa6f7f01 core: Add stub of ContextMenuItem 2020-07-12 15:25:58 -07:00
CUB3D c8fefc56b5 core: Add stubs for context menu 2020-07-12 15:25:58 -07:00