Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/nimble/R/RCfunction_compile.R
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ nf_substituteExceptFunctionsAndDollarSigns <- function(code, subList) {
RCfunProcessing <- setRefClass('RCfunProcessing',
contains = 'RCvirtualFunProcessing',
fields = list(
neededRCfuns = 'list' ## nfMethodRC objects
NeededTypes = 'list' ## nfMethodRC objects
),
methods = list(
process = function(debug = FALSE, debugCpp = FALSE, debugCppLabel = character(), doKeywords = TRUE) {
Expand Down Expand Up @@ -203,7 +203,7 @@ RCfunProcessing <- setRefClass('RCfunProcessing',
browser()
}

compileInfo$typeEnv[['neededRCfuns']] <<- list()
compileInfo$typeEnv[['NeededTypes']] <<- list()
compileInfo$typeEnv[['.AllowUnknowns']] <<- TRUE ## will be FALSE for RHS recursion in setSizes
compileInfo$typeEnv[['.ensureNimbleBlocks']] <<- FALSE ## will be TRUE for LHS recursion after RHS sees rmnorm and other vector dist "r" calls.
passedArgNames <- as.list(compileInfo$origLocalSymTab$getSymbolNames())
Expand All @@ -213,7 +213,7 @@ RCfunProcessing <- setRefClass('RCfunProcessing',
if(inherits(tryResult, 'try-error')) {
stop(paste('There is some problem at the setSizes processing step for this code:\n', paste(deparse(compileInfo$origRcode), collapse = '\n'), collapse = '\n'), call. = FALSE)
}
neededRCfuns <<- compileInfo$typeEnv[['neededRCfuns']]
NeededTypes <<- compileInfo$typeEnv[['NeededTypes']]

if(debug) {
print('compileInfo$nimExpr$show(showType = TRUE) -- broken')
Expand Down
4 changes: 2 additions & 2 deletions packages/nimble/R/RCfunction_core.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ nfMethodRC <-
fields = list(
template = 'ANY',
code = 'ANY',
neededRCfuns = 'ANY' #list
NeededTypes = 'ANY' #list
),
methods = list(
initialize = function(method, name, check = FALSE, methodNames = NULL, setupVarNames = NULL) {
if(!missing(name)) uniqueName <<- name ## only needed for a pure RC function. Not needed for a nimbleFunction method
neededRCfuns <<- list()
NeededTypes <<- list()
argInfo <<- formals(method)
code <<- nf_changeNimKeywords(body(method)) ## changes all nimble keywords, e.g. 'print' to 'nimPrint'; see 'nimKeyWords' list at bottom
if(code[[1]] != '{') code <<- substitute({CODE}, list(CODE=code))
Expand Down
4 changes: 2 additions & 2 deletions packages/nimble/R/cppDefs_RCfunction.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ RCfunctionDef <- setRefClass('RCfunctionDef',
CPPuse
},
genNeededTypes = function() {
for(i in seq_along(RCfunProc$neededRCfuns)) {
neededType<- RCfunProc$neededRCfuns[[i]]
for(i in seq_along(RCfunProc$NeededTypes)) {
neededType<- RCfunProc$NeededTypes[[i]]
if(inherits(neededType, 'nfMethodRC')) {
thisCppDef <- nimbleProject$getRCfunCppDef(neededType, NULLok = TRUE)
if(is.null(thisCppDef)) {
Expand Down
4 changes: 2 additions & 2 deletions packages/nimble/R/genCpp_sizeProcessing.R
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ exprClasses_setSizes <- function(code, symTab, typeEnv) { ## input code is exprC
nfmObj <- environment(obj)$nfMethodRCobject
uniqueName <- nfmObj$uniqueName
if(length(uniqueName)==0) stop(exprClassProcessingErrorMsg(code, 'In size processing: A no-setup nimbleFunction with no internal name is being called.'), call. = FALSE)
if(is.null(typeEnv$neededRCfuns[[uniqueName]])) {
typeEnv$neededRCfuns[[uniqueName]] <- nfmObj
if(is.null(typeEnv$NeededTypes[[uniqueName]])) {
typeEnv$NeededTypes[[uniqueName]] <- nfmObj
}
return(sizeRCfunction(code, symTab, typeEnv, nfmObj))
}
Expand Down
4 changes: 2 additions & 2 deletions packages/nimble/R/nimbleFunction_compile.R
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ nfProcessing <- setRefClass('nfProcessing',
},
collectRCfunNeededTypes = function() {
for(i in seq_along(RCfunProcs)) {
for(j in names(RCfunProcs[[i]]$neededRCfuns)) {
for(j in names(RCfunProcs[[i]]$NeededTypes)) {
if(is.null(neededTypes[[j]])) {
neededTypes[[j]] <<- RCfunProcs[[i]]$neededRCfuns[[j]]
neededTypes[[j]] <<- RCfunProcs[[i]]$NeededTypes[[j]]
}
}
## could clear RCfunProc[[i]]$neededRCtypes, but instead will prevent them from being used at compilation
Expand Down