~ubuntu-branches/ubuntu/quantal/aspectc++/quantal

« back to all changes in this revision

Viewing changes to AspectC++/ResultBuffer.cc

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2008-04-10 17:40:52 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20080410174052-xdnsm7oi8hauyyf1
Tags: 1.0pre4~svn.20080409+dfsg-3
Fix another missing include, this time in Ag++/StdSystem.cc

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// This file is part of the AspectC++ compiler 'ac++'.
 
2
// Copyright (C) 1999-2003  The 'ac++' developers (see aspectc.org)
 
3
//                                                                
 
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.            
 
8
//                                                                
 
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.                   
 
13
//                                                                
 
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, 
 
17
// MA  02111-1307  USA                                            
 
18
 
 
19
#include "ResultBuffer.h"
 
20
#include "Puma/CTypeInfo.h"
 
21
#include <sstream>
 
22
using std::stringstream;
 
23
 
 
24
bool ResultBuffer::has_constructor_problem () const {
 
25
  return _type->isRecord () && !_type->isAddress ();
 
26
}
 
27
 
 
28
string ResultBuffer::result_type (const string &name, bool unqual) const {
 
29
  stringstream out;
 
30
  CTypeInfo *type = _type;
 
31
  if (unqual)
 
32
    type = type->UnqualType ();
 
33
  if (type->isVoid () || type->isUndefined ())
 
34
    out << "void";
 
35
  else if (type->isAddress ()) {
 
36
    string ptrname = string ("*") + name;
 
37
    type->BaseType ()->TypeText (out, ptrname.c_str (), true, true);
 
38
  }
 
39
  else
 
40
    type->TypeText (out, name.c_str (), true, true);
 
41
  return out.str ();
 
42
}
 
43
 
 
44
string ResultBuffer::result_declaration() const {
 
45
  stringstream out;
 
46
  if (!(_type->isVoid () || _type->isUndefined ())) {
 
47
    if (_problem)
 
48
      out << "AC::ResultBuffer< " << result_type ("", false) << " > result";
 
49
    else
 
50
      out << result_type ("result", true);
 
51
    out << ";" << endl;
 
52
  }
 
53
  return out.str ();
 
54
}
 
55
 
 
56
string ResultBuffer::result_assignment(const string &result) const {
 
57
  stringstream out;
 
58
  if (!(_type->isVoid() || _type->isUndefined ()))  {
 
59
    if (_problem) {
 
60
      out << "::new (&result) ";
 
61
      out << result_type ("", true);
 
62
      out << " (";
 
63
    }
 
64
    else
 
65
      out << "result = ";
 
66
    if (_type->isAddress ())
 
67
      out << "&";
 
68
  }
 
69
  out << result;
 
70
  if (!(_type->isVoid() || _type->isUndefined ()))
 
71
    if (_problem)
 
72
      out << ")";
 
73
  return out.str ();
 
74
}
 
75
 
 
76
string ResultBuffer::action_result_assignment(const string &result) const {
 
77
  stringstream out;
 
78
  if (!(_type->isVoid() || _type->isUndefined ()))  {
 
79
    if (_problem) {
 
80
      out << "::new ((AC::ResultBuffer< ";
 
81
      out << result_type ("", false);
 
82
      out << " >*)__TJP::result ()) ";
 
83
      out << result_type ("", false);
 
84
      out << " (";
 
85
    }
 
86
    else {
 
87
      out << "*__TJP::result () = (" << result_type ("", false) << ")";
 
88
    }
 
89
    if (_type->isAddress ())
 
90
      out << "&";
 
91
  }
 
92
  out << result;
 
93
  if (!(_type->isVoid() || _type->isUndefined ()))
 
94
    if (_problem)
 
95
      out << ")";
 
96
  return out.str ();
 
97
}
 
98
 
 
99
string ResultBuffer::result_return() const {
 
100
  stringstream out;
 
101
  if (!(_type->isVoid () || _type->isUndefined ())) {
 
102
    out << "return ";
 
103
    if (_type->isAddress ())
 
104
      out << "*";
 
105
    out << "(";
 
106
    out << result_type ("&");
 
107
    out << ")result;" << endl;
 
108
  }
 
109
  return out.str ();
 
110
}