Browse Source

Fix `eval` attributes (#2130)

This Pull Request changes the following:

- Fix `eval` attributes
- Fix `eval` length
- Fix `eval` name
pull/2135/head
raskad 2 years ago
parent
commit
43f60e9bb1
  1. 20
      boa_engine/src/builtins/eval/mod.rs

20
boa_engine/src/builtins/eval/mod.rs

@ -10,8 +10,8 @@
//! [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval //! [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval
use crate::{ use crate::{
builtins::{function::Function, BuiltIn, JsArgs}, builtins::{BuiltIn, JsArgs},
object::{JsObject, ObjectData}, object::FunctionBuilder,
property::Attribute, property::Attribute,
Context, JsValue, Context, JsValue,
}; };
@ -24,20 +24,18 @@ pub(crate) struct Eval;
impl BuiltIn for Eval { impl BuiltIn for Eval {
const NAME: &'static str = "eval"; const NAME: &'static str = "eval";
const ATTRIBUTE: Attribute = Attribute::READONLY const ATTRIBUTE: Attribute = Attribute::CONFIGURABLE
.union(Attribute::NON_ENUMERABLE) .union(Attribute::NON_ENUMERABLE)
.union(Attribute::PERMANENT); .union(Attribute::WRITABLE);
fn init(context: &mut Context) -> Option<JsValue> { fn init(context: &mut Context) -> Option<JsValue> {
let _timer = Profiler::global().start_event(Self::NAME, "init"); let _timer = Profiler::global().start_event(Self::NAME, "init");
let object = JsObject::from_proto_and_data( let object = FunctionBuilder::native(context, Self::eval)
context.intrinsics().constructors().function().prototype(), .name("eval")
ObjectData::function(Function::Native { .length(1)
function: Self::eval, .constructor(false)
constructor: false, .build();
}),
);
Some(object.into()) Some(object.into())
} }

Loading…
Cancel
Save