[Roxygen-commits] r113 - pkg/sandbox

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Jul 28 06:01:48 CEST 2008


Author: pcd
Date: 2008-07-28 06:01:48 +0200 (Mon, 28 Jul 2008)
New Revision: 113

Added:
   pkg/sandbox/call-test.R
Log:
test for approfounding calls


Added: pkg/sandbox/call-test.R
===================================================================
--- pkg/sandbox/call-test.R	                        (rev 0)
+++ pkg/sandbox/call-test.R	2008-07-28 04:01:48 UTC (rev 113)
@@ -0,0 +1,32 @@
+preorder.walk.expression <- function(proc, expression) {
+  if (length(expression) > 0)
+    for (i in c(1:length(expression))) {
+      member <- tryCatch(expression[[i]], error=function(e) NULL)
+      if (!is.null(member) && !identical(member, expression)) {
+        proc(member)
+        try(preorder.walk.expression(proc, member),
+            silent=TRUE)
+      }
+    }
+}
+
+subcalls <- NULL
+
+is.callable <- function(name)
+  exists(name, mode='function')
+
+exprofundum <- expression(is.callable)
+
+discover.subcalls <- function(exprofundum)
+  if (is.name(exprofundum)) {
+    name <- as.character(exprofundum)
+    if (is.callable(name) && !name %in% subcalls) {
+      cat(name, '\n')
+      subcalls <<- append(name, subcalls)
+      body <- tryCatch(body(name), error=function(e) NULL)
+      if (!is.null(body))
+        preorder.walk.expression(discover.subcalls, body)
+    }
+  }
+
+preorder.walk.expression(discover.subcalls, exprofundum)



More information about the Roxygen-commits mailing list