avm2: Support Array(...) without new
This commit is contained in:
parent
40318f905e
commit
128416cccd
|
@ -102,6 +102,19 @@ pub fn instance_init<'gc>(
|
|||
Ok(Value::Undefined)
|
||||
}
|
||||
|
||||
pub fn class_call<'gc>(
|
||||
activation: &mut Activation<'_, 'gc>,
|
||||
_this: Option<Object<'gc>>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
Ok(activation
|
||||
.avm2()
|
||||
.classes()
|
||||
.array
|
||||
.construct(activation, args)?
|
||||
.into())
|
||||
}
|
||||
|
||||
/// Implements `Array`'s class initializer.
|
||||
pub fn class_init<'gc>(
|
||||
activation: &mut Activation<'_, 'gc>,
|
||||
|
@ -1272,6 +1285,7 @@ pub fn create_class<'gc>(activation: &mut Activation<'_, 'gc>) -> GcCell<'gc, Cl
|
|||
let mut write = class.write(mc);
|
||||
|
||||
write.set_instance_allocator(array_allocator);
|
||||
write.set_call_handler(Method::from_builtin(class_call, "<Array call handler>", mc));
|
||||
|
||||
const PUBLIC_INSTANCE_PROPERTIES: &[(
|
||||
&str,
|
||||
|
|
|
@ -21,3 +21,12 @@ string
|
|||
/asdf/gi
|
||||
//RegExp(regexp)
|
||||
/asdf/gi
|
||||
|
||||
//Array().length
|
||||
0
|
||||
//Array(5)
|
||||
,,,,
|
||||
//Array("5")
|
||||
5
|
||||
//Array("a", "b", "c")
|
||||
a,b,c
|
||||
|
|
|
@ -51,4 +51,12 @@ trace("//RegExp(regexp)")
|
|||
pat = cls(pat);
|
||||
trace(pat);
|
||||
|
||||
|
||||
trace()
|
||||
trace("//Array().length")
|
||||
trace(Array().length)
|
||||
trace("//Array(5)")
|
||||
trace(Array(5))
|
||||
trace("//Array(\"5\")")
|
||||
trace(Array("5"))
|
||||
trace("//Array(\"a\", \"b\", \"c\")")
|
||||
trace(Array("a", "b", "c"))
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue