source: src/Parser/ExpressionNode.cc @ ba01b14

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprpersistent-indexerpthread-emulationqualifiedEnum
Last change on this file since ba01b14 was ba01b14, checked in by Peter A. Buhr <pabuhr@…>, 5 years ago

update constant parsing add _FloatNN

  • Property mode set to 100644
File size: 21.2 KB
Line 
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//
7// ExpressionNode.cc --
8//
9// Author           : Peter A. Buhr
10// Created On       : Sat May 16 13:17:07 2015
11// Last Modified By : Peter A. Buhr
12// Last Modified On : Thu Feb  7 22:35:29 2019
13// Update Count     : 900
14//
15
16#include <cassert>                 // for assert
17#include <stdio.h>                 // for sscanf, size_t
18#include <climits>                 // for LLONG_MAX, LONG_MAX, INT_MAX, UINT...
19#include <list>                    // for list
20#include <sstream>                 // for basic_istream::operator>>, basic_i...
21#include <string>                  // for string, operator+, operator==
22
23#include "Common/SemanticError.h"  // for SemanticError
24#include "Common/utility.h"        // for maybeMoveBuild, maybeBuild, CodeLo...
25#include "ParseNode.h"             // for ExpressionNode, maybeMoveBuildType
26#include "SynTree/Constant.h"      // for Constant
27#include "SynTree/Declaration.h"   // for EnumDecl, StructDecl, UnionDecl
28#include "SynTree/Expression.h"    // for Expression, ConstantExpr, NameExpr
29#include "SynTree/Statement.h"     // for CompoundStmt, Statement
30#include "SynTree/Type.h"          // for BasicType, Type, Type::Qualifiers
31#include "parserutility.h"         // for notZeroExpr
32
33class Initializer;
34
35using namespace std;
36
37//##############################################################################
38
39// Difficult to separate extra parts of constants during lexing because actions are not allow in the middle of patterns:
40//
41//              prefix action constant action suffix
42//
43// Alternatively, breaking a pattern using BEGIN does not work if the following pattern can be empty:
44//
45//              constant BEGIN CONT ...
46//              <CONT>(...)? BEGIN 0 ... // possible empty suffix
47//
48// because the CONT rule is NOT triggered if the pattern is empty. Hence, constants are reparsed here to determine their
49// type.
50
51extern const Type::Qualifiers noQualifiers;                             // no qualifiers on constants
52
53// static inline bool checkH( char c ) { return c == 'h' || c == 'H'; }
54// static inline bool checkZ( char c ) { return c == 'z' || c == 'Z'; }
55// static inline bool checkU( char c ) { return c == 'u' || c == 'U'; }
56static inline bool checkF( char c ) { return c == 'f' || c == 'F'; }
57static inline bool checkD( char c ) { return c == 'd' || c == 'D'; }
58static inline bool checkF80( char c ) { return c == 'w' || c == 'W'; }
59static inline bool checkL( char c ) { return c == 'l' || c == 'L'; }
60static inline bool checkF128( char c ) { return c == 'q' || c == 'Q'; }
61static inline bool checkI( char c ) { return c == 'i' || c == 'I'; }
62static inline bool checkB( char c ) { return c == 'b' || c == 'B'; }
63static inline bool checkX( char c ) { return c == 'x' || c == 'X'; }
64
65Expression * build_constantInteger( string & str ) {
66        static const BasicType::Kind kind[2][6] = {
67                // short (h) must be before char (hh) because shorter type has the longer suffix
68                { BasicType::ShortSignedInt, BasicType::SignedChar, BasicType::SignedInt, BasicType::LongSignedInt, BasicType::LongLongSignedInt, BasicType::SignedInt128, },
69                { BasicType::ShortUnsignedInt, BasicType::UnsignedChar, BasicType::UnsignedInt, BasicType::LongUnsignedInt, BasicType::LongLongUnsignedInt, BasicType::UnsignedInt128, },
70        };
71
72        static const char * lnthsInt[2][5] = {
73                { "int16_t",  "int8_t",  "int32_t",  "int64_t",  "size_t", },
74                { "uint16_t", "uint8_t", "uint32_t", "uint64_t", "size_t", },
75        }; // lnthsInt
76
77        bool dec = true, Unsigned = false;                                      // decimal, unsigned constant
78        int type = -1;                                                                          // 0 => short, 1 => char, 2 => int, 3 => long int, 4 => long long int, 5 => int128
79        int ltype = -1;                                                                         // literal length
80
81        unsigned long long int v;                                                       // converted integral value
82        size_t last = str.length() - 1;                                         // last subscript of constant
83        Expression * ret;
84
85        // special constants
86        if ( str == "0" ) {
87                ret = new ConstantExpr( Constant( (Type *)new ZeroType( noQualifiers ), str, (unsigned long long int)0 ) );
88                goto CLEANUP;
89        } // if
90        if ( str == "1" ) {
91                ret = new ConstantExpr( Constant( (Type *)new OneType( noQualifiers ), str, (unsigned long long int)1 ) );
92                goto CLEANUP;
93        } // if
94
95        // Cannot be "0"
96
97        if ( str[0] == '0' ) {                                                          // radix character ?
98                dec = false;
99                if ( checkX( str[1] ) ) {                                               // hex constant ?
100                        sscanf( (char *)str.c_str(), "%llx", &v );
101                        //printf( "%llx %llu\n", v, v );
102                } else if ( checkB( str[1] ) ) {                                // binary constant ?
103                        v = 0;                                                                          // compute value
104                        for ( unsigned int i = 2;; ) {
105                                if ( str[i] == '1' ) v |= 1;
106                                i += 1;
107                          if ( i == last - 1 || (str[i] != '0' && str[i] != '1') ) break;
108                                v <<= 1;
109                        } // for
110                        //printf( "%#llx %llu\n", v, v );
111                } else {                                                                                // octal constant
112                        sscanf( (char *)str.c_str(), "%llo", &v );
113                        //printf( "%#llo %llu\n", v, v );
114                } // if
115        } else {                                                                                        // decimal constant ?
116                sscanf( (char *)str.c_str(), "%llu", &v );
117                //printf( "%llu %llu\n", v, v );
118        } // if
119
120        // At least one digit in integer constant, so safe to backup while looking for suffix.
121
122        string::size_type posn;
123
124        if ( str.find_last_of( "uU" ) != string::npos ) Unsigned = true;
125
126        posn = str.rfind( "hh" );
127        if ( posn != string::npos ) { type = 1; str.erase( posn, 2 ); goto FINI; }
128
129        posn = str.rfind( "HH" );
130        if ( posn != string::npos ) { type = 1; str.erase( posn, 2 ); goto FINI; }
131
132        posn = str.find_last_of( "hH" );
133        if ( posn != string::npos ) { type = 0; str.erase( posn, 1 ); goto FINI; }
134
135        posn = str.find_last_of( "zZ" );
136        if ( posn != string::npos ) { Unsigned = true; type = 2; ltype = 4; str.erase( posn, 1 ); goto FINI; }
137
138        if ( str.rfind( "ll" ) != string::npos || str.rfind( "LL" ) != string::npos ) { type = 4; goto FINI; }
139
140        posn = str.find_last_of( "lL" );
141        if ( posn != string::npos ) {
142                type = 3;                                                                               // default
143                posn += 1;                                                                              // advance to size
144                if ( str[posn] == '3' ) {                                               // 32
145                        type = ltype = 2; str.erase( posn, 2 );
146                } else if ( str[posn] == '6' ) {                                // 64
147                        type = ltype = 3; str.erase( posn, 2 );
148                } else if ( str[posn] == '8' ) {                                // 8
149                        type = ltype = 1; str.erase( posn, 1 );
150                } else if ( str[posn] == '1' ) {
151                        if ( str[posn + 1] == '6' ) {                           // 16
152                                type = ltype = 0; str.erase( posn, 2 );
153                        } else {                                                                        // 128
154                                type = ltype = 5; str.erase( posn, 3 );
155                        } // if
156                } // if
157        } // if
158  FINI:
159
160        if ( type == -1 ) {                                                                     // no suffix type, use value
161                if ( v <= INT_MAX ) {                                                   // signed int
162                        type = 2;
163                } else if ( v <= UINT_MAX && ! dec ) {                  // unsigned int
164                        type = 2;
165                        Unsigned = true;                                                        // unsigned
166                } else if ( v <= LONG_MAX ) {                                   // signed long int
167                        type = 3;
168                } else if ( v <= ULONG_MAX && ( ! dec || LONG_MAX == LLONG_MAX ) ) { // signed long int
169                        type = 3;
170                        Unsigned = true;                                                        // unsigned long int
171                } else if ( v <= LLONG_MAX ) {                                  // signed long long int
172                        type = 4;
173                } else {                                                                                // unsigned long long int
174                        type = 4;
175                        Unsigned = true;                                                        // unsigned long long int
176                } // if
177        } // if
178
179        assert( 0 <= type && type < 6 );
180        // Constant type is correct for overload resolving.
181        ret = new ConstantExpr( Constant( new BasicType( noQualifiers, kind[Unsigned][type] ), str, v ) );
182        if ( Unsigned && type < 2 ) {                                           // hh or h, less than int ?
183                // int i = -1uh => 65535 not -1, so cast is necessary for unsigned, which unfortunately eliminates warnings for large values.
184                ret = new CastExpr( ret, new BasicType( Type::Qualifiers(), kind[Unsigned][type] ), false );
185        } else if ( ltype != -1 ) {                                                     // explicit length ?
186                if ( ltype == 5 ) {                                                             // int128 ?
187                        type = 5;
188                        ret = new CastExpr( ret, new BasicType( Type::Qualifiers(), kind[Unsigned][type] ), false );
189                } else {
190                        ret = new CastExpr( ret, new TypeInstType( Type::Qualifiers(), lnthsInt[Unsigned][ltype], false ), false );
191                } // if
192        } // if
193  CLEANUP:
194
195        delete &str;                                                                            // created by lex
196        return ret;
197} // build_constantInteger
198
199
200static inline void checkFnxFloat( string & str, size_t last, bool & explnth, int & type ) {
201        string::size_type posn;
202        // floating-point constant has minimum of 2 characters, 1. or .1, so safe to look ahead
203        if ( str[1] == 'x' ) {                                                          // hex ?
204                posn = str.find_last_of( "pP" );                                // back for exponent (must have)
205                posn = str.find_first_of( "fF", posn + 1 );             // forward for size (fF allowed in hex constant)
206        } else {
207                posn = str.find_last_of( "fF" );                                // back for size (fF not allowed)
208        } // if
209  if ( posn == string::npos ) return;
210        explnth = true;
211        posn += 1;                                                                                      // advance to size
212        if ( str[posn] == '3' ) {                                                       // 32
213                if ( str[last] != 'x' ) type = 6;
214                else type = 7;
215        } else if ( str[posn] == '6' ) {                                        // 64
216                if ( str[last] != 'x' ) type = 8;
217                else type = 9;
218        } else if ( str[posn] == '8' ) {                                        // 80
219                type = 3;
220        } else if ( str[posn] == '1' ) {                                        // 16/128
221                if ( str[posn + 1] == '6' ) {                                   // 16
222                        type = 5;
223                } else {                                                                                // 128
224                        if ( str[last] != 'x' ) type = 10;
225                        else type = 11;
226                } // if
227        } else {
228                assertf( false, "internal error, bad floating point length %s", str.c_str() );
229        } // if
230} // checkFnxFloat
231
232
233Expression * build_constantFloat( string & str ) {
234        static const BasicType::Kind kind[2][12] = {
235                { BasicType::Float, BasicType::Double, BasicType::LongDouble, BasicType::__float80, BasicType::__float128, BasicType::_Float16, BasicType::_Float32, BasicType::_Float32x, BasicType::_Float64, BasicType::_Float64x, BasicType::_Float128, BasicType::_Float128x },
236                { BasicType::FloatComplex, BasicType::DoubleComplex, BasicType::LongDoubleComplex, (BasicType::Kind)-1, (BasicType::Kind)-1, BasicType::_Float16Complex, BasicType::_Float32Complex, BasicType::_Float32xComplex, BasicType::_Float64Complex, BasicType::_Float64xComplex, BasicType::_Float128Complex, BasicType::_Float128xComplex },
237        };
238
239        // floating-point constant has minimum of 2 characters 1. or .1
240        size_t last = str.length() - 1;
241        double v;
242        int type;                                                                                       // 0 => float, 1 => double, 3 => long double, ...
243        bool complx = false;                                                            // real, complex
244        bool explnth = false;                                                           // explicit literal length
245
246        sscanf( str.c_str(), "%lg", &v );
247
248        if ( checkI( str[last] ) ) {                                            // imaginary ?
249                complx = true;
250                last -= 1;                                                                              // backup one character
251        } // if
252
253        if ( checkF( str[last] ) ) {                                            // float ?
254                type = 0;
255        } else if ( checkD( str[last] ) ) {                                     // double ?
256                type = 1;
257        } else if ( checkL( str[last] ) ) {                                     // long double ?
258                type = 2;
259        } else if ( checkF80( str[last] ) ) {                           // __float80 ?
260                type = 3;
261        } else if ( checkF128( str[last] ) ) {                          // __float128 ?
262                type = 4;
263        } else {
264                type = 1;                                                                               // double (default if no suffix)
265                checkFnxFloat( str, last, explnth, type );
266        } // if
267
268        if ( ! complx && checkI( str[last - 1] ) ) {            // imaginary ?
269                complx = true;
270        } // if
271
272        assert( 0 <= type && type < 12 );
273        Expression * ret = new ConstantExpr( Constant( new BasicType( noQualifiers, kind[complx][type] ), str, v ) );
274        if ( explnth ) {                                                                        // explicit length ?
275                ret = new CastExpr( ret, new BasicType( Type::Qualifiers(), kind[complx][type] ), false );
276        } // if
277
278        delete &str;                                                                            // created by lex
279        return ret;
280} // build_constantFloat
281
282static void sepString( string & str, string & units, char delimit ) {
283        string::size_type posn = str.find_last_of( delimit ) + 1;
284        if ( posn != str.length() ) {
285                units = "?" + str.substr( posn );                               // extract units
286                str.erase( posn );                                                              // remove units
287        } // if
288} // sepString
289
290Expression * build_constantChar( string & str ) {
291        string units;                                                                           // units
292        sepString( str, units, '\'' );                                          // separate constant from units
293
294        Expression * ret = new ConstantExpr( Constant( new BasicType( noQualifiers, BasicType::Char ), str, (unsigned long long int)(unsigned char)str[1] ) );
295        if ( units.length() != 0 ) {
296                ret = new UntypedExpr( new NameExpr( units ), { ret } );
297        } // if
298
299        delete &str;                                                                            // created by lex
300        return ret;
301} // build_constantChar
302
303Expression * build_constantStr( string & str ) {
304        assert( str.length() > 0 );
305        string units;                                                                           // units
306        sepString( str, units, '"' );                                           // separate constant from units
307
308        Type * strtype;
309        switch ( str[0] ) {                                                                     // str has >= 2 characters, i.e, null string "" => safe to look at subscripts 0/1
310          case 'u':
311                if ( str[1] == '8' ) goto Default;                              // utf-8 characters => array of char
312                // lookup type of associated typedef
313                strtype = new TypeInstType( Type::Qualifiers( Type::Const ), "char16_t", false );
314                break;
315          case 'U':
316                strtype = new TypeInstType( Type::Qualifiers( Type::Const ), "char32_t", false );
317                break;
318          case 'L':
319                strtype = new TypeInstType( Type::Qualifiers( Type::Const ), "wchar_t", false );
320                break;
321          Default:                                                                                      // char default string type
322          default:
323                strtype = new BasicType( Type::Qualifiers( Type::Const ), BasicType::Char );
324        } // switch
325        ArrayType * at = new ArrayType( noQualifiers, strtype,
326                                                                        new ConstantExpr( Constant::from_ulong( str.size() + 1 - 2 ) ), // +1 for '\0' and -2 for '"'
327                                                                        false, false );
328        Expression * ret = new ConstantExpr( Constant( at, str, (unsigned long long int)0 ) ); // constant 0 is ignored for pure string value
329        if ( units.length() != 0 ) {
330                ret = new UntypedExpr( new NameExpr( units ), { ret } );
331        } // if
332
333        delete &str;                                                                            // created by lex
334        return ret;
335} // build_constantStr
336
337Expression * build_field_name_FLOATING_FRACTIONconstant( const string & str ) {
338        if ( str.find_first_not_of( "0123456789", 1 ) != string::npos ) SemanticError( yylloc, "invalid tuple index " + str );
339        Expression * ret = build_constantInteger( *new string( str.substr(1) ) );
340        delete &str;
341        return ret;
342} // build_field_name_FLOATING_FRACTIONconstant
343
344Expression * build_field_name_FLOATING_DECIMALconstant( const string & str ) {
345        if ( str[str.size()-1] != '.' ) SemanticError( yylloc, "invalid tuple index " + str );
346        Expression * ret = build_constantInteger( *new string( str.substr( 0, str.size()-1 ) ) );
347        delete &str;
348        return ret;
349} // build_field_name_FLOATING_DECIMALconstant
350
351Expression * build_field_name_FLOATINGconstant( const string & str ) {
352        // str is of the form A.B -> separate at the . and return member expression
353        int a, b;
354        char dot;
355        stringstream ss( str );
356        ss >> a >> dot >> b;
357        UntypedMemberExpr * ret = new UntypedMemberExpr( new ConstantExpr( Constant::from_int( b ) ), new ConstantExpr( Constant::from_int( a ) ) );
358        delete &str;
359        return ret;
360} // build_field_name_FLOATINGconstant
361
362Expression * make_field_name_fraction_constants( Expression * fieldName, Expression * fracts ) {
363        if ( fracts ) {
364                if ( UntypedMemberExpr * memberExpr = dynamic_cast< UntypedMemberExpr * >( fracts ) ) {
365                        memberExpr->set_member( make_field_name_fraction_constants( fieldName, memberExpr->get_aggregate() ) );
366                        return memberExpr;
367                } else {
368                        return new UntypedMemberExpr( fracts, fieldName );
369                } // if
370        } // if
371        return fieldName;
372} // make_field_name_fraction_constants
373
374Expression * build_field_name_fraction_constants( Expression * fieldName, ExpressionNode * fracts ) {
375        return make_field_name_fraction_constants( fieldName, maybeMoveBuild< Expression >( fracts ) );
376} // build_field_name_fraction_constants
377
378NameExpr * build_varref( const string * name ) {
379        NameExpr * expr = new NameExpr( *name );
380        delete name;
381        return expr;
382} // build_varref
383
384// TODO: get rid of this and OperKinds and reuse code from OperatorTable
385static const char * OperName[] = {                                              // must harmonize with OperKinds
386        // diadic
387        "SizeOf", "AlignOf", "OffsetOf", "?+?", "?-?", "?\\?", "?*?", "?/?", "?%?", "||", "&&",
388        "?|?", "?&?", "?^?", "Cast", "?<<?", "?>>?", "?<?", "?>?", "?<=?", "?>=?", "?==?", "?!=?",
389        "?=?", "?@=?", "?\\=?", "?*=?", "?/=?", "?%=?", "?+=?", "?-=?", "?<<=?", "?>>=?", "?&=?", "?^=?", "?|=?",
390        "?[?]", "...",
391        // monadic
392        "+?", "-?", "AddressOf", "*?", "!?", "~?", "++?", "?++", "--?", "?--",
393}; // OperName
394
395Expression * build_cast( DeclarationNode * decl_node, ExpressionNode * expr_node ) {
396        Type * targetType = maybeMoveBuildType( decl_node );
397        if ( dynamic_cast< VoidType * >( targetType ) ) {
398                delete targetType;
399                return new CastExpr( maybeMoveBuild< Expression >(expr_node), false );
400        } else {
401                return new CastExpr( maybeMoveBuild< Expression >(expr_node), targetType, false );
402        } // if
403} // build_cast
404
405Expression * build_keyword_cast( KeywordCastExpr::Target target, ExpressionNode * expr_node ) {
406        return new KeywordCastExpr( maybeMoveBuild< Expression >(expr_node), target );
407}
408
409Expression * build_virtual_cast( DeclarationNode * decl_node, ExpressionNode * expr_node ) {
410        return new VirtualCastExpr( maybeMoveBuild< Expression >( expr_node ), maybeMoveBuildType( decl_node ) );
411} // build_virtual_cast
412
413Expression * build_fieldSel( ExpressionNode * expr_node, Expression * member ) {
414        return new UntypedMemberExpr( member, maybeMoveBuild< Expression >(expr_node) );
415} // build_fieldSel
416
417Expression * build_pfieldSel( ExpressionNode * expr_node, Expression * member ) {
418        UntypedExpr * deref = new UntypedExpr( new NameExpr( "*?" ) );
419        deref->location = expr_node->location;
420        deref->get_args().push_back( maybeMoveBuild< Expression >(expr_node) );
421        UntypedMemberExpr * ret = new UntypedMemberExpr( member, deref );
422        return ret;
423} // build_pfieldSel
424
425Expression * build_offsetOf( DeclarationNode * decl_node, NameExpr * member ) {
426        Expression * ret = new UntypedOffsetofExpr( maybeMoveBuildType( decl_node ), member->get_name() );
427        delete member;
428        return ret;
429} // build_offsetOf
430
431Expression * build_and_or( ExpressionNode * expr_node1, ExpressionNode * expr_node2, bool kind ) {
432        return new LogicalExpr( notZeroExpr( maybeMoveBuild< Expression >(expr_node1) ), notZeroExpr( maybeMoveBuild< Expression >(expr_node2) ), kind );
433} // build_and_or
434
435Expression * build_unary_val( OperKinds op, ExpressionNode * expr_node ) {
436        list< Expression * > args;
437        args.push_back( maybeMoveBuild< Expression >(expr_node) );
438        return new UntypedExpr( new NameExpr( OperName[ (int)op ] ), args );
439} // build_unary_val
440
441Expression * build_unary_ptr( OperKinds op, ExpressionNode * expr_node ) {
442        list< Expression * > args;
443        args.push_back(  maybeMoveBuild< Expression >(expr_node) ); // xxx -- this is exactly the same as the val case now, refactor this code.
444        return new UntypedExpr( new NameExpr( OperName[ (int)op ] ), args );
445} // build_unary_ptr
446
447Expression * build_binary_val( OperKinds op, ExpressionNode * expr_node1, ExpressionNode * expr_node2 ) {
448        list< Expression * > args;
449        args.push_back( maybeMoveBuild< Expression >(expr_node1) );
450        args.push_back( maybeMoveBuild< Expression >(expr_node2) );
451        return new UntypedExpr( new NameExpr( OperName[ (int)op ] ), args );
452} // build_binary_val
453
454Expression * build_binary_ptr( OperKinds op, ExpressionNode * expr_node1, ExpressionNode * expr_node2 ) {
455        list< Expression * > args;
456        args.push_back( maybeMoveBuild< Expression >(expr_node1) );
457        args.push_back( maybeMoveBuild< Expression >(expr_node2) );
458        return new UntypedExpr( new NameExpr( OperName[ (int)op ] ), args );
459} // build_binary_ptr
460
461Expression * build_cond( ExpressionNode * expr_node1, ExpressionNode * expr_node2, ExpressionNode * expr_node3 ) {
462        return new ConditionalExpr( notZeroExpr( maybeMoveBuild< Expression >(expr_node1) ), maybeMoveBuild< Expression >(expr_node2), maybeMoveBuild< Expression >(expr_node3) );
463} // build_cond
464
465Expression * build_tuple( ExpressionNode * expr_node ) {
466        list< Expression * > exprs;
467        buildMoveList( expr_node, exprs );
468        return new UntypedTupleExpr( exprs );;
469} // build_tuple
470
471Expression * build_func( ExpressionNode * function, ExpressionNode * expr_node ) {
472        list< Expression * > args;
473        buildMoveList( expr_node, args );
474        return new UntypedExpr( maybeMoveBuild< Expression >(function), args );
475} // build_func
476
477Expression * build_compoundLiteral( DeclarationNode * decl_node, InitializerNode * kids ) {
478        Declaration * newDecl = maybeBuild< Declaration >(decl_node); // compound literal type
479        if ( DeclarationWithType * newDeclWithType = dynamic_cast< DeclarationWithType * >( newDecl ) ) { // non-sue compound-literal type
480                return new CompoundLiteralExpr( newDeclWithType->get_type(), maybeMoveBuild< Initializer >(kids) );
481        // these types do not have associated type information
482        } else if ( StructDecl * newDeclStructDecl = dynamic_cast< StructDecl * >( newDecl )  ) {
483                if ( newDeclStructDecl->has_body() ) {
484                        return new CompoundLiteralExpr( new StructInstType( Type::Qualifiers(), newDeclStructDecl ), maybeMoveBuild< Initializer >(kids) );
485                } else {
486                        return new CompoundLiteralExpr( new StructInstType( Type::Qualifiers(), newDeclStructDecl->get_name() ), maybeMoveBuild< Initializer >(kids) );
487                } // if
488        } else if ( UnionDecl * newDeclUnionDecl = dynamic_cast< UnionDecl * >( newDecl )  ) {
489                if ( newDeclUnionDecl->has_body() ) {
490                        return new CompoundLiteralExpr( new UnionInstType( Type::Qualifiers(), newDeclUnionDecl ), maybeMoveBuild< Initializer >(kids) );
491                } else {
492                        return new CompoundLiteralExpr( new UnionInstType( Type::Qualifiers(), newDeclUnionDecl->get_name() ), maybeMoveBuild< Initializer >(kids) );
493                } // if
494        } else if ( EnumDecl * newDeclEnumDecl = dynamic_cast< EnumDecl * >( newDecl )  ) {
495                if ( newDeclEnumDecl->has_body() ) {
496                        return new CompoundLiteralExpr( new EnumInstType( Type::Qualifiers(), newDeclEnumDecl ), maybeMoveBuild< Initializer >(kids) );
497                } else {
498                        return new CompoundLiteralExpr( new EnumInstType( Type::Qualifiers(), newDeclEnumDecl->get_name() ), maybeMoveBuild< Initializer >(kids) );
499                } // if
500        } else {
501                assert( false );
502        } // if
503} // build_compoundLiteral
504
505// Local Variables: //
506// tab-width: 4 //
507// mode: c++ //
508// compile-command: "make install" //
509// End: //
Note: See TracBrowser for help on using the repository browser.