~ubuntu-branches/ubuntu/maverick/aspectc++/maverick

« back to all changes in this revision

Viewing changes to Puma/gen-release/step1/aspects/WinIfExists.ah

  • 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:
27
27
#include "Puma/CTokens.h"
28
28
#include "Puma/Token.h"
29
29
 
30
 
using namespace Puma;
31
 
 
32
30
namespace Puma {
33
31
  slice class WinIfExistsCpp;
34
32
}
46
44
 
47
45
  // preprocess __if_exists and __if_not_exists statements
48
46
  advice execution ("% Puma::PreprocessorParser::next()") : around () {
49
 
    Token *token;
 
47
    Puma::Token *token;
50
48
    int type;
51
49
    JoinPoint::That *preparser;
52
50
  
53
 
        preparser = tjp->that ();
 
51
    preparser = tjp->that ();
54
52
    tjp->proceed (); // get the next token
55
53
    token = *tjp->result ();
56
54
    if (token) {
57
55
      type = token->type ();
58
56
      // __if_exists (...) { ... }
59
 
      if (type == TOK_IF_EXISTS) {
60
 
        preparser->skip_up_to (TOK_CLOSE_CURLY);
61
 
                    *(Token**)thisJoinPoint->result () = preparser->next ();
62
 
                    return;
 
57
      if (type == Puma::TOK_IF_EXISTS) {
 
58
        preparser->skip_up_to (Puma::TOK_CLOSE_CURLY);
 
59
        *(Puma::Token**)thisJoinPoint->result () = preparser->next ();
 
60
        return;
63
61
        // __if_not_exists (...) { ... }
64
 
      } else if (type == TOK_IF_NOT_EXISTS) {
65
 
        preparser->skip_up_to (TOK_OPEN_CURLY);
 
62
      } else if (type == Puma::TOK_IF_NOT_EXISTS) {
 
63
        preparser->skip_up_to (Puma::TOK_OPEN_CURLY);
66
64
        preparser->_depth.push (1);
67
 
                    *(Token**)thisJoinPoint->result () = preparser->next ();
68
 
                    return;
 
65
        *(Puma::Token**)thisJoinPoint->result () = preparser->next ();
 
66
        return;
69
67
      }
70
68
      // skip closing `}' of __if_not_exists
71
69
      if (preparser->_depth.length ()) {
72
 
        if (type == TOK_OPEN_CURLY) 
 
70
        if (type == Puma::TOK_OPEN_CURLY) 
73
71
          preparser->_depth.top () = preparser->_depth.top () + 1;
74
 
        else if (type == TOK_CLOSE_CURLY) { 
 
72
        else if (type == Puma::TOK_CLOSE_CURLY) { 
75
73
          preparser->_depth.top () = preparser->_depth.top () - 1;
76
 
                    if (preparser->_depth.top () == 0) {
77
 
                  preparser->_depth.pop ();
78
 
                  *(Token**)thisJoinPoint->result () = preparser->next ();
79
 
                  return;
80
 
                    }
 
74
          if (preparser->_depth.top () == 0) {
 
75
            preparser->_depth.pop ();
 
76
            *(Puma::Token**)thisJoinPoint->result () = preparser->next ();
 
77
            return;
 
78
          }
81
79
        }
82
80
      }
83
81
    }
91
89
  slice class WinIfExistsCpp {
92
90
  public:
93
91
    // introduce data member into preprocessor
94
 
    Stack<unsigned> _depth;
 
92
    Puma::Stack<unsigned> _depth;
95
93
    // introduce method into preprocessor
96
94
    void skip_up_to (int);
97
95
  };
99
97
  // skip __if_exists resp. __if_not_exists statement
100
98
  slice void WinIfExistsCpp::skip_up_to (int end_token) {
101
99
    unsigned parenthesis = 0, curlies = 0;
102
 
    Token *token;
 
100
    Puma::Token *token;
103
101
    int type;
104
102
    
105
103
    // skip up to the first non-nested `{'
106
104
    while ((token = parseToken ())) {
107
105
      type = token->type ();
108
 
      if (type == TOK_OPEN_CURLY) {
 
106
      if (type == Puma::TOK_OPEN_CURLY) {
109
107
        if (parenthesis == 0 && curlies == 0)
110
108
          break;
111
109
        curlies++;
112
 
      } else if (type == TOK_CLOSE_CURLY)
 
110
      } else if (type == Puma::TOK_CLOSE_CURLY)
113
111
        curlies--;
114
 
      else if (type == TOK_OPEN_ROUND)
 
112
      else if (type == Puma::TOK_OPEN_ROUND)
115
113
        parenthesis++;
116
 
      else if (type == TOK_CLOSE_ROUND)
 
114
      else if (type == Puma::TOK_CLOSE_ROUND)
117
115
        parenthesis--;
118
116
    }
119
117
    
120
118
    // skip up to the first non-nested `}'
121
 
    if (end_token == TOK_CLOSE_CURLY) {
 
119
    if (end_token == Puma::TOK_CLOSE_CURLY) {
122
120
      parenthesis = curlies = 0;
123
121
      while ((token = parseToken ())) {
124
122
        type = token->type ();
125
 
        if (type == TOK_OPEN_CURLY)
 
123
        if (type == Puma::TOK_OPEN_CURLY)
126
124
          curlies++;
127
 
        else if (type == TOK_CLOSE_CURLY) {
 
125
        else if (type == Puma::TOK_CLOSE_CURLY) {
128
126
          if (parenthesis == 0 && curlies == 0)
129
127
            break;
130
128
          curlies--;
131
 
        } else if (type == TOK_OPEN_ROUND)
 
129
        } else if (type == Puma::TOK_OPEN_ROUND)
132
130
          parenthesis++;
133
 
        else if (type == TOK_CLOSE_ROUND)
 
131
        else if (type == Puma::TOK_CLOSE_ROUND)
134
132
          parenthesis--;
135
133
      }
136
134
    }