David Wendt
e087a27e56
avm2: `Vector.sort` actually *does* calculate an indexed sort array, but then discards it.
...
Normally we could skip sorting, but values in the vector may have side effects when coerced. So we need to make sure coercions run, at least.
2021-09-02 17:57:58 -06:00
David Wendt
280fbbde45
avm2: Pick nits in `Vector`'s `instance_init`
2021-09-02 17:57:58 -06:00
David Wendt
2095c1831a
avm2: Replace some if expressions with easier-to-read equivalents
2021-09-02 17:57:58 -06:00
David Wendt
464605d015
avm2: Pre-allocate all the things
2021-09-02 17:57:58 -06:00
David Wendt
535f4fba58
swf: Pre-allocate the parameters when parsing a `TypeName`
2021-09-02 17:57:58 -06:00
David Wendt
bf4492c454
avm2: Add the legacy Vector types that old movies can use.
...
This one was rather tough to test, as I actually can't generate ABCs in Animate CC that reference these classes. I instead had to modify a compiled SWF to open the package-internal namespace that these pre-specialized classes exist in.
2021-09-02 17:57:58 -06:00
David Wendt
dcf6d87363
avm2: Accept `null` as a valid type in `applytype`.
...
In AVM2, the `*` (any) type is represented as `null`.
This requires also changing the parameters on classes and objects to be nullable, too.
We do *not* represent `null` as a particular value on the underyling vector storage object, however. We instead change it to `Object`, as that's the root of all other types.
This may require revision if non-`Object`-extending types appear in the future.
2021-09-02 17:57:58 -06:00
David Wendt
ee30f21e8e
avm2: Remove unnecessary `mut`
2021-09-02 17:57:58 -06:00
David Wendt
b452b653bf
tests: Add a test for `Vector`'s instance initializer.
2021-09-02 17:57:58 -06:00
David Wendt
aaddcc598f
avm2: Impl `Vector.toLocaleString` and test `toString`
2021-09-02 17:57:58 -06:00
David Wendt
d1e49db3cc
avm2: Stub `Number.toLocaleString`
...
This exists but is undocumented, and I accidentally wrote a Vector test that needs it.
2021-09-02 17:57:58 -06:00
David Wendt
dbc6f38c34
avm2: Impl `Vector.splice`
2021-09-02 17:57:58 -06:00
David Wendt
81d0775776
avm2: Impl `Vector.sort`
2021-09-02 17:57:58 -06:00
David Wendt
9fcd846a4d
avm2: Fix ineffective Vector typechecks
2021-09-02 17:57:58 -06:00
David Wendt
44a9f13047
avm2: Impl `Vector.slice`
2021-09-02 17:57:58 -06:00
David Wendt
077fd87842
avm2: Impl `Vector.reverse`
2021-09-02 17:57:58 -06:00
David Wendt
aa2d729a44
avm2: Impl `Vector.removeAt`
2021-09-02 17:57:58 -06:00
David Wendt
cea580e7c0
tests: Ensure we're testing push/shift/etc with empty vectors
2021-09-02 17:57:58 -06:00
David Wendt
a053015558
avm2: Impl `Vector.insertAt`
2021-09-02 17:57:58 -06:00
David Wendt
e3ad30a0f7
tests: Consolidate all of the type variants of each test into one test per function.
2021-09-02 17:57:58 -06:00
David Wendt
6b78e86ddc
avm2: Impl `Vector.shift` and `Vector.unshift`
2021-09-02 17:57:58 -06:00
David Wendt
1cfa9e0b28
avm2: Impl `Vector.push` and `.pop`
2021-09-02 17:57:58 -06:00
David Wendt
6350ce2dde
avm2: Impl `Vector.map`
2021-09-02 17:57:58 -06:00
David Wendt
7628b2b49a
avm2: Impl `Vector.lastIndexOf` (and the weird backward-index behavior of `indexOf`)
2021-09-02 17:57:58 -06:00
David Wendt
4624157ae0
avm2: Impl `Vector.indexOf`
2021-09-02 17:57:58 -06:00
David Wendt
62be772649
chore: Compliance with current clippy beta/nightly
2021-09-02 17:57:58 -06:00
David Wendt
622be142c3
avm2: Specialize generic classes when resolving types whose names have parameter names also in them.
...
Any is, as usual, special-cased. In this case, we treat it as specializing to `Object`, since all vectors should be coercible to `Object`.
2021-09-02 17:57:58 -06:00
David Wendt
c06a3c10d8
avm2: Impl `Vector.filter`
2021-09-02 17:57:58 -06:00
David Wendt
d079c647fa
avm2: Parameter types can be `*`.
2021-09-02 17:57:58 -06:00
David Wendt
f00234ce26
avm2: Consider specializations of generic classes to be of the same type as other specializations of the same class when their parameters are also of the same type.
...
For example, instances of `Vector.<Class>` are considered to be of type `Vector.<Interface>` in the same way that instances of `Class` are considered to be of type `Interface`. This assumes `Class` implements `Interface`.
This does *not* apply to the builtin coercions for numeric and string types, which do not extend to generic parameters. For example, `Vector.<uint>` is *not* coercible to `Vector.<int>`, even though it's contents *are*.
2021-09-02 17:57:58 -06:00
David Wendt
4d962f154e
avm2: Don't run initializers on vectors as they overwrite the existing vector storage.
2021-09-02 17:57:58 -06:00
David Wendt
fcc7c9e7ee
avm2: Propagate the specialized class parameter into the vector storage so that coercions happen correctly.
2021-09-02 17:57:58 -06:00
Adrian Wielgosik
2560bdc804
chore: Drop unnecessary mut
2021-09-02 17:57:58 -06:00
Adrian Wielgosik
846b53dc1b
avm2: Impl `Vector.forEach`
2021-09-02 17:57:58 -06:00
Adrian Wielgosik
8a77494b2f
avm2: Impl `Vector.some`
2021-09-02 17:57:58 -06:00
Adrian Wielgosik
519feb9af7
avm2: `Array.every/some` should early return
2021-09-02 17:57:58 -06:00
Adrian Wielgosik
07f979b582
avm2: `Vector.every` should early return
2021-09-02 17:57:58 -06:00
David Wendt
97e6f55110
avm2: Impl `Vector.every`
2021-09-02 17:57:58 -06:00
David Wendt
aa0946c64c
avm2: Impl `Vector.fixed`
2021-09-02 17:57:58 -06:00
David Wendt
01904acad3
tests: Add `Vector.<T>.join` tests
2021-09-02 17:57:58 -06:00
David Wendt
f255c7d577
tests: Add tests for multi-dimensional vector coercion typechecks & concatenation
2021-09-02 17:57:58 -06:00
David Wendt
841ed4b5e4
avm2: Setting to an out-of-bounds index on a growable `Vector` should grow it
2021-09-02 17:57:58 -06:00
David Wendt
238959d7f8
avm2: Impl `Vector.join` and `toString`
2021-09-02 17:57:58 -06:00
David Wendt
1ce7e4e642
avm2: `Vector` is a final class (no matter what the docs say)
2021-09-02 17:57:58 -06:00
David Wendt
ecf514969b
tests: Add a test for concatenating to lists of ES4 interfaces.
2021-09-02 17:57:58 -06:00
David Wendt
8740098e5d
tests: Recompile the `vector_es4class_concat` test
2021-09-02 17:57:58 -06:00
David Wendt
70b60d6bb4
tests: Recompile the concat test
2021-09-02 17:57:58 -06:00
David Wendt
dba9b18540
avm2: Impl `Vector.concat`
2021-09-02 17:57:58 -06:00
David Wendt
96afc5a6c2
avm2: Cache all `Vector` applications on the `Vector` class object.
...
This matches Flash Player behavior: notably, multiple applications of the same types see the same class and prototype, but different applications actually create new objects that don't share properties.
2021-09-02 17:57:58 -06:00
David Wendt
9a1b864988
tests: Add tests for `Vector.concat`
2021-09-02 17:57:58 -06:00