Last change
on this file since 0a9b5c1 was
61e362f,
checked in by Andrew Beach <ajbeach@…>, 9 months ago
|
Changed notZeroExpr so that expressions with conditional contexts are handled in the resolver instead of the parser. Bugs kept the same from being done with statements. (Also a bit of clean-up from the last commit and a small fix in code-gen.)
|
-
Property mode set to
100644
|
File size:
1.2 KB
|
Rev | Line | |
---|
[b87a5ed] | 1 | // |
---|
| 2 | // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo |
---|
| 3 | // |
---|
| 4 | // The contents of this file are covered under the licence agreement in the |
---|
| 5 | // file "LICENCE" distributed with Cforall. |
---|
| 6 | // |
---|
[9335ecc] | 7 | // parserutility.cc -- |
---|
[b87a5ed] | 8 | // |
---|
| 9 | // Author : Rodolfo G. Esteves |
---|
| 10 | // Created On : Sat May 16 15:30:39 2015 |
---|
[ac10576] | 11 | // Last Modified By : Andrew Beach |
---|
[bb7422a] | 12 | // Last Modified On : Wed Mar 1 10:42:00 2023 |
---|
| 13 | // Update Count : 9 |
---|
[4cb935e] | 14 | // |
---|
[b87a5ed] | 15 | |
---|
[a67b60e] | 16 | #include "parserutility.h" |
---|
[d180746] | 17 | |
---|
| 18 | #include <list> // for list |
---|
| 19 | #include <string> // for string |
---|
| 20 | |
---|
[bb7422a] | 21 | #include "AST/Expr.hpp" // for UntypedExpr, CastExpr, ConstantExpr |
---|
| 22 | #include "AST/Type.hpp" // for BasicType, ZeroType, BasicType::Kind... |
---|
[51b7345] | 23 | |
---|
[e82aa9df] | 24 | // rewrite |
---|
| 25 | // if ( x ) ... |
---|
| 26 | // as |
---|
| 27 | // if ( (int)(x != 0) ) ... |
---|
| 28 | |
---|
[61e362f] | 29 | ast::Expr * notZeroExpr( const ast::Expr * orig ) { |
---|
[bb7422a] | 30 | return ( !orig ) ? nullptr : new ast::CastExpr( orig->location, |
---|
| 31 | ast::UntypedExpr::createCall( orig->location, |
---|
| 32 | "?!=?", |
---|
| 33 | { |
---|
| 34 | orig, |
---|
| 35 | new ast::ConstantExpr( orig->location, |
---|
| 36 | new ast::ZeroType(), |
---|
| 37 | "0", |
---|
| 38 | std::optional<unsigned long long>( 0 ) |
---|
| 39 | ), |
---|
| 40 | } |
---|
| 41 | ), |
---|
| 42 | new ast::BasicType( ast::BasicType::SignedInt ) |
---|
| 43 | ); |
---|
[51b7345] | 44 | } |
---|
[b87a5ed] | 45 | |
---|
| 46 | // Local Variables: // |
---|
| 47 | // tab-width: 4 // |
---|
| 48 | // mode: c++ // |
---|
| 49 | // compile-command: "make install" // |
---|
| 50 | // End: // |
---|
Note: See
TracBrowser
for help on using the repository browser.