1
// This file is part of the AspectC++ compiler 'ac++'.
2
// Copyright (C) 1999-2003 The 'ac++' developers (see aspectc.org)
4
// This program is free software; you can redistribute it and/or
5
// modify it under the terms of the GNU General Public License as
6
// published by the Free Software Foundation; either version 2 of
7
// the License, or (at your option) any later version.
9
// This program 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.
14
// You should have received a copy of the GNU General Public
15
// License along with this program; if not, write to the Free
16
// Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
19
#include "ResultBuffer.h"
20
#include "Puma/CTypeInfo.h"
22
using std::stringstream;
24
bool ResultBuffer::has_constructor_problem () const {
25
return _type->isRecord () && !_type->isAddress ();
28
string ResultBuffer::result_type (const string &name, bool unqual) const {
30
CTypeInfo *type = _type;
32
type = type->UnqualType ();
33
if (type->isVoid () || type->isUndefined ())
35
else if (type->isAddress ()) {
36
string ptrname = string ("*") + name;
37
type->BaseType ()->TypeText (out, ptrname.c_str (), true, true);
40
type->TypeText (out, name.c_str (), true, true);
44
string ResultBuffer::result_declaration() const {
46
if (!(_type->isVoid () || _type->isUndefined ())) {
48
out << "AC::ResultBuffer< " << result_type ("", false) << " > result";
50
out << result_type ("result", true);
56
string ResultBuffer::result_assignment(const string &result) const {
58
if (!(_type->isVoid() || _type->isUndefined ())) {
60
out << "::new (&result) ";
61
out << result_type ("", true);
66
if (_type->isAddress ())
70
if (!(_type->isVoid() || _type->isUndefined ()))
76
string ResultBuffer::action_result_assignment(const string &result) const {
78
if (!(_type->isVoid() || _type->isUndefined ())) {
80
out << "::new ((AC::ResultBuffer< ";
81
out << result_type ("", false);
82
out << " >*)__TJP::result ()) ";
83
out << result_type ("", false);
87
out << "*__TJP::result () = (" << result_type ("", false) << ")";
89
if (_type->isAddress ())
93
if (!(_type->isVoid() || _type->isUndefined ()))
99
string ResultBuffer::result_return() const {
101
if (!(_type->isVoid () || _type->isUndefined ())) {
103
if (_type->isAddress ())
106
out << result_type ("&");
107
out << ")result;" << endl;