avm2: Fix function prototype
This commit is contained in:
parent
bac18c1a84
commit
13ee356b8c
|
@ -2726,25 +2726,24 @@ impl<'a, 'gc> Activation<'a, 'gc> {
|
|||
Value::Bool(_) => "boolean",
|
||||
Value::Number(_) | Value::Integer(_) => "number",
|
||||
Value::Object(o) => {
|
||||
// Subclasses always have a typeof = "object", must be a subclass if the prototype chain is > 2, or not a subclass if <=2
|
||||
let is_not_subclass = o
|
||||
.proto()
|
||||
.and_then(|p| p.proto())
|
||||
.and_then(|p| p.proto())
|
||||
.is_none();
|
||||
let classes = self.avm2().classes();
|
||||
|
||||
match o {
|
||||
Object::FunctionObject(_) => {
|
||||
if is_not_subclass {
|
||||
if o.instance_class() == Some(classes.function.inner_class_definition()) {
|
||||
"function"
|
||||
} else {
|
||||
// Subclasses always have a typeof = "object"
|
||||
"object"
|
||||
}
|
||||
}
|
||||
Object::XmlObject(_) | Object::XmlListObject(_) => {
|
||||
if is_not_subclass {
|
||||
if o.instance_class() == Some(classes.xml_list.inner_class_definition())
|
||||
|| o.instance_class() == Some(classes.xml.inner_class_definition())
|
||||
{
|
||||
"xml"
|
||||
} else {
|
||||
// Subclasses always have a typeof = "object"
|
||||
"object"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -564,6 +564,10 @@ pub fn load_player_globals<'gc>(
|
|||
let object_class = object_class.into_finished_class(activation)?;
|
||||
let fn_class = fn_class.into_finished_class(activation)?;
|
||||
|
||||
// Function's prototype is an instance of itself
|
||||
let fn_proto = fn_class.construct(activation, &[])?;
|
||||
fn_class.link_prototype(activation, fn_proto)?;
|
||||
|
||||
// Construct the global class.
|
||||
let global_classdef = global_scope::create_class(activation);
|
||||
let global_class = ClassObject::from_class(activation, global_classdef, Some(object_class))?;
|
||||
|
|
|
@ -1,2 +1 @@
|
|||
num_frames = 1
|
||||
known_failure = true
|
||||
|
|
|
@ -1,2 +1 @@
|
|||
num_ticks = 1
|
||||
known_failure = true
|
||||
|
|
Loading…
Reference in New Issue