|
470 | 470 | (define mappings (build-vector (batch-length batch) values)) |
471 | 471 | (define bindings (make-hash)) |
472 | 472 | (define vars (make-hash)) |
473 | | - (define commands-to-send '()) ; Accumulate all commands to send |
474 | 473 | (define (remap x spec?) |
475 | 474 | (cond |
476 | 475 | [(hash-has-key? vars x) |
|
545 | 544 | (set! root-bindings (cons (vector-ref mappings n) root-bindings)))) |
546 | 545 |
|
547 | 546 | ; Var-lowering-rules |
548 | | - (for ([var (in-list (context-vars ctx))] |
549 | | - [repr (in-list (context-var-reprs ctx))]) |
550 | | - |
551 | | - (set! commands-to-send |
552 | | - (cons `(rule ((= e (Var ,(symbol->string var)))) |
553 | | - ((let ty ,(symbol->string (representation-name repr)) |
554 | | - ) |
555 | | - (let ety (,(typed-var-id (representation-name repr)) |
556 | | - ,(symbol->string var)) |
557 | | - ) |
558 | | - (union (do-lower e ty) ety)) |
559 | | - :ruleset |
560 | | - lower) |
561 | | - commands-to-send))) |
| 547 | + (send-to-egglog (for/list ([var (in-list (context-vars ctx))] |
| 548 | + [repr (in-list (context-var-reprs ctx))]) |
| 549 | + `(rule ((= e (Var ,(symbol->string var)))) |
| 550 | + ((let ty ,(symbol->string (representation-name repr)) |
| 551 | + ) |
| 552 | + (let ety (,(typed-var-id (representation-name repr)) |
| 553 | + ,(symbol->string var)) |
| 554 | + ) |
| 555 | + (union (do-lower e ty) ety)) |
| 556 | + :ruleset |
| 557 | + lower)) |
| 558 | + subproc) |
562 | 559 |
|
563 | 560 | ; Var-lifting-rules |
564 | | - (for ([var (in-list (context-vars ctx))] |
565 | | - [repr (in-list (context-var-reprs ctx))]) |
566 | | - |
567 | | - (set! commands-to-send |
568 | | - (cons `(rule ((= e (,(typed-var-id (representation-name repr)) ,(symbol->string var)))) |
569 | | - ((let se (Var |
570 | | - ,(symbol->string var)) |
571 | | - ) |
572 | | - (union (do-lift e) se)) |
573 | | - :ruleset |
574 | | - lift) |
575 | | - commands-to-send))) |
| 561 | + (send-to-egglog (for/list ([var (in-list (context-vars ctx))] |
| 562 | + [repr (in-list (context-var-reprs ctx))]) |
| 563 | + `(rule ((= e (,(typed-var-id (representation-name repr)) ,(symbol->string var)))) |
| 564 | + ((let se (Var |
| 565 | + ,(symbol->string var)) |
| 566 | + ) |
| 567 | + (union (do-lift e) se)) |
| 568 | + :ruleset |
| 569 | + lift)) |
| 570 | + subproc) |
576 | 571 |
|
577 | 572 | (define all-bindings '()) |
578 | 573 | (define binding->constructor (make-hash)) ; map from binding name to constructor name |
|
589 | 584 | ; Define the actual binding |
590 | 585 | (define curr-var-spec-binding `(let ,binding-name (Var ,(symbol->string var)))) |
591 | 586 |
|
592 | | - ; Add the unique constructor to send list |
593 | | - (set! commands-to-send |
594 | | - (cons `(constructor ,constructor-name () M :unextractable) commands-to-send)) |
| 587 | + ; Send the constructor definition |
| 588 | + (send-to-egglog (list `(constructor ,constructor-name () M :unextractable)) subproc) |
595 | 589 |
|
596 | 590 | ; Add the binding and constructor set to all-bindings for the future rule |
597 | 591 | (set! all-bindings (cons curr-var-spec-binding all-bindings)) |
|
611 | 605 | (define curr-var-typed-binding |
612 | 606 | `(let ,binding-name (,(typed-var-id (representation-name repr)) ,(symbol->string var)))) |
613 | 607 |
|
614 | | - ; Add the unique constructor to send list |
615 | | - (set! commands-to-send |
616 | | - (cons `(constructor ,constructor-name () MTy :unextractable) commands-to-send)) |
| 608 | + ; Send the constructor definition |
| 609 | + (send-to-egglog (list `(constructor ,constructor-name () MTy :unextractable)) subproc) |
617 | 610 |
|
618 | 611 | ; Add the binding and constructor set to all-bindings for the future rule |
619 | 612 | (set! all-bindings (cons curr-var-typed-binding all-bindings)) |
|
646 | 639 |
|
647 | 640 | (define curr-binding-exprs `(let ,binding-name ,actual-binding)) |
648 | 641 |
|
649 | | - (set! commands-to-send |
650 | | - (cons `(constructor ,constructor-name () ,curr-datatype :unextractable) commands-to-send)) |
| 642 | + (send-to-egglog (list `(constructor ,constructor-name () ,curr-datatype :unextractable)) subproc) |
651 | 643 |
|
652 | 644 | (set! all-bindings (cons curr-binding-exprs all-bindings)) |
653 | 645 | (set! all-bindings (cons `(set (,constructor-name) ,binding-name) all-bindings)) |
|
666 | 658 |
|
667 | 659 | (hash-ref binding->constructor curr-binding-name))) |
668 | 660 |
|
669 | | - ; Send all accumulated commands to egglog |
670 | | - (send-to-egglog (reverse commands-to-send) subproc) |
671 | | - |
672 | 661 | (values (reverse all-bindings) curr-bindings)) |
673 | 662 |
|
674 | 663 | (define (egglog-unsound-detected-subprocess tag subproc) |
|
0 commit comments