source: to-imperative/trunk/runtime/rf_retval.hh @ 147

Last change on this file since 147 was 147, checked in by orlov, 18 years ago

First working version after rewriting pxx

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 1.5 KB
Line 
1//
2// Copyright (C) 2000 Refal+ Development Group
3//
4// Refal+ is free software; you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation; either version 2 of the License, or
7// (at your option) any later version.
8//
9// Refal+ is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with Refal+; if not, write to the Free Software
16// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17//
18// $Source$
19// $Revision: 147 $
20// $Date: 2002-09-01 00:16:12 +0000 (Sun, 01 Sep 2002) $
21// Author: Andrey Slepuhin <pooh@msu.ru>
22
23#ifndef __rf_retval_hh__
24#define __rf_retval_hh__
25
26namespace rfrt
27{
28
29class RetVal ;
30typedef RetVal (*rf_func_t)() ;
31
32class RetVal
33{
34
35private:
36
37  uintptr_t data;
38
39public:
40
41  inline RetVal (rf_func_t _f) :
42    data ((uintptr_t)_f)
43  {}
44
45  inline RetVal (bool = true)
46  {
47    data = 0;
48  }
49
50  inline RetVal (Expr* _saved_top)
51  {
52    data = 1;
53    stack.destroy_results(_saved_top);
54  }
55
56  inline ~RetVal ()
57  {}
58
59  inline operator bool ()
60  {
61    return (data & uintptr_t(0x01)) == 0;
62  }
63
64  inline bool is_tail ()
65  {
66    return data > 1;
67  }
68
69  inline rf_func_t get_ptr ()
70  {
71    return (rf_func_t)(data & ~(uintptr_t(0x01)));
72  }
73
74};
75
76}
77
78#endif // __rf_retval_hh__
Note: See TracBrowser for help on using the repository browser.