From 6a9ff1c648925b80942ea55d2c6526d8e3f62e94 Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Sat, 5 Oct 2019 00:18:44 -0500 Subject: [PATCH] postpone asExpr --- spotter.ml | 60 ++++++++++++++++++++++++++---------------------------- 1 file changed, 29 insertions(+), 31 deletions(-) diff --git a/spotter.ml b/spotter.ml index 7c5b193..d4b3521 100644 --- a/spotter.ml +++ b/spotter.ml @@ -449,37 +449,35 @@ module Compiler = struct (fun d (v, ps, nps, body) -> AtomDict.add (v, List.length ps) (ps, nps, body) d) AtomDict.empty meths in - State.bind asExpr (fun ase -> - State.bind (sequence auditors) (fun auds (* XXX rebind into env *) s -> - ( object (self) - (* XXX method dispatch, matcher dispatch *) - method call verb args namedArgs : monte option = - Printf.printf "call: %s/%d" verb (List.length args) ; - match - AtomDict.find_opt (verb, List.length args) methdict - with - | None -> - Printf.printf "no such method" ; - None (* refused. XXX matchers *) - | Some (params, nParams, body) -> - let exit = nullObj (* XXX *) in - (* XXX bind namePatt to self *) - (* XXX duplicate code with listPatt, refactor! *) - let env' = - List.fold_left2 - (fun ma p s -> State.and_then ma (p s exit)) - (State.return ()) params args in - Printf.printf "executing %s" verb ; - let o, _ = State.and_then env' body s in - Some o - - (* XXX miranda methods *) - (* XXX call printOn *) - method stringOf = "" - - method unwrap = None - end - , s ))) + (* XXX State.bind asExpr (fun ase -> *) + State.bind (sequence auditors) (fun auds (* XXX rebind into env *) s -> + ( object (self) + (* XXX method dispatch, matcher dispatch *) + method call verb args namedArgs : monte option = + Printf.printf "call: %s/%d" verb (List.length args) ; + match AtomDict.find_opt (verb, List.length args) methdict with + | None -> + Printf.printf "no such method" ; + None (* refused. XXX matchers *) + | Some (params, nParams, body) -> + let exit = nullObj (* XXX *) in + (* XXX bind namePatt to self *) + (* XXX duplicate code with listPatt, refactor! *) + let env' = + List.fold_left2 + (fun ma p s -> State.and_then ma (p s exit)) + (State.return ()) params args in + Printf.printf "executing %s" verb ; + let o, _ = State.and_then env' body s in + Some o + + (* XXX miranda methods *) + (* XXX call printOn *) + method stringOf = "" + + method unwrap = None + end + , s )) let assignExpr name rhs span = State.bind rhs (fun rv ->