-
-
Notifications
You must be signed in to change notification settings - Fork 411
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle
__proto__
fields in object literals (#2423)
This Pull Request changes the following: - Handle `__proto__` fields in object literals
- Loading branch information
Showing
13 changed files
with
154 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
use crate::{ | ||
vm::{opcode::Operation, ShouldExit}, | ||
Context, JsResult, | ||
}; | ||
|
||
/// `SetPrototype` implements the Opcode Operation for `Opcode::SetPrototype` | ||
/// | ||
/// Operation: | ||
/// - Sets the prototype of an object. | ||
#[derive(Debug, Clone, Copy)] | ||
pub(crate) struct SetPrototype; | ||
|
||
impl Operation for SetPrototype { | ||
const NAME: &'static str = "SetPrototype"; | ||
const INSTRUCTION: &'static str = "INST - SetPrototype"; | ||
|
||
fn execute(context: &mut Context) -> JsResult<ShouldExit> { | ||
let value = context.vm.pop(); | ||
let object = context.vm.pop(); | ||
|
||
let prototype = if let Some(prototype) = value.as_object() { | ||
Some(prototype.clone()) | ||
} else if value.is_null() { | ||
None | ||
} else { | ||
return Ok(ShouldExit::False); | ||
}; | ||
|
||
let object = object.as_object().expect("object is not an object"); | ||
object | ||
.__set_prototype_of__(prototype, context) | ||
.expect("cannot fail per spec"); | ||
|
||
Ok(ShouldExit::False) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters