CXXR (C++ R)
ReturnBailout.hpp
Go to the documentation of this file.
1 /*CXXR $Id: ReturnBailout.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 RETURNBAILOUT_HPP
41 #define RETURNBAILOUT_HPP 1
42 
43 #include "CXXR/Bailout.hpp"
44 #include "CXXR/Evaluator.h"
45 
46 namespace CXXR {
47  class Environment;
48 
56  class ReturnBailout : public Bailout {
57  public:
67  ReturnBailout(Environment* the_environment, RObject* the_value)
68  : m_environment(the_environment), m_value(the_value),
69  m_print_result(R_Visible)
70  {}
71 
78  {
79  return m_environment;
80  }
81 
87  bool printResult() const
88  {
89  return m_print_result;
90  }
91 
97  RObject* value() const
98  {
99  return m_value;
100  }
101 
102  // Virtual function of Bailout:
103  void throwException();
104 
105  // Virtual function of GCNode:
106  void visitReferents(const_visitor* v) const;
107  protected:
108  // Virtual function of GCNode:
109  void detachReferents();
110  private:
111  GCEdge<Environment> m_environment;
112  GCEdge<> m_value;
113  bool m_print_result;
114 
115  // Declared private to ensure that ReturnBailout objects are
116  // allocated only using 'new':
117  ~ReturnBailout() {}
118 
119  // Not implemented. Declared to prevent compiler-generated versions:
121  ReturnBailout& operator=(const ReturnBailout&);
122  };
123 }
124 
125 #endif // RETURNBAILOUT_HPP