[q-lang-cvs] qcalc qcalc.q,1.189,1.190
Brought to you by:
agraef
From: Albert G. <ag...@us...> - 2007-11-26 14:35:50
|
Update of /cvsroot/q-lang/qcalc In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv12656 Modified Files: qcalc.q Log Message: bugfixes Index: qcalc.q =================================================================== RCS file: /cvsroot/q-lang/qcalc/qcalc.q,v retrieving revision 1.189 retrieving revision 1.190 diff -C2 -d -r1.189 -r1.190 *** qcalc.q 26 Nov 2007 09:31:06 -0000 1.189 --- qcalc.q 26 Nov 2007 14:35:45 -0000 1.190 *************** *** 717,723 **** init_interp || ABORTED := false || statusmsg "Computation aborted" || ! normal_cursor if get ABORTED; ! = normal_cursor otherwise; /* Queue GUI updates for later processing during evaluations. */ --- 717,723 ---- init_interp || ABORTED := false || statusmsg "Computation aborted" || ! normal_cursor || false if get ABORTED; ! = normal_cursor || true otherwise; /* Queue GUI updates for later processing during evaluations. */ *************** *** 854,860 **** // background task: digest 'X = X; - // pending updates: - digest W:List = process_sel2 W || merge_undo $ map (flip (flip sub 0) 1) W - if get STATE = 4; // other messages from the inferior process: --- 854,857 ---- *************** *** 3070,3074 **** merge_undo L:List = //printf "*** merge undo: %s ++ %s\n" (str L0,str L) || ! UNDO_LIST := [L0++L|UL] where [L0|UL] = get UNDO_LIST if not null L --- 3067,3071 ---- merge_undo L:List = //printf "*** merge undo: %s ++ %s\n" (str L0,str L) || ! UNDO_LIST := [merge_lists L0 L|UL] where [L0|UL] = get UNDO_LIST if not null L *************** *** 3077,3085 **** merge_undo L:List = //printf "*** merge undo: %s ++ %s\n" (str (DI,DJ,L0),str L) || ! UNDO_LIST := [(I,J,L0++L)|UL] where [(I,J,L0:List)|UL] = get UNDO_LIST if not null L where L = filter (neg is_gui_elem.fst) $ undo_cellvals L; undo_cellvals (I,J) = [undo_cellval (I,J)]; --- 3074,3086 ---- merge_undo L:List = //printf "*** merge undo: %s ++ %s\n" (str (DI,DJ,L0),str L) || ! UNDO_LIST := [(I,J,merge_lists L0 L)|UL] where [(I,J,L0:List)|UL] = get UNDO_LIST if not null L where L = filter (neg is_gui_elem.fst) $ undo_cellvals L; + // XXXFIXME: We should remove duplicates here. + merge_lists L1 L2 + = L1++L2; + undo_cellvals (I,J) = [undo_cellval (I,J)]; *************** *** 3552,3558 **** /* Recompute the given cells. */ ! compute V = begin_compute || ! do submit V || collect_results emptyhdict V || ! end_compute_test; collect_results U V --- 3553,3576 ---- /* Recompute the given cells. */ ! def UQ = semaphore; // temporary storage for queueing deferred cell updates ! ! /* We go to some lengths here to implement this fully tail-recursively, in ! order to prevent stack overflows on the deferred propagation of cell values ! changed via setval et al or any of the GUI element functions while a ! computation is already in progress. To achieve this, the accumulated list ! of updated cell indices U is passed around between compute and process_sel2 ! (which call each other tail-recursively). When the cascade of updates ! eventually ends, we finally call the merge_undo function on this list to ! update the undo list in one go. */ ! ! compute V:List = compute ([],V); ! compute (U,V) = /* Some cells were updated, process them (tail-)recursively ! after the current computation has finished. */ ! process_sel2 (U++U1,W) ! where (U1,W) = try UQ ! if begin_compute || do submit V || ! collect_results emptyhdict V || ! end_compute_test; ! = merge_undo U otherwise; collect_results U V *************** *** 3560,3565 **** results_loop T0 U [] ! // we're finished; process any pending cell updates ! = post MSGS $ zipwith append (keys U) (vals U) if not null U; = () otherwise; results_loop T0 U [(I,J)|V] --- 3578,3585 ---- results_loop T0 U [] ! // we're finished; queue any pending cell updates s.t. they are executed later ! = post UQ (K,W) ! where K = keys U, V = vals U, W = zipwith append K V ! if not null U; = () otherwise; results_loop T0 U [(I,J)|V] *************** *** 3801,3805 **** = false otherwise; ! process_sel2 W = if check_interp then compute V where W = map (flip (flip sub 0) 1) W, // Exclude all toplevel GUI elements from this list --- 3821,3828 ---- = false otherwise; ! process_sel2 W:List ! = process_sel2 ([],W); ! process_sel2 (U,W) ! = if check_interp then compute (U,V) where W = map (flip (flip sub 0) 1) W, // Exclude all toplevel GUI elements from this list *************** *** 3810,3813 **** --- 3833,3837 ---- CHK = foldl process2 false W if not null W and then check_interp; + = merge_undo U otherwise; clear_sel W = do (flip cell_setval ()) W || do clear_cell W || compute V |