-
-
Notifications
You must be signed in to change notification settings - Fork 408
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
767 additions
and
86 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
use crate::{ | ||
builtins::function::BuiltInFunction, | ||
object::{JsObject, Object}, | ||
property::PropertyDescriptor, | ||
Context, JsResult, JsValue, | ||
}; | ||
|
||
use super::function::Function; | ||
|
||
#[derive(Debug, Default)] | ||
pub struct Intrinsics { | ||
throw_type_error: JsObject, | ||
} | ||
|
||
impl Intrinsics { | ||
pub fn init(context: &mut Context) -> Intrinsics { | ||
Self { | ||
throw_type_error: create_throw_type_error(context), | ||
} | ||
} | ||
|
||
pub fn throw_type_error(&self) -> JsObject { | ||
self.throw_type_error.clone() | ||
} | ||
} | ||
|
||
fn create_throw_type_error(context: &mut Context) -> JsObject { | ||
fn throw_type_error(_: &JsValue, _: &[JsValue], context: &mut Context) -> JsResult<JsValue> { | ||
context.throw_type_error("generic type error") | ||
} | ||
let mut function = Object::function( | ||
Function::Native { | ||
function: BuiltInFunction(throw_type_error), | ||
constructable: false, | ||
}, | ||
context | ||
.standard_objects() | ||
.function_object() | ||
.prototype() | ||
.into(), | ||
); | ||
let property = PropertyDescriptor::builder() | ||
.writable(false) | ||
.enumerable(false) | ||
.configurable(false); | ||
function.insert_property("name", property.clone().value("ThrowTypeError")); | ||
function.insert_property("length", property.value(0)); | ||
|
||
JsObject::new(function) | ||
} |
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
Oops, something went wrong.