Permalink
Browse files

State of the world from last night, fell asleep on it.

  • Loading branch information...
1 parent e1a5ce8 commit 43c8cf0074fd3936f3f047ece12dd0ea287fe009 @adamalix adamalix committed Nov 15, 2012
Showing with 29 additions and 12 deletions.
  1. +29 −12 src/ljs/ljs_cesk.ml
View
@@ -14,7 +14,9 @@ type closure =
| ExpClosure of S.exp * env
| ValClosure of value * env
| AEClosure of S.exp option * env
- | AVClosure of value option * env ;;
+ | AVClosure of value option * env
+ | PEClosure of S.prop * env
+ | PVClosure of propv * env ;;
let exp_of clos = match clos with
| ExpClosure (expr, _) -> Some expr
@@ -205,6 +207,27 @@ let rec eval_cesk desugar clos store kont : (value * store) =
eval (ExpClosure (None, env)) store (K.Object (primval, None, Some protoval, None, codeval, klass, ext, props, propsv, k))*)
in
+ (* should probably extend kont with way to distinguish between the two.
+ this is getting unweildy, kont should be reformatted or refactored *)
+ let rec eval_prop propclos store kont = match propclos, kont with
+ (* eval vexp *)
+ | PEClosure (S.Data ({ S.value = vexp; S.writable = w; }, enum, config), env),
+ K.Object (pv, pe, prov, ce, cv, kls, ext, props, propsv, k) ->
+ eval (ExpClosure (vexp, env)) store, kont
+ (* eval get *)
+ (* need a way to signal in kont that we're evaling get *)
+ | PEClosure (S.Accessor ({ S.getter = get; }, enum, config), env),
+ K.Object (pv, pe, prov, ce, cv, kls, ext, props, propsv, k) ->
+ eval (ExpClosure (get, env)) store kont
+ (* eval set *)
+ (* need to signal in kont that we're eval'ing set *)
+ | PEClosure (S.Accessor ({ S.setter = set; }, enum, config), env),
+ K.Object (pv, pe, prov, ce, cv, kls, ext, props, propsv, k) ->
+ eval (ExpClosure (set, env)) store kont
+ (* prop is eval'd add to store, continue *)
+(* | _ -> ??? *)
+ in
+
let rec apply p store func args = match func with
| Closure (env, xs, body) ->
let alloc_arg argval argname (store, env) =
@@ -280,7 +303,11 @@ let rec eval_cesk desugar clos store kont : (value * store) =
| ValClosure (protoval, env), K.Object (_, None, None, _, _, _, _, _, _, _) ->
eval_attrs (AVClosure (Some protoval, env)) store kont
(* Prop Cases *)
-
+ (* initial call to eval_prop will be from eval_attrs *)
+ | ValClosure (ObjLoc objloc, env), K.Object(pv, pe, prv, ce, cv, kls, ext, prop::props, propsv, k) ->
+ eval_props (PEClosure (prop, env)) store (K.Object (pv, pe, prv, ce, cv, kls, ext, props, propsv, k))
+ | ValClosure (ObjLoc objloc, env), K.Object(_, _, _, _, _, _, _, [], propsv, k) ->
+ eval (ValClosure (objloc, env)) store k
(* GetAttr *)
(* better way to do this? it's non-exhaustive, but shouldn't be an issue we
we are guaranteeing left to right evaluation on the obj / field *)
@@ -607,16 +634,6 @@ and envstore_of_obj p (_, props) store =
and arity_mismatch_err p xs args = interp_error p ("Arity mismatch, supplied " ^ string_of_int (List.length args) ^ " arguments and expected " ^ string_of_int (List.length xs) ^ ". Arg names were: " ^ (List.fold_right (^) (map (fun s -> " " ^ s ^ " ") xs) "") ^ ". Values were: " ^ (List.fold_right (^) (map (fun v -> " " ^ pretty_value v ^ " ") args) ""))
-(*and eval_prop prop store = match prop with
- | S.Data ({ S.value = vexp; S.writable = w; }, enum, config) ->
- let vexp, store = eval (ExpClosure (vexp, env) store in
- Data ({ value = vexp; writable = w; }, enum, config), store
- | S.Accessor ({ S.getter = ge; S.setter = se; }, enum, config) ->
- let gv, store = eval ge env store in
- let sv, store = eval se env store in
- Accessor ({ getter = gv; setter = sv}, enum, config), store
-*)
-
let err show_stack trace message =
if show_stack then begin
eprintf "%s\n" (string_stack_trace trace);

0 comments on commit 43c8cf0

Please sign in to comment.