add datetime device, revise device handling, remove tracing code

This commit is contained in:
Lobo 2025-12-19 00:31:36 -03:00
parent 56a3398c8f
commit cf31dc5564
8 changed files with 115 additions and 119 deletions

View file

@ -1,35 +1,12 @@
module Int_set = Set.Make (Int)
module type DEVICE = sig
type state
val state : state
val can_handle : int -> bool
val dei : Machine.machine -> int -> int option
val dei2 : Machine.machine -> int -> int option
val dei_ports : Int_set.t
val deo_ports : Int_set.t
val dei : Machine.machine -> int -> int
val dei2 : Machine.machine -> int -> int
val deo : Machine.machine -> int -> int -> unit
end
module Compose (D1 : DEVICE) (D2 : DEVICE) :
DEVICE with type state = D1.state * D2.state = struct
type state = D1.state * D2.state
let state = (D1.state, D2.state)
let can_handle port = D1.can_handle port || D2.can_handle port
let dei mach port =
match (D1.can_handle port, D2.can_handle port) with
| true, false -> D1.dei mach port
| false, true -> D2.dei mach port
| _ -> None
let dei2 mach port =
match (D1.can_handle port, D2.can_handle port) with
| true, false -> D1.dei2 mach port
| false, true -> D2.dei2 mach port
| _ -> None
let deo mach port value =
match (D1.can_handle port, D2.can_handle port) with
| true, false -> D1.deo mach port value
| false, true -> D2.deo mach port value
| _ -> ()
end