Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Garrett committed May 23, 2021
1 parent 3a6fc0c commit d76e312
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions packages/@glimmer/validator/lib/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,13 +386,21 @@ function endTrack(): Tracker {
export class TrackFrameOpcode implements UpdatingOpcode {
public source: Source | null = null;
public target: number | null = null;
public revision: Revision = Revisions.UNINITIALIZED;

constructor(private debuggingContext?: string) {
beginTrack(debuggingContext);
}

evaluate(vm: UpdatingVM) {
if (this.source === null || !isDirty(this.source)) {
let { source } = this;

assert(
source === null || isSourceImpl(source),
'VM BUG: Expected track opcode to have a source'
);

if (source === null || this.revision >= getRevision(source)) {
let { target } = this;

assert(target, 'VM BUG: expected a target to exist for a tracking opcode, but it did not');
Expand All @@ -417,19 +425,21 @@ export class EndTrackFrameOpcode implements UpdatingOpcode {
let current = endTrack();

let deps = current.toDeps();
let { maxRevision } = current;
let source = deps;

if (Array.isArray(source)) {
source = new SourceImpl<unknown>(undefined, null, null);
source.deps = deps;
source.revision = source.valueRevision = current.maxRevision;
source.revision = source.valueRevision = maxRevision;
}

if (CURRENT_TRACKER !== null && source !== null) {
CURRENT_TRACKER.add(source);
}

this.begin.source = source;
this.begin.revision = maxRevision;
}
}

Expand Down

0 comments on commit d76e312

Please sign in to comment.