1#lang racket/base
2(require "../common/module-path.rkt")
3
4;; A `module-use` record is just a part of module path index plus
5;; phase, since that combination is commonly needed
6
7(provide (struct-out module-use))
8
9(struct module-use (module phase)
10  #:property prop:equal+hash
11  (list (lambda (a b eql?)
12          (define a-mod (module-use-module a))
13          (define b-mod (module-use-module b))
14          (and (eql? a-mod b-mod)
15               (eql? (module-use-phase a)
16                     (module-use-phase b))
17               ;; Unusual, but possible with top-level evaluation: can have
18               ;; different "self" MPIs that refer to different modules
19               (let-values ([(a-path a-base) (module-path-index-split a-mod)]
20                            [(b-path b-base) (module-path-index-split b-mod)])
21                 (or a-path
22                     b-path
23                     (eq? (module-path-index-resolved a-mod)
24                          (module-path-index-resolved b-mod))))))
25        (lambda (a hash-code)
26          (+ (hash-code (module-use-module a))
27             (hash-code (module-use-phase a))))
28        (lambda (a hash-code)
29          (+ (hash-code (module-use-module a))
30             (hash-code (module-use-phase a))))))
31