~ubuntu-branches/ubuntu/jaunty/aspectc++/jaunty

« back to all changes in this revision

Viewing changes to Puma/src/aspects/ExtGnu.ah

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2008-07-07 14:41:02 UTC
  • mfrom: (1.1.3 upstream) (6.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080707144102-lzml7t07f3sl00r5
Tags: 1.0pre4~svn.20080711-1
* new upstream snapshot.
* include all upstream documentation. Clarifying emails regarding
  licensing has been included into debian/copyright.
* reformat description following recomendations of
  http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Description
  (Closes: #480316)

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
  bool std_hack;
58
58
  bool typeof_keyword;
59
59
  bool statement_exprs;
 
60
  bool labels_as_values;
60
61
 
61
62
  // pointcut definitions
62
63
  pointcut node ()          = "Puma::CT_AsmDef";
160
161
      tjp->proceed ();
161
162
  }
162
163
 
 
164
  // ----------------------------------------
 
165
  // support for "labels as values" extension 
 
166
  // ----------------------------------------
 
167
 
 
168
  // extended goto syntax
 
169
  advice within (derived (syntax ())) &&
 
170
    execution ("% ...::jump_stmt()") : around () {
 
171
    JoinPoint::That *syntax = tjp->that ();
 
172
    if (labels_as_values && 
 
173
        syntax->look_ahead (Puma::TOK_GOTO) &&
 
174
        syntax->look_ahead (Puma::TOK_MUL, 2)) {
 
175
      syntax->consume (); // skip the 'goto' keyword
 
176
      Puma::CTree *&result = *(Puma::CTree**)tjp->result ();
 
177
      result = (syntax->parse (&JoinPoint::That::expr) &&
 
178
                syntax->parse (Puma::TOK_SEMI_COLON)) ?
 
179
               syntax->builder().jump_stmt () : 0;
 
180
    }
 
181
    else
 
182
      tjp->proceed ();
 
183
  }
 
184
 
 
185
  // the address of a label
 
186
    advice within (derived (syntax ())) &&
 
187
      execution ("% ...::unary_expr()") : around () {
 
188
      JoinPoint::That *syntax = tjp->that ();
 
189
      if (labels_as_values && 
 
190
          syntax->look_ahead (Puma::TOK_AND_AND)) {
 
191
        syntax->consume (); // consume the '&&' token, already checked
 
192
        Puma::CTree *&result = *(Puma::CTree**)tjp->result ();
 
193
        result = syntax->identifier () ? syntax->builder().unary_expr () : 0;
 
194
      }
 
195
      else
 
196
        tjp->proceed ();
 
197
    }
 
198
 
 
199
  // extended semantic analysis
 
200
  advice within ("Puma::%CSemVisitor") &&
 
201
    execution ("% ...::check_goto_label(...)") &&
 
202
    args (tree) : around (Puma::CTree *tree) {
 
203
    if (tree->NodeName () == Puma::CT_SimpleName::NodeId ())
 
204
      tjp->proceed ();
 
205
    else if (tree->NodeName () == Puma::CT_DerefExpr::NodeId ())
 
206
      tjp->that ()->resolveExpr (((Puma::CT_DerefExpr*)tree)->Expr (), tree);
 
207
  }
 
208
 
 
209
  // label address has type void*
 
210
  advice within ("Puma::%CSemExpr") &&
 
211
    execution ("% ...::resolve(Puma::CT_UnaryExpr *, Puma::CTree *)") : around () {
 
212
      int oper = (*tjp->arg<0>())->token ()->type ();
 
213
      if (oper == Puma::TOK_AND_AND) {
 
214
        // TODO: It would be better to whether the label really exists, but
 
215
        //       at the moment I don't see a way how to do that.
 
216
        //       (In the gcc extension the label can be defined anywhere in
 
217
        //        the translation unit!)
 
218
        //       It is also not possible to use the error handling macros here.
 
219
        Puma::CTypeInfo *t = new Puma::CTypePointer (&Puma::CTYPE_VOID);
 
220
        (*tjp->arg<0>())->setType (t);
 
221
        *tjp->result () = t;
 
222
      }
 
223
      else
 
224
        tjp->proceed ();
 
225
  }
 
226
 
163
227
  // ----------------------
164
228
  // TYPEOF keyword support
165
229
  // ----------------------
296
360
      gnu_builtins     = true;
297
361
      typeof_keyword   = true;
298
362
      statement_exprs  = true;
 
363
      labels_as_values = true;
299
364
    }
300
365
    if (config.Option ("--gnu-extended-asm"))
301
366
      extended_asm = true;