avm1: Set __constructor__ in Function::construct
This commit is contained in:
parent
d9c8c43cf3
commit
2faf35d43e
|
@ -1728,23 +1728,7 @@ impl<'a, 'gc: 'a> Activation<'a, 'gc> {
|
|||
.get("prototype", self, context)?
|
||||
.coerce_to_object(self, context);
|
||||
|
||||
let mut this = prototype.new(self, context, prototype, &args)?;
|
||||
this.set("__constructor__", constructor.into(), self, context)?;
|
||||
this.set_attributes(
|
||||
context.gc_context,
|
||||
Some("__constructor__"),
|
||||
Attribute::DontEnum.into(),
|
||||
EnumSet::empty(),
|
||||
);
|
||||
if self.current_swf_version() < 7 {
|
||||
this.set("constructor", constructor.into(), self, context)?;
|
||||
this.set_attributes(
|
||||
context.gc_context,
|
||||
Some("constructor"),
|
||||
Attribute::DontEnum.into(),
|
||||
EnumSet::empty(),
|
||||
);
|
||||
}
|
||||
let this = prototype.new(self, context, prototype, &args)?;
|
||||
|
||||
//TODO: What happens if you `ActionNewMethod` without a method name?
|
||||
constructor.construct(self, context, this, &args)?;
|
||||
|
@ -1781,23 +1765,7 @@ impl<'a, 'gc: 'a> Activation<'a, 'gc> {
|
|||
.get("prototype", self, context)?
|
||||
.coerce_to_object(self, context);
|
||||
|
||||
let mut this = prototype.new(self, context, prototype, &args)?;
|
||||
this.set("__constructor__", constructor.into(), self, context)?;
|
||||
this.set_attributes(
|
||||
context.gc_context,
|
||||
Some("__constructor__"),
|
||||
Attribute::DontEnum.into(),
|
||||
EnumSet::empty(),
|
||||
);
|
||||
if self.current_swf_version() < 7 {
|
||||
this.set("constructor", constructor.into(), self, context)?;
|
||||
this.set_attributes(
|
||||
context.gc_context,
|
||||
Some("constructor"),
|
||||
Attribute::DontEnum.into(),
|
||||
EnumSet::empty(),
|
||||
);
|
||||
}
|
||||
let this = prototype.new(self, context, prototype, &args)?;
|
||||
|
||||
constructor.construct(self, context, this, &args)?;
|
||||
|
||||
|
|
|
@ -578,9 +578,25 @@ impl<'gc> TObject<'gc> for FunctionObject<'gc> {
|
|||
&self,
|
||||
activation: &mut Activation<'_, 'gc>,
|
||||
context: &mut UpdateContext<'_, 'gc, '_>,
|
||||
this: Object<'gc>,
|
||||
mut this: Object<'gc>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
this.set("__constructor__", (*self).into(), activation, context)?;
|
||||
this.set_attributes(
|
||||
context.gc_context,
|
||||
Some("__constructor__"),
|
||||
Attribute::DontEnum.into(),
|
||||
EnumSet::empty(),
|
||||
);
|
||||
if activation.current_swf_version() < 7 {
|
||||
this.set("constructor", (*self).into(), activation, context)?;
|
||||
this.set_attributes(
|
||||
context.gc_context,
|
||||
Some("constructor"),
|
||||
Attribute::DontEnum.into(),
|
||||
EnumSet::empty(),
|
||||
);
|
||||
}
|
||||
if let Some(exec) = &self.data.read().constructor {
|
||||
exec.exec(
|
||||
"[ctor]",
|
||||
|
|
Loading…
Reference in New Issue