Skip to content

Commit 68843b6

Browse files
committed
add highlight to change in call arity
1 parent 19d9e35 commit 68843b6

File tree

2 files changed

+6
-36
lines changed

2 files changed

+6
-36
lines changed

src/features/cseMachine/CseMachineAnimation.tsx

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -283,30 +283,21 @@ export class CseAnimation {
283283
);
284284
break;
285285
case InstrType.SPREAD:
286-
const prevcontrol = Layout.previousControlComponent.stackItemComponents;
287286
const control = Layout.controlComponent.stackItemComponents;
288287
const array = Layout.previousStashComponent.stashItemComponents.at(-1)!.arrow!
289288
.target! as ArrayValue;
290289

291290
let currCallInstr;
292-
let prevCallInstr;
293291

294-
for (let i = 0; control.at(-i) != undefined; i++) {
292+
for (let i = 1; control.at(-i) != undefined; i++) {
293+
console.log(control.at(-i));
295294
if (control.at(-i)?.text.includes('call ')) {
296295
// find call instr above
297296
currCallInstr = control.at(-i);
298297
break;
299298
}
300299
}
301300

302-
for (let i = 0; prevcontrol.at(-i) != undefined; i++) {
303-
if (prevcontrol.at(-i)?.text.includes('call ')) {
304-
// find call instr above
305-
prevCallInstr = prevcontrol.at(-i);
306-
break;
307-
}
308-
}
309-
310301
const resultItems =
311302
array.data.length !== 0
312303
? Layout.stashComponent.stashItemComponents.slice(-array.data.length)
@@ -317,8 +308,7 @@ export class CseAnimation {
317308
lastControlComponent,
318309
Layout.previousStashComponent.stashItemComponents.at(-1)!,
319310
resultItems!,
320-
currCallInstr!,
321-
prevCallInstr!
311+
currCallInstr!
322312
)
323313
);
324314
break;

src/features/cseMachine/animationComponents/ArraySpreadAnimation.tsx

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Easings } from 'konva/lib/Tween';
1+
//import { Easings } from 'konva/lib/Tween';
22
import React from 'react';
33
import { Group } from 'react-konva';
44

@@ -26,16 +26,14 @@ export class ArraySpreadAnimation extends Animatable {
2626
private resultAnimations: AnimatedTextbox[];
2727
private arrowAnimation?: AnimatedGenericArrow<StashItemComponent, Visible>;
2828
private currCallInstrAnimation: AnimatedTextbox;
29-
private prevCallInstrAnimation: AnimatedTextbox;
3029

3130
private endX: number;
3231

3332
constructor(
3433
private controlInstrItem: ControlItemComponent,
3534
private stashItem: StashItemComponent,
3635
private resultItems: StashItemComponent[],
37-
private currCallInstrItem: ControlItemComponent,
38-
private prevCallInstrItem: ControlItemComponent
36+
private currCallInstrItem: ControlItemComponent
3937
) {
4038
super();
4139

@@ -52,15 +50,9 @@ export class ArraySpreadAnimation extends Animatable {
5250
});
5351

5452
// call instr above
55-
this.prevCallInstrAnimation = new AnimatedTextbox(
56-
this.prevCallInstrItem.text,
57-
{ ...getNodePosition(this.prevCallInstrItem), opacity: 0 },
58-
{ rectProps: { stroke: defaultActiveColor() } }
59-
);
60-
6153
this.currCallInstrAnimation = new AnimatedTextbox(
6254
this.currCallInstrItem.text,
63-
{ ...getNodePosition(this.currCallInstrItem), opacity: 0 },
55+
getNodePosition(this.currCallInstrItem),
6456
{ rectProps: { stroke: defaultActiveColor() } }
6557
);
6658

@@ -81,7 +73,6 @@ export class ArraySpreadAnimation extends Animatable {
8173
{this.controlInstrAnimation.draw()}
8274
{this.stashItemAnimation.draw()}
8375
{this.currCallInstrAnimation.draw()}
84-
{this.prevCallInstrAnimation.draw()}
8576
{this.resultAnimations.map(a => a.draw())}
8677
{this.arrowAnimation?.draw()}
8778
</Group>
@@ -101,17 +92,6 @@ export class ArraySpreadAnimation extends Animatable {
10192

10293
// Move spread instruction next to stash item (array pointer)
10394
await Promise.all([
104-
// Show change in call arity
105-
this.prevCallInstrAnimation.animateTo(
106-
{ scaleX: 1.1, scaleY: 1.1, opacity: 0 },
107-
{ duration: 0.3, easing: Easings.StrongEaseOut }
108-
),
109-
110-
this.currCallInstrAnimation.animateTo(
111-
{ opacity: 1 },
112-
{ duration: 0.3, easing: Easings.StrongEaseOut }
113-
),
114-
11595
...this.resultAnimations.flatMap(a => [
11696
a.animateTo(
11797
{ x: startX + (this.endX - startX) / 2 - this.resultItems[0]?.width() / 2 },

0 commit comments

Comments
 (0)