Ignore:
Timestamp:
Mar 23, 2017, 6:11:52 PM (7 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
f20dffa
Parents:
0583064b
Message:

first attempt at named designators

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/Resolver.cc

    r0583064b r6013bd7  
    1010// Created On       : Sun May 17 12:17:01 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jul 12 17:45:42 2016
    13 // Update Count     : 204
     12// Last Modified On : Thu Mar 23 17:23:14 2017
     13// Update Count     : 211
    1414//
    1515
     
    371371        void Resolver::visit( SingleInit *singleInit ) {
    372372                if ( singleInit->get_value() ) {
    373 #if 0
    374                         if (NameExpr * ne = dynamic_cast<NameExpr*>(singleInit->get_value())) {
    375                                 string n = ne->get_name();
    376                                 if (n == "0") {
    377                                         initContext = new BasicType(Type::Qualifiers(),
    378                                                                                                 BasicType::SignedInt);
    379                                 } else {
    380                                         DeclarationWithType * decl = lookupId( n );
    381                                         initContext = decl->get_type();
    382                                 }
    383                         } else if (ConstantExpr * e =
    384                                            dynamic_cast<ConstantExpr*>(singleInit->get_value())) {
    385                                 Constant *c = e->get_constant();
    386                                 initContext = c->get_type();
    387                         } else {
    388                                 assert(0);
    389                         }
    390 #endif
     373                        // // find all the d's
     374                        // std::list<Expression *> &designators = singleInit->get_designators();
     375                        // std::list<Type *> types1{ initContext }, types2;
     376                        // for ( Expression * expr: designators ) {
     377                        //      cerr << expr << endl;
     378                        //      if ( NameExpr * nexpr = dynamic_cast<NameExpr *>( expr ) ) {
     379                        //              for ( Type * type: types1 ) {
     380                        //                      cerr << type << endl;
     381                        //                      ReferenceToType * fred = dynamic_cast<ReferenceToType *>(type);
     382                        //                      std::list<Declaration *> members;
     383                        //                      if ( fred ) {
     384                        //                              fred->lookup( nexpr->get_name(), members ); // concatenate identical field name
     385                        //                              for ( Declaration * mem: members ) {
     386                        //                                      if ( DeclarationWithType * dwt = dynamic_cast<DeclarationWithType *>(mem) ) {
     387                        //                                              types2.push_back( dwt->get_type() );
     388                        //                                      } // if
     389                        //                              } // for
     390                        //                      } // if
     391                        //              } // for
     392                        //              types1 = types2;
     393                        //              types2.clear();
     394                        //      } // if
     395                        // } // for
     396                        // // for ( Type * type: types1 ) {
     397                        // //   cerr << type << endl;
     398                        // // } // for
     399                       
     400                        // // O(N^2) checks of d-types with f-types
     401                        // // find the minimum cost
    391402                        CastExpr *castExpr = new CastExpr( singleInit->get_value(), initContext->clone() );
    392403                        Expression *newExpr = findSingleExpression( castExpr, *this );
     
    410421                        }
    411422                } // if
    412 //      singleInit->get_value()->accept( *this );
    413423        }
    414424
Note: See TracChangeset for help on using the changeset viewer.