Skip to content

Commit

Permalink
pass the third argument to all array prototype methods
Browse files Browse the repository at this point in the history
  • Loading branch information
y21 committed Sep 9, 2024
1 parent 0df96a0 commit 2c2cdeb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 22 deletions.
13 changes: 0 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ members = [
"crates/dash_compiler",
"crates/dash_optimizer",
"crates/dash_vm",
"crates/dash_core",
"cli",
"testrunner",
"crates/dash_regex",
Expand Down
16 changes: 8 additions & 8 deletions crates/dash_vm/src/js_std/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ pub fn every(cx: CallContext) -> Result<Value, Value> {
for k in 0..len {
let pk = cx.scope.intern_usize(k);
let pkv = this.get_property(cx.scope, pk.into()).root(cx.scope)?;
let args = vec![pkv, Value::number(k as f64)];
let args = vec![pkv, Value::number(k as f64), this.clone()];
let test = callback
.apply(cx.scope, Value::undefined(), args)
.root(cx.scope)?
Expand All @@ -127,7 +127,7 @@ pub fn some(cx: CallContext) -> Result<Value, Value> {
for k in 0..len {
let pk = cx.scope.intern_usize(k);
let pkv = this.get_property(cx.scope, pk.into()).root(cx.scope)?;
let args = vec![pkv, Value::number(k as f64)];
let args = vec![pkv, Value::number(k as f64), this.clone()];
let test = callback
.apply(cx.scope, Value::undefined(), args)
.root(cx.scope)?
Expand Down Expand Up @@ -167,7 +167,7 @@ pub fn filter(cx: CallContext) -> Result<Value, Value> {
for k in 0..len {
let pk = cx.scope.intern_usize(k);
let pkv = this.get_property(cx.scope, pk.into()).root(cx.scope)?;
let args = vec![pkv.clone(), Value::number(k as f64)];
let args = vec![pkv.clone(), Value::number(k as f64), this.clone()];
let test = callback
.apply(cx.scope, Value::undefined(), args)
.root(cx.scope)?
Expand Down Expand Up @@ -208,7 +208,7 @@ pub fn reduce(cx: CallContext) -> Result<Value, Value> {
for k in start..len {
let pk = cx.scope.intern_usize(k);
let pkv = this.get_property(cx.scope, pk.into()).root(cx.scope)?;
let args = vec![accumulator, pkv, Value::number(k as f64)];
let args = vec![accumulator, pkv, Value::number(k as f64), this.clone()];
accumulator = callback.apply(cx.scope, Value::undefined(), args).root(cx.scope)?;
}

Expand All @@ -223,7 +223,7 @@ pub fn find(cx: CallContext) -> Result<Value, Value> {
for k in 0..len {
let pk = cx.scope.intern_usize(k);
let pkv = this.get_property(cx.scope, pk.into()).root(cx.scope)?;
let args = vec![pkv.clone(), Value::number(k as f64)];
let args = vec![pkv.clone(), Value::number(k as f64), this.clone()];
let test = callback
.apply(cx.scope, Value::undefined(), args)
.root(cx.scope)?
Expand All @@ -245,7 +245,7 @@ pub fn find_index(cx: CallContext) -> Result<Value, Value> {
for k in 0..len {
let pk = cx.scope.intern_usize(k);
let pkv = this.get_property(cx.scope, pk.into()).root(cx.scope)?;
let args = vec![pkv, Value::number(k as f64)];
let args = vec![pkv, Value::number(k as f64), this.clone()];
let test = callback
.apply(cx.scope, Value::undefined(), args)
.root(cx.scope)?
Expand All @@ -271,7 +271,7 @@ pub fn for_each(cx: CallContext) -> Result<Value, Value> {
for k in 0..len {
let pk = cx.scope.intern_usize(k);
let pkv = this.get_property(cx.scope, pk.into()).root(cx.scope)?;
let args = vec![pkv, Value::number(k as f64)];
let args = vec![pkv, Value::number(k as f64), this.clone()];
callback.apply(cx.scope, Value::undefined(), args).root_err(cx.scope)?;
}

Expand Down Expand Up @@ -367,7 +367,7 @@ pub fn map(cx: CallContext) -> Result<Value, Value> {
for k in 0..len {
let pk = cx.scope.intern_usize(k);
let pkv = this.get_property(cx.scope, pk.into()).root(cx.scope)?;
let args = vec![pkv.clone(), Value::number(k as f64)];
let args = vec![pkv.clone(), Value::number(k as f64), this.clone()];
let value = callback.apply(cx.scope, Value::undefined(), args).root(cx.scope)?;

values.push(PropertyValue::static_default(value));
Expand Down

0 comments on commit 2c2cdeb

Please sign in to comment.