CXXR (C++ R)
ClosureContext.hpp
Go to the documentation of this file.
1 /*CXXR $Id: ClosureContext.hpp 1348 2013-02-25 17:49:03Z arr $
2  *CXXR
3  *CXXR This file is part of CXXR, a project to refactor the R interpreter
4  *CXXR into C++. It may consist in whole or in part of program code and
5  *CXXR documentation taken from the R project itself, incorporated into
6  *CXXR CXXR (and possibly MODIFIED) under the terms of the GNU General Public
7  *CXXR Licence.
8  *CXXR
9  *CXXR CXXR is Copyright (C) 2008-13 Andrew R. Runnalls, subject to such other
10  *CXXR copyrights and copyright restrictions as may be stated below.
11  *CXXR
12  *CXXR CXXR is not part of the R project, and bugs and other issues should
13  *CXXR not be reported via r-bugs or other R project channels; instead refer
14  *CXXR to the CXXR website.
15  *CXXR */
16 
17 /*
18  * R : A Computer Language for Statistical Data Analysis
19  *
20  * This program is free software; you can redistribute it and/or modify
21  * it under the terms of the GNU General Public License as published by
22  * the Free Software Foundation; either version 2.1 of the License, or
23  * (at your option) any later version.
24  *
25  * This program is distributed in the hope that it will be useful,
26  * but WITHOUT ANY WARRANTY; without even the implied warranty of
27  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28  * GNU Lesser General Public License for more details.
29  *
30  * You should have received a copy of the GNU General Public License
31  * along with this program; if not, a copy is available at
32  * http://www.r-project.org/Licenses/
33  */
34 
40 #ifndef CLOSURECONTEXT_HPP
41 #define CLOSURECONTEXT_HPP 1
42 
43 #include "CXXR/FunctionBase.h"
44 #include "CXXR/FunctionContext.hpp"
45 
46 extern "C" {
47  // Parked here pending the creation of an ErrorHandling class:
48  extern CXXR::GCRoot<> R_HandlerStack; // Condition handler stack
49  extern CXXR::GCRoot<> R_RestartStack; // Stack of available restarts
50 }
51 
52 namespace CXXR {
69  public:
89  ClosureContext(const Expression* the_call, Environment* call_env,
90  const FunctionBase* function, Environment* working_env,
91  const PairList* promise_args);
92 
93  ~ClosureContext();
94 
103  {
104  return m_handlerstack;
105  }
106 
121 
128  RObject* onExit() const
129  {
130  return m_onexit;
131  }
132 
138  const PairList* promiseArgs() const
139  {
140  return m_promise_args;
141  }
142 
149  void setOnExit(RObject* onexit)
150  {
151  m_onexit = onexit;
152  }
153 
162  {
163  return m_working_env;
164  }
165  private:
166  Rboolean m_interrupts_suspended;
167  GCStackRoot<> m_handlerstack;
168  GCStackRoot<> m_restartstack;
169  GCStackRoot<Environment> m_working_env;
170  GCStackRoot<const PairList> m_promise_args;
171  GCStackRoot<> m_onexit;
172  };
173 } // namespace CXXR
174 
175 SEXP Rf_dynamicfindVar(SEXP, CXXR::ClosureContext*);
176 int Rf_framedepth(CXXR::ClosureContext*);
177 void R_InsertRestartHandlers(CXXR::ClosureContext*, Rboolean);
178 SEXP R_syscall(int, CXXR::ClosureContext*);
179 int R_sysparent(int, CXXR::ClosureContext*);
180 SEXP R_sysframe(int, CXXR::ClosureContext*);
181 SEXP R_sysfunction(int, CXXR::ClosureContext*);
182 
183 #endif // CLOSURECONTEXT_HPP