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: 688 $ |
---|
20 | // $Date: 2003-04-28 17:06:59 +0000 (Mon, 28 Apr 2003) $ |
---|
21 | // Author: Andrey Slepuhin <pooh@msu.ru> |
---|
22 | |
---|
23 | #ifndef __rf_result_hh__ |
---|
24 | #define __rf_result_hh__ |
---|
25 | |
---|
26 | #include "rf_expr.hh" |
---|
27 | #include "rf_stack.hh" |
---|
28 | |
---|
29 | namespace rfrt |
---|
30 | { |
---|
31 | |
---|
32 | class Result |
---|
33 | { |
---|
34 | |
---|
35 | friend class Stack ; |
---|
36 | |
---|
37 | private: |
---|
38 | |
---|
39 | Expr* expr_ptr ; |
---|
40 | |
---|
41 | Result (Result const&) |
---|
42 | { |
---|
43 | FATAL("Private constructor Result(Result const&) should never be called"); |
---|
44 | } |
---|
45 | |
---|
46 | Result& operator = (Result const&) |
---|
47 | { |
---|
48 | FATAL("Private operator = Result(Result const&) should never be called"); |
---|
49 | return *this; |
---|
50 | } |
---|
51 | |
---|
52 | public: |
---|
53 | |
---|
54 | Result () |
---|
55 | { |
---|
56 | expr_ptr = stack.top++; |
---|
57 | expr_ptr->set_mem_chunk(null); |
---|
58 | } |
---|
59 | |
---|
60 | ~Result () |
---|
61 | {} |
---|
62 | |
---|
63 | Result& operator = (Expr const& _expr) |
---|
64 | { |
---|
65 | new(expr_ptr) Expr(_expr); |
---|
66 | return *this; |
---|
67 | } |
---|
68 | |
---|
69 | }; |
---|
70 | |
---|
71 | inline Stack& Stack::operator , (Result& _res) |
---|
72 | { |
---|
73 | if (_res.expr_ptr != top) { |
---|
74 | new(_res.expr_ptr) Expr(top); |
---|
75 | } |
---|
76 | top++; |
---|
77 | return *this; |
---|
78 | } |
---|
79 | |
---|
80 | } |
---|
81 | |
---|
82 | #endif // __rf_result_hh__ |
---|