(.module: [lux #* [control [equivalence (#+ Equivalence)] [hash (#+ Hash)] pipe] [data [text format]]]) (type: #export Register Nat) (type: #export Variable (#Local Register) (#Foreign Register)) (type: #export Reference (#Variable Variable) (#Constant Name)) (structure: #export equivalence (Equivalence Variable) (def: (= reference sample) (case [reference sample] (^template [] [( reference') ( sample')] (n/= reference' sample')) ([#Local] [#Foreign]) _ #0))) (structure: #export hash (Hash Variable) (def: &equivalence ..equivalence) (def: (hash var) (case var (#Local register) (n/* 1 register) (#Foreign register) (n/* 2 register)))) (do-template [ ] [(template: #export ( content) (<| content))] [local #..Variable #..Local] [foreign #..Variable #..Foreign] ) (do-template [ ] [(template: #export ( content) (<| content))] [variable #..Variable] [constant #..Constant] ) (def: #export self Reference (..local 0)) (def: #export self? (-> Variable Bit) (|>> ..variable (case> (^ (..local 0)) #1 _ #0))) (def: #export (%variable variable) (Format Variable) (case variable (#Local local) (format "+" (%n local)) (#Foreign foreign) (format "-" (%n foreign)))) (def: #export (%reference reference) (Format Reference) (case reference (#Variable variable) (%variable variable) (#Constant constant) (%name constant)))