Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions core/common/src/avm_string/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ define_common_strings! {
str_bold: b"bold",
str_boldItalic: b"boldItalic",
str_boolean: b"boolean",
str_Boolean: b"Boolean",
str_broadcastMessage: b"broadcastMessage",
str_builtInItems: b"builtInItems",
str_bytesLoaded: b"bytesLoaded",
Expand Down Expand Up @@ -187,6 +188,7 @@ define_common_strings! {
str_normal: b"normal",
str_null: b"null",
str_number: b"number",
str_Number: b"Number",
str_object: b"object",
str_onCancel: b"onCancel",
str_onChanged: b"onChanged",
Expand Down Expand Up @@ -272,6 +274,7 @@ define_common_strings! {
str_standardExtended: b"standardExtended",
str_status: b"status",
str_string: b"string",
str_String: b"String",
str_subpixel: b"subpixel",
str_subtract: b"subtract",
str_success: b"success",
Expand Down
34 changes: 17 additions & 17 deletions core/src/avm1/activation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ impl<'a, 'gc> Activation<'a, 'gc> {
return Ok(FrameControl::Continue);
}

let object = object_val.coerce_to_object(self);
let object = object_val.coerce_to_object_or_bare(self)?;

let method_name = if method_name == Value::Undefined {
istr!(self, "")
Expand All @@ -811,12 +811,12 @@ impl<'a, 'gc> Activation<'a, 'gc> {

fn action_cast_op(&mut self) -> Result<FrameControl<'gc>, Error<'gc>> {
let obj = self.context.avm1.pop();
let constr = self.context.avm1.pop().coerce_to_object(self);
let constr = self.context.avm1.pop().coerce_to_object_or_bare(self)?;

let is_instance_of = if let Some(obj) = obj.as_object(self) {
let prototype = constr
.get(istr!(self, "prototype"), self)?
.coerce_to_object(self);
.coerce_to_object_or_bare(self)?;
obj.is_instance_of(self, constr, prototype)?
} else {
false
Expand Down Expand Up @@ -1034,8 +1034,8 @@ impl<'a, 'gc> Activation<'a, 'gc> {
}

fn action_extends(&mut self) -> Result<FrameControl<'gc>, Error<'gc>> {
let superclass = self.context.avm1.pop().coerce_to_object(self);
let subclass = self.context.avm1.pop().coerce_to_object(self);
let superclass = self.context.avm1.pop().coerce_to_object_or_bare(self)?;
let subclass = self.context.avm1.pop().coerce_to_object_or_bare(self)?;

//TODO: What happens if we try to extend an object which has no `prototype`?
//e.g. `class Whatever extends Object.prototype` or `class Whatever extends 5`
Expand Down Expand Up @@ -1066,7 +1066,7 @@ impl<'a, 'gc> Activation<'a, 'gc> {
let name_val = self.context.avm1.pop();
let name = name_val.coerce_to_string(self)?;
let object_val = self.context.avm1.pop();
let object = object_val.coerce_to_object(self);
let object = object_val.coerce_to_object_or_bare(self)?;

let result = object.get(name, self)?;
self.stack_push(result);
Expand Down Expand Up @@ -1433,7 +1433,7 @@ impl<'a, 'gc> Activation<'a, 'gc> {
}

fn action_implements_op(&mut self) -> Result<FrameControl<'gc>, Error<'gc>> {
let constructor = self.context.avm1.pop().coerce_to_object(self);
let constructor = self.context.avm1.pop().coerce_to_object_or_bare(self)?;
let count = self.context.avm1.pop();
// Old Flash Players (at least FP9) used to coerce objects as well. However, this was
// changed at some point and instead the following is logged:
Expand All @@ -1454,26 +1454,26 @@ impl<'a, 'gc> Activation<'a, 'gc> {
// TODO: If one of the interfaces is not an object, do we leave the
// whole stack dirty, or...?
for _ in 0..count {
interfaces.push(self.context.avm1.pop().coerce_to_object(self));
interfaces.push(self.context.avm1.pop().coerce_to_object_or_bare(self)?);
}

let prototype = constructor
.get(istr!(self, "prototype"), self)?
.coerce_to_object(self);
.coerce_to_object_or_bare(self)?;
prototype.set_interfaces(self.gc(), interfaces);
}

Ok(FrameControl::Continue)
}

fn action_instance_of(&mut self) -> Result<FrameControl<'gc>, Error<'gc>> {
let constr = self.context.avm1.pop().coerce_to_object(self);
let constr = self.context.avm1.pop().coerce_to_object_or_bare(self)?;
let obj = self.context.avm1.pop();

let result = if let Some(obj) = obj.as_object(self) {
let prototype = constr
.get(istr!(self, "prototype"), self)?
.coerce_to_object(self);
.coerce_to_object_or_bare(self)?;
obj.is_instance_of(self, constr, prototype)?
} else {
false
Expand Down Expand Up @@ -1640,7 +1640,7 @@ impl<'a, 'gc> Activation<'a, 'gc> {
return Ok(FrameControl::Continue);
}

let object = object_val.coerce_to_object(self);
let object = object_val.coerce_to_object_or_bare(self)?;

let method_name = if method_name == Value::Undefined {
istr!(self, "")
Expand Down Expand Up @@ -1678,7 +1678,7 @@ impl<'a, 'gc> Activation<'a, 'gc> {
let args = self.pop_call_args(num_args);

let name_value: Value<'gc> = self.resolve(fn_name)?.into();
let constructor = name_value.coerce_to_object(self);
let constructor = name_value.coerce_to_object_or_bare(self)?;
let result = constructor.construct(self, &args)?;
self.stack_push(result);

Expand Down Expand Up @@ -1807,7 +1807,7 @@ impl<'a, 'gc> Activation<'a, 'gc> {
let name_val = self.context.avm1.pop();
let name = name_val.coerce_to_string(self)?;

let object = self.context.avm1.pop().coerce_to_object(self);
let object = self.context.avm1.pop().coerce_to_object_or_bare(self)?;
object.set(name, value, self)?;

Ok(FrameControl::Continue)
Expand Down Expand Up @@ -1915,7 +1915,7 @@ impl<'a, 'gc> Activation<'a, 'gc> {
}
}
Value::MovieClip(_) => {
let o = target.coerce_to_object(self);
let o = target.coerce_to_object_or_bare(self)?;
if let Some(clip) = o.as_display_object() {
// MovieClips can be targeted directly.
self.set_target_clip(Some(clip));
Expand Down Expand Up @@ -2086,7 +2086,7 @@ impl<'a, 'gc> Activation<'a, 'gc> {
fn action_target_path(&mut self) -> Result<FrameControl<'gc>, Error<'gc>> {
// Prints out the dot-path for the parameter.
// Parameter must be a display object (not a string path).
let param = self.context.avm1.pop().coerce_to_object(self);
let param = self.context.avm1.pop().coerce_to_object_or_bare(self)?;
let result = if let Some(display_object) = param.as_display_object() {
let path = display_object.path();
AvmString::new(self.gc(), path).into()
Expand Down Expand Up @@ -2308,7 +2308,7 @@ impl<'a, 'gc> Activation<'a, 'gc> {

value => {
// Note that primitives get boxed at this point.
let object = value.coerce_to_object(self);
let object = value.coerce_to_object_or_bare(self)?;
let with_scope = Gc::new(self.gc(), Scope::new_with_scope(self.scope(), object));
let mut new_activation = self.with_new_scope("[With]", with_scope);
if let ReturnType::Explicit(value) = new_activation.run_actions(code)? {
Expand Down
8 changes: 4 additions & 4 deletions core/src/avm1/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -563,12 +563,12 @@
match self.function {
Executable::Native(nf) => {
// TODO: Change NativeFunction to accept `this: Value`.
let this = this.coerce_to_object(activation);
let this = this.coerce_to_object_or_bare(activation)?;
nf(activation, this, args)
}
Executable::TableNative { native, index } => {
// TODO: Change TableNativeFunction to accept `this: Value`.
let this = this.coerce_to_object(activation);
let this = this.coerce_to_object_or_bare(activation)?;
native(activation, this, args, index)
}
Executable::Action(af) => af.exec(name, activation, this, depth, args, reason, callee),
Expand Down Expand Up @@ -596,12 +596,12 @@
match constr {
Executable::Native(nf) => {
// TODO: Change NativeFunction to accept `this: Value`.
let this = this.coerce_to_object(activation);
let this = this.coerce_to_object_or_bare(activation)?;
nf(activation, this, args)
}
Executable::TableNative { native, index } => {
// TODO: Change TableNativeFunction to accept `this: Value`.
let this = this.coerce_to_object(activation);
let this = this.coerce_to_object_or_bare(activation)?;

Check warning on line 604 in core/src/avm1/function.rs

View workflow job for this annotation

GitHub Actions / Coverage Report

Coverage

Uncovered line (604)
native(activation, this, args, index)
}
Executable::Action(af) => af.exec(name, activation, this, depth, args, reason, callee),
Expand Down
18 changes: 0 additions & 18 deletions core/src/avm1/globals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -498,29 +498,20 @@ pub struct SystemPrototypes<'gc> {
pub object_constructor: Object<'gc>,
pub function: Object<'gc>,
pub movie_clip: Object<'gc>,
pub sound: Object<'gc>,
pub text_field: Object<'gc>,
pub text_format: Object<'gc>,
pub array: Object<'gc>,
pub array_constructor: Object<'gc>,
pub xml_node_constructor: Object<'gc>,
pub xml_constructor: Object<'gc>,
pub string: Object<'gc>,
pub number: Object<'gc>,
pub boolean: Object<'gc>,
pub matrix: Object<'gc>,
pub matrix_constructor: Object<'gc>,
pub point: Object<'gc>,
pub point_constructor: Object<'gc>,
pub rectangle: Object<'gc>,
pub rectangle_constructor: Object<'gc>,
pub transform_constructor: Object<'gc>,
pub shared_object_constructor: Object<'gc>,
pub color_transform: Object<'gc>,
pub color_transform_constructor: Object<'gc>,
pub context_menu: Object<'gc>,
pub context_menu_constructor: Object<'gc>,
pub context_menu_item: Object<'gc>,
pub context_menu_item_constructor: Object<'gc>,
pub date_constructor: Object<'gc>,
pub bitmap_data: Object<'gc>,
Expand Down Expand Up @@ -744,29 +735,20 @@ pub fn create_globals<'gc>(
object_constructor: object.constr,
function: function.proto,
movie_clip: movie_clip.proto,
sound: sound.proto,
text_field: text_field.proto,
text_format: text_format.proto,
array: array.proto,
array_constructor: array.constr,
xml_node_constructor: xmlnode.constr,
xml_constructor: xml.constr,
string: string.proto,
number: number.proto,
boolean: boolean.proto,
matrix: matrix.proto,
matrix_constructor: matrix.constr,
point: point.proto,
point_constructor: point.constr,
rectangle: rectangle.proto,
rectangle_constructor: rectangle.constr,
transform_constructor: transform.constr,
shared_object_constructor: shared_object.constr,
color_transform: color_transform.proto,
color_transform_constructor: color_transform.constr,
context_menu: context_menu.proto,
context_menu_constructor: context_menu.constr,
context_menu_item: context_menu_item.proto,
context_menu_item_constructor: context_menu_item.constr,
date_constructor: date.constr,
bitmap_data: bitmap_data.proto,
Expand Down
2 changes: 1 addition & 1 deletion core/src/avm1/globals/as_broadcaster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ fn initialize<'gc>(
_this: Object<'gc>,
args: &[Value<'gc>],
) -> Result<Value<'gc>, Error<'gc>> {
let broadcaster = args.get_object(activation, 0);
let broadcaster = args.get_object(activation, 0)?;
initialize_internal(
&activation.context.strings,
broadcaster,
Expand Down
Loading
Loading