Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Tuples/TupleAssignment.cc

    rf5854507 r5fb6830  
    1414//
    1515
    16 #include <algorithm>                       // for transform
    17 #include <cassert>                         // for assert
    18 #include <iterator>                        // for back_insert_iterator, back...
    19 #include <list>                            // for _List_const_iterator, _Lis...
    20 #include <memory>                          // for unique_ptr, allocator_trai...
    21 #include <string>                          // for string
    22 
     16#include "ResolvExpr/AlternativeFinder.h"
     17#include "ResolvExpr/Alternative.h"
     18#include "ResolvExpr/typeops.h"
     19#include "SynTree/Expression.h"
     20#include "SynTree/Initializer.h"
     21#include "Tuples.h"
     22#include "Explode.h"
     23#include "Common/SemanticError.h"
    2324#include "CodeGen/OperatorTable.h"
    24 #include "Common/UniqueName.h"             // for UniqueName
    25 #include "Common/utility.h"                // for zipWith
    26 #include "Explode.h"                       // for explode
    27 #include "InitTweak/GenInit.h"             // for genCtorInit
    28 #include "InitTweak/InitTweak.h"           // for getPointerBase, isAssignment
    29 #include "Parser/LinkageSpec.h"            // for Cforall
    30 #include "ResolvExpr/Alternative.h"        // for AltList, Alternative
    31 #include "ResolvExpr/AlternativeFinder.h"  // for AlternativeFinder, simpleC...
    32 #include "ResolvExpr/Cost.h"               // for Cost
    33 #include "ResolvExpr/Resolver.h"           // for resolveCtorInit
    34 #include "ResolvExpr/TypeEnvironment.h"    // for TypeEnvironment
    35 #include "SynTree/Declaration.h"           // for ObjectDecl
    36 #include "SynTree/Expression.h"            // for Expression, CastExpr, Name...
    37 #include "SynTree/Initializer.h"           // for ConstructorInit, SingleInit
    38 #include "SynTree/Statement.h"             // for ExprStmt
    39 #include "SynTree/Type.h"                  // for Type, Type::Qualifiers
    40 #include "SynTree/TypeSubstitution.h"      // for TypeSubstitution
    41 #include "SynTree/Visitor.h"               // for Visitor
    42 
    43 #if 0
    44 #define PRINT(x) x
    45 #else
    46 #define PRINT(x)
    47 #endif
     25#include "InitTweak/InitTweak.h"
     26#include "InitTweak/GenInit.h"
     27
     28#include <functional>
     29#include <algorithm>
     30#include <iterator>
     31#include <iostream>
     32#include <cassert>
     33#include <set>
     34#include <unordered_set>
    4835
    4936namespace Tuples {
     
    9077        bool isTuple( Expression *expr ) {
    9178                if ( ! expr ) return false;
    92                 assert( expr->result );
     79                assert( expr->has_result() );
    9380                return dynamic_cast< TupleType * >( expr->get_result()->stripReferences() );
    9481        }
     
    125112                if (  NameExpr *op = dynamic_cast< NameExpr * >(expr->get_function()) ) {
    126113                        if ( CodeGen::isCtorDtorAssign( op->get_name() ) ) {
    127                                fname = op->get_name();
    128                                 PRINT( std::cerr << "TupleAssignment: " << fname << std::endl; )
     114                                fname = op->get_name();
    129115                                for ( std::list<ResolvExpr::AltList>::const_iterator ali = possibilities.begin(); ali != possibilities.end(); ++ali ) {
    130116                                        if ( ali->size() == 0 ) continue; // AlternativeFinder will natrually handle this case, if it's legal
     
    138124                                        const ResolvExpr::Alternative & alt1 = ali->front();
    139125                                        auto begin = std::next(ali->begin(), 1), end = ali->end();
    140                                         PRINT( std::cerr << "alt1 is " << alt1.expr << std::endl; )
    141126                                        if ( refToTuple(alt1.expr) ) {
    142                                                 PRINT( std::cerr << "and is reference to tuple" << std::endl; )
    143127                                                if ( isMultAssign( begin, end ) ) {
    144                                                         PRINT( std::cerr << "possible multiple assignment" << std::endl; )
    145128                                                        matcher.reset( new MultipleAssignMatcher( *this, *ali ) );
    146129                                                } else {
    147130                                                        // mass assignment
    148                                                         PRINT( std::cerr << "possible mass assignment" << std::endl; )
    149131                                                        matcher.reset( new MassAssignMatcher( *this,  *ali ) );
    150132                                                }
     
    170152                // now resolve new assignments
    171153                for ( std::list< Expression * >::iterator i = new_assigns.begin(); i != new_assigns.end(); ++i ) {
    172                         PRINT(
    173                                 std::cerr << "== resolving tuple assign ==" << std::endl;
    174                                 std::cerr << *i << std::endl;
    175                         )
    176 
    177154                        ResolvExpr::AlternativeFinder finder( currentFinder.get_indexer(), currentFinder.get_environ() );
    178155                        try {
     
    254231
    255232        ObjectDecl * TupleAssignSpotter::Matcher::newObject( UniqueName & namer, Expression * expr ) {
    256                 assert( expr->result && ! expr->get_result()->isVoid() );
     233                assert( expr->has_result() && ! expr->get_result()->isVoid() );
    257234                ObjectDecl * ret = new ObjectDecl( namer.newName(), Type::StorageClasses(), LinkageSpec::Cforall, nullptr, expr->get_result()->clone(), new SingleInit( expr->clone() ) );
    258235                // if expression type is a reference, don't need to construct anything, a simple initializer is sufficient.
     
    264241                        ctorInit->accept( rm );
    265242                }
    266                 PRINT( std::cerr << "new object: " << ret << std::endl; )
    267243                return ret;
    268244        }
Note: See TracChangeset for help on using the changeset viewer.