MCPcopy Index your code
hub / github.com/witheve/Eve / NotScan

Class NotScan

src/runtime/join.ts:470–529  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

468//---------------------------------------------------------------------
469
470export class NotScan {
471 id: string;
472 strata: BlockStratum[];
473 vars: Variable[];
474 args: Variable[];
475 internalVars: Variable[];
476 resolved: any[];
477
478 constructor(id: string, args: Variable[], strata: BlockStratum[]) {
479 this.id = id;
480 this.strata = strata;
481 this.resolved = [];
482 let blockVars = [];
483 scansToVars(strata, blockVars);
484 this.vars = args;
485 this.args = args;
486 this.internalVars = blockVars;
487 }
488
489 resolve(prefix) {
490 return resolve(this.args, prefix, this.resolved);
491 }
492
493 propose() { return; }
494 resolveProposal() { throw new Error("Resolving a not proposal"); }
495
496 accept(multiIndex: MultiIndex, prefix, solvingFor, force?, prejoin?) {
497 // if we're in the prejoin phase and this not has no args, then we need
498 // to evaluate the not to see if we should run. If we didn't do this, arg-less
499 // nots won't get evaluated during Generic Join since we're never solving for a
500 // variable that this scan cares about.
501 if((!prejoin || this.args.length)
502 // if we aren't forcing and not solving for the current variable, then we just accept
503 // as it is
504 && (!force && !this.internalVars[solvingFor.id] && this.internalVars.length)
505 // we also blind accept if we have args that haven't been filled in yet, as we don't
506 // have the dependencies necessary to make a decision
507 || !fullyResolved(this.args, prefix)) return true;
508 let resolved = this.resolve(prefix);
509 let notPrefix = [];
510 let ix = 0;
511 for(let arg of this.args) {
512 notPrefix[arg.id] = resolved[ix];
513 ix++;
514 }
515 // console.log("checking not", notPrefix, this.internalVars);
516 let results = [notPrefix];
517 if(this.strata.length === 1) {
518 results = this.strata[0].execute(multiIndex, results, {single: true});
519 } else {
520 for(let stratum of this.strata) {
521 results = stratum.execute(multiIndex, results);
522 if(results.length === 0) break;
523 }
524 }
525 // console.log("checked not!", results.length);
526 return !results.length;
527 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected