(module inference-environments mzscheme
(provide (all-defined))
(define-values (struct:inference-environment
inference-environment-constructor
inference-environment?
inference-environment-field-ref
set-inference-environment-field!)
(make-struct-type 'inference-environment #f 7 0))
(define inference-environment-data-index
(make-struct-field-accessor
inference-environment-field-ref 0 'data-index))
(define set-inference-environment-data-index!
(make-struct-field-mutator
set-inference-environment-field! 0 'data-index))
(define inference-environment-goal-index
(make-struct-field-accessor
inference-environment-field-ref 1 'goal-index))
(define set-inference-environment-goal-index!
(make-struct-field-mutator
set-inference-environment-field! 1 'goal-index))
(define inference-environment-rule-nodes
(make-struct-field-accessor
inference-environment-field-ref 2 'rule-nodes))
(define set-inference-environment-rule-nodes!
(make-struct-field-mutator
set-inference-environment-field! 2 'rule-nodes))
(define inference-environment-exit
(make-struct-field-accessor
inference-environment-field-ref 3 'exit))
(define set-inference-environment-exit!
(make-struct-field-mutator
set-inference-environment-field! 3 'exit))
(define inference-environment-next-assertion-id
(make-struct-field-accessor
inference-environment-field-ref 4 'next-assertion-id))
(define set-inference-environment-next-assertion-id!
(make-struct-field-mutator
set-inference-environment-field! 4 'next-assertion-id))
(define inference-environment-assertion-index
(make-struct-field-accessor
inference-environment-field-ref 5 'assertion-index))
(define set-inference-environment-assertion-index!
(make-struct-field-mutator
set-inference-environment-field! 5 'assertion-index))
(define inference-environment-trace
(make-struct-field-accessor
inference-environment-field-ref 6 'trace))
(define set-inference-environment-trace!
(make-struct-field-mutator
set-inference-environment-field! 6 'trace))
(define (make-inference-environment)
(inference-environment-constructor
(make-hash-table) (make-hash-table) '() #f 1 (make-hash-table) #f ))
(define default-inference-environment
(make-inference-environment))
(define current-inference-environment
(make-parameter
default-inference-environment
(lambda (x)
(when (not (inference-environment? x))
(raise-type-error 'current-inference-environment
"inference-environment" x))
x)))
(define current-inference-data-index
(case-lambda
(()
(inference-environment-data-index
(current-inference-environment)))
((data-index)
(set-inference-environment-data-index!
(current-inference-environment) data-index))))
(define current-inference-goal-index
(case-lambda
(()
(inference-environment-goal-index
(current-inference-environment)))
((goal-index)
(set-inference-environment-goal-index!
(current-inference-environment) goal-index))))
(define current-inference-rule-nodes
(case-lambda
(()
(inference-environment-rule-nodes
(current-inference-environment)))
((rule-nodes)
(set-inference-environment-rule-nodes!
(current-inference-environment) rule-nodes))))
(define current-inference-exit
(case-lambda
(()
(inference-environment-exit
(current-inference-environment)))
((exit)
(set-inference-environment-exit!
(current-inference-environment) exit))))
(define current-inference-next-assertion-id
(case-lambda
(()
(inference-environment-next-assertion-id
(current-inference-environment)))
((next-assertion-id)
(set-inference-environment-next-assertion-id!
(current-inference-environment) next-assertion-id))))
(define current-inference-assertion-index
(case-lambda
(()
(inference-environment-assertion-index
(current-inference-environment)))
((assertion-index)
(set-inference-environment-assertion-index!
(current-inference-environment) assertion-index))))
(define current-inference-trace
(case-lambda
(()
(inference-environment-trace
(current-inference-environment)))
((trace)
(set-inference-environment-trace!
(current-inference-environment) trace))))
(define-syntax with-inference-environment
(syntax-rules ()
((with-inference-environment inference-environment
body ...)
(parameterize ((current-inference-environment
inference-environment))
body ...))))
(define-syntax with-new-inference-environment
(syntax-rules ()
((with-new-inference-environment
body ...)
(parameterize ((current-inference-environment
(make-inference-environment)))
body ...))))
)