X-Git-Url: http://christophe.rhodes.io/gitweb/?p=swankr.git;a=blobdiff_plain;f=swank-presentations.R;h=69488cfa9dd7f954b60d1bbd0d9012e979db18c7;hp=d2ed3f71efe45542bb3454a3fec4a815cd4d987e;hb=55bb6badd1c00884315aa19df9c5319e18787265;hpb=e35149b43e4da28f542c6bdf2decd802e84dd440 diff --git a/swank-presentations.R b/swank-presentations.R index d2ed3f7..69488cf 100644 --- a/swank-presentations.R +++ b/swank-presentations.R @@ -4,6 +4,8 @@ savePresentedObject <- function(slimeConnection, value) { if(!exists("idToObject", envir=slimeConnection)) { assign("idToObject", new.env(), envir=slimeConnection) } + ## FIXME this should check for value already being present in the + ## idToObject map presentationCounter <<- presentationCounter + 1 assign(as.character(presentationCounter), value, envir=slimeConnection$idToObject) presentationCounter @@ -27,7 +29,6 @@ sendReplResultFunction <- presentReplResult } `swank:lookup-presented-object` <- function(slimeConnection, sldbState, id) { - str(ls(slimeConnection)) if(exists(as.character(id), envir=slimeConnection$idToObject)) { value <- get(as.character(id), envir=slimeConnection$idToObject) list(value, TRUE) @@ -44,4 +45,16 @@ sendReplResultFunction <- presentReplResult stop(sprintf("attempt to access unrecorded object (id %d)", id)) } } - + +`swank:lookup-and-save-presented-object-or-lose` <- function(slimeConnection, sldbState, id) { + obj <- `swank:lookup-presented-object-or-lose`(slimeConnection, sldbState, id) + savePresentedObject(slimeConnection, obj) +} + +`swank:clear-repl-results` <- function(slimeConnection, sldbState) { + if(!exists("idToObject", envir=slimeConnection)) { + assign("idToObject", new.env(), envir=slimeConnection) + } + rm(list=ls(slimeConnection$idToObject), envir=slimeConnection$idToObject) + TRUE +}