[a32b204] | 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 | // |
---|
[71f4e4f] | 7 | // Resolver.cc -- |
---|
[a32b204] | 8 | // |
---|
| 9 | // Author : Richard C. Bilson |
---|
| 10 | // Created On : Sun May 17 12:17:01 2015 |
---|
[cbce272] | 11 | // Last Modified By : Andrew Beach |
---|
| 12 | // Last Modified On : Tus Aug 8 16:06:00 2017 |
---|
| 13 | // Update Count : 212 |
---|
[a32b204] | 14 | // |
---|
| 15 | |
---|
[ea6332d] | 16 | #include <stddef.h> // for NULL |
---|
[e3e16bc] | 17 | #include <cassert> // for strict_dynamic_cast, assert |
---|
[ea6332d] | 18 | #include <memory> // for allocator, allocator_traits<... |
---|
| 19 | #include <tuple> // for get |
---|
[bd4f2e9] | 20 | #include <vector> |
---|
[ea6332d] | 21 | |
---|
| 22 | #include "Alternative.h" // for Alternative, AltList |
---|
| 23 | #include "AlternativeFinder.h" // for AlternativeFinder, resolveIn... |
---|
[a4ca48c] | 24 | #include "Common/PassVisitor.h" // for PassVisitor |
---|
[ea6332d] | 25 | #include "Common/SemanticError.h" // for SemanticError |
---|
| 26 | #include "Common/utility.h" // for ValueGuard, group_iterate |
---|
| 27 | #include "CurrentObject.h" // for CurrentObject |
---|
[0a60c04] | 28 | #include "InitTweak/GenInit.h" |
---|
[ea6332d] | 29 | #include "InitTweak/InitTweak.h" // for isIntrinsicSingleArgCallStmt |
---|
| 30 | #include "RenameVars.h" // for RenameVars, global_renamer |
---|
| 31 | #include "ResolvExpr/TypeEnvironment.h" // for TypeEnvironment |
---|
| 32 | #include "ResolveTypeof.h" // for resolveTypeof |
---|
[e4d829b] | 33 | #include "Resolver.h" |
---|
[ea6332d] | 34 | #include "SymTab/Autogen.h" // for SizeType |
---|
| 35 | #include "SymTab/Indexer.h" // for Indexer |
---|
| 36 | #include "SynTree/Declaration.h" // for ObjectDecl, TypeDecl, Declar... |
---|
| 37 | #include "SynTree/Expression.h" // for Expression, CastExpr, InitExpr |
---|
| 38 | #include "SynTree/Initializer.h" // for ConstructorInit, SingleInit |
---|
| 39 | #include "SynTree/Statement.h" // for ForStmt, Statement, BranchStmt |
---|
| 40 | #include "SynTree/Type.h" // for Type, BasicType, PointerType |
---|
| 41 | #include "SynTree/TypeSubstitution.h" // for TypeSubstitution |
---|
| 42 | #include "SynTree/Visitor.h" // for acceptAll, maybeAccept |
---|
[0a60c04] | 43 | #include "Tuples/Tuples.h" |
---|
[ea6332d] | 44 | #include "typeops.h" // for extractResultType |
---|
[1dcd9554] | 45 | #include "Unify.h" // for unify |
---|
[51b7345] | 46 | |
---|
[d9a0e76] | 47 | using namespace std; |
---|
[51b7345] | 48 | |
---|
[d9a0e76] | 49 | namespace ResolvExpr { |
---|
[0a60c04] | 50 | struct Resolver final : public WithIndexer, public WithGuards, public WithVisitorRef<Resolver>, public WithShortCircuiting, public WithStmtsToAdd { |
---|
[a4ca48c] | 51 | Resolver() {} |
---|
| 52 | Resolver( const SymTab::Indexer & other ) { |
---|
| 53 | indexer = other; |
---|
[1d2b64f] | 54 | } |
---|
[71f4e4f] | 55 | |
---|
[a4ca48c] | 56 | void previsit( FunctionDecl *functionDecl ); |
---|
| 57 | void postvisit( FunctionDecl *functionDecl ); |
---|
[3c398b6] | 58 | void previsit( ObjectDecl *objectDecll ); |
---|
[a4ca48c] | 59 | void previsit( TypeDecl *typeDecl ); |
---|
| 60 | void previsit( EnumDecl * enumDecl ); |
---|
| 61 | |
---|
| 62 | void previsit( ArrayType * at ); |
---|
| 63 | void previsit( PointerType * at ); |
---|
| 64 | |
---|
| 65 | void previsit( ExprStmt *exprStmt ); |
---|
| 66 | void previsit( AsmExpr *asmExpr ); |
---|
| 67 | void previsit( AsmStmt *asmStmt ); |
---|
| 68 | void previsit( IfStmt *ifStmt ); |
---|
| 69 | void previsit( WhileStmt *whileStmt ); |
---|
| 70 | void previsit( ForStmt *forStmt ); |
---|
| 71 | void previsit( SwitchStmt *switchStmt ); |
---|
| 72 | void previsit( CaseStmt *caseStmt ); |
---|
| 73 | void previsit( BranchStmt *branchStmt ); |
---|
| 74 | void previsit( ReturnStmt *returnStmt ); |
---|
| 75 | void previsit( ThrowStmt *throwStmt ); |
---|
| 76 | void previsit( CatchStmt *catchStmt ); |
---|
[695e00d] | 77 | void previsit( WaitForStmt * stmt ); |
---|
[882ad37] | 78 | void previsit( WithStmt * withStmt ); |
---|
[a4ca48c] | 79 | |
---|
| 80 | void previsit( SingleInit *singleInit ); |
---|
| 81 | void previsit( ListInit *listInit ); |
---|
| 82 | void previsit( ConstructorInit *ctorInit ); |
---|
[a32b204] | 83 | private: |
---|
[c28a038d] | 84 | typedef std::list< Initializer * >::iterator InitIterator; |
---|
[94b4364] | 85 | |
---|
[40e636a] | 86 | template< typename PtrType > |
---|
| 87 | void handlePtrType( PtrType * type ); |
---|
| 88 | |
---|
[c28a038d] | 89 | void resolveWithExprs( std::list< Expression * > & withExprs, std::list< Statement * > & newStmts ); |
---|
| 90 | void fallbackInit( ConstructorInit * ctorInit ); |
---|
[b726084] | 91 | |
---|
[77971f6] | 92 | Type * functionReturn = nullptr; |
---|
[e4d829b] | 93 | CurrentObject currentObject = nullptr; |
---|
[a436947] | 94 | bool inEnumDecl = false; |
---|
[a32b204] | 95 | }; |
---|
[d9a0e76] | 96 | |
---|
[a32b204] | 97 | void resolve( std::list< Declaration * > translationUnit ) { |
---|
[a4ca48c] | 98 | PassVisitor<Resolver> resolver; |
---|
[a32b204] | 99 | acceptAll( translationUnit, resolver ); |
---|
[d9a0e76] | 100 | } |
---|
| 101 | |
---|
[8b11840] | 102 | void resolveDecl( Declaration * decl, const SymTab::Indexer &indexer ) { |
---|
| 103 | PassVisitor<Resolver> resolver( indexer ); |
---|
| 104 | maybeAccept( decl, resolver ); |
---|
| 105 | } |
---|
| 106 | |
---|
[a4ca48c] | 107 | // used in resolveTypeof |
---|
[a32b204] | 108 | Expression *resolveInVoidContext( Expression *expr, const SymTab::Indexer &indexer ) { |
---|
| 109 | TypeEnvironment env; |
---|
| 110 | return resolveInVoidContext( expr, indexer, env ); |
---|
[d9a0e76] | 111 | } |
---|
[a32b204] | 112 | |
---|
| 113 | namespace { |
---|
[7664fad] | 114 | void finishExpr( Expression *expr, const TypeEnvironment &env, TypeSubstitution * oldenv = nullptr ) { |
---|
| 115 | expr->env = oldenv ? oldenv->clone() : new TypeSubstitution; |
---|
[a32b204] | 116 | env.makeSubstitution( *expr->get_env() ); |
---|
| 117 | } |
---|
[0a22cda] | 118 | |
---|
| 119 | void removeExtraneousCast( Expression *& expr, const SymTab::Indexer & indexer ) { |
---|
| 120 | if ( CastExpr * castExpr = dynamic_cast< CastExpr * >( expr ) ) { |
---|
| 121 | if ( ResolvExpr::typesCompatible( castExpr->arg->result, castExpr->result, indexer ) ) { |
---|
| 122 | // cast is to the same type as its argument, so it's unnecessary -- remove it |
---|
| 123 | expr = castExpr->arg; |
---|
| 124 | castExpr->arg = nullptr; |
---|
| 125 | std::swap( expr->env, castExpr->env ); |
---|
| 126 | delete castExpr; |
---|
| 127 | } |
---|
| 128 | } |
---|
| 129 | } |
---|
[db4ecc5] | 130 | } // namespace |
---|
[a32b204] | 131 | |
---|
[08da53d] | 132 | void findVoidExpression( Expression *& untyped, const SymTab::Indexer &indexer ) { |
---|
[ad51cc2] | 133 | resetTyVarRenaming(); |
---|
[db4ecc5] | 134 | TypeEnvironment env; |
---|
| 135 | Expression *newExpr = resolveInVoidContext( untyped, indexer, env ); |
---|
[7664fad] | 136 | finishExpr( newExpr, env, untyped->env ); |
---|
[08da53d] | 137 | delete untyped; |
---|
| 138 | untyped = newExpr; |
---|
[db4ecc5] | 139 | } |
---|
[71f4e4f] | 140 | |
---|
[08da53d] | 141 | void findSingleExpression( Expression *&untyped, const SymTab::Indexer &indexer ) { |
---|
| 142 | if ( ! untyped ) return; |
---|
[8f98b78] | 143 | TypeEnvironment env; |
---|
| 144 | AlternativeFinder finder( indexer, env ); |
---|
| 145 | finder.find( untyped ); |
---|
| 146 | #if 0 |
---|
| 147 | if ( finder.get_alternatives().size() != 1 ) { |
---|
[7664fad] | 148 | std::cerr << "untyped expr is "; |
---|
| 149 | untyped->print( std::cerr ); |
---|
| 150 | std::cerr << std::endl << "alternatives are:"; |
---|
| 151 | for ( const Alternative & alt : finder.get_alternatives() ) { |
---|
| 152 | alt.print( std::cerr ); |
---|
[8f98b78] | 153 | } // for |
---|
| 154 | } // if |
---|
| 155 | #endif |
---|
[6138d0f] | 156 | assertf( finder.get_alternatives().size() == 1, "findSingleExpression: must have exactly one alternative at the end: (%zd) %s", finder.get_alternatives().size(), toString( untyped ).c_str() ); |
---|
[8f98b78] | 157 | Alternative &choice = finder.get_alternatives().front(); |
---|
| 158 | Expression *newExpr = choice.expr->clone(); |
---|
[7664fad] | 159 | finishExpr( newExpr, choice.env, untyped->env ); |
---|
[08da53d] | 160 | delete untyped; |
---|
| 161 | untyped = newExpr; |
---|
| 162 | } |
---|
| 163 | |
---|
| 164 | void findSingleExpression( Expression *& untyped, Type * type, const SymTab::Indexer & indexer ) { |
---|
| 165 | assert( untyped && type ); |
---|
| 166 | untyped = new CastExpr( untyped, type ); |
---|
| 167 | findSingleExpression( untyped, indexer ); |
---|
[0a22cda] | 168 | removeExtraneousCast( untyped, indexer ); |
---|
[8f98b78] | 169 | } |
---|
[d9a0e76] | 170 | |
---|
[8f98b78] | 171 | namespace { |
---|
[8587878e] | 172 | /// resolve `untyped` to the expression whose type satisfies `pred` with the lowest cost; kindStr is used for providing better error messages |
---|
| 173 | template<typename Pred> |
---|
| 174 | void findKindExpression(Expression *& untyped, const SymTab::Indexer & indexer, const std::string & kindStr, Pred pred) { |
---|
| 175 | TypeEnvironment env; |
---|
| 176 | AlternativeFinder finder( indexer, env ); |
---|
| 177 | finder.findWithAdjustment( untyped ); |
---|
| 178 | |
---|
| 179 | AltList candidates; |
---|
| 180 | for ( Alternative & alt : finder.get_alternatives() ) { |
---|
| 181 | if ( pred( alt.expr->result ) ) { |
---|
| 182 | candidates.push_back( std::move( alt ) ); |
---|
| 183 | } |
---|
| 184 | } |
---|
| 185 | |
---|
| 186 | // choose the lowest cost expression among the candidates |
---|
| 187 | AltList winners; |
---|
| 188 | findMinCost( candidates.begin(), candidates.end(), back_inserter( winners ) ); |
---|
| 189 | if ( winners.size() == 0 ) { |
---|
| 190 | throw SemanticError( "No reasonable alternatives for " + kindStr + " expression: ", untyped ); |
---|
| 191 | } else if ( winners.size() != 1 ) { |
---|
| 192 | std::ostringstream stream; |
---|
| 193 | stream << "Cannot choose between " << winners.size() << " alternatives for " + kindStr + " expression\n"; |
---|
| 194 | untyped->print( stream ); |
---|
| 195 | stream << "Alternatives are:\n"; |
---|
| 196 | printAlts( winners, stream, 1 ); |
---|
| 197 | throw SemanticError( stream.str() ); |
---|
| 198 | } |
---|
| 199 | |
---|
| 200 | // there is one unambiguous interpretation - move the expression into the with statement |
---|
| 201 | Alternative & alt = winners.front(); |
---|
| 202 | finishExpr( alt.expr, alt.env, untyped->env ); |
---|
| 203 | delete untyped; |
---|
| 204 | untyped = alt.expr; |
---|
| 205 | alt.expr = nullptr; |
---|
| 206 | } |
---|
| 207 | |
---|
[a32b204] | 208 | bool isIntegralType( Type *type ) { |
---|
| 209 | if ( dynamic_cast< EnumInstType * >( type ) ) { |
---|
| 210 | return true; |
---|
| 211 | } else if ( BasicType *bt = dynamic_cast< BasicType * >( type ) ) { |
---|
| 212 | return bt->isInteger(); |
---|
[89e6ffc] | 213 | } else if ( dynamic_cast< ZeroType* >( type ) != nullptr || dynamic_cast< OneType* >( type ) != nullptr ) { |
---|
| 214 | return true; |
---|
[a32b204] | 215 | } else { |
---|
| 216 | return false; |
---|
| 217 | } // if |
---|
| 218 | } |
---|
[71f4e4f] | 219 | |
---|
[08da53d] | 220 | void findIntegralExpression( Expression *& untyped, const SymTab::Indexer &indexer ) { |
---|
[8587878e] | 221 | findKindExpression( untyped, indexer, "condition", isIntegralType ); |
---|
[a32b204] | 222 | } |
---|
| 223 | } |
---|
[71f4e4f] | 224 | |
---|
[a4ca48c] | 225 | void Resolver::previsit( ObjectDecl *objectDecl ) { |
---|
| 226 | Type *new_type = resolveTypeof( objectDecl->get_type(), indexer ); |
---|
[a32b204] | 227 | objectDecl->set_type( new_type ); |
---|
[3cfe27f] | 228 | // To handle initialization of routine pointers, e.g., int (*fp)(int) = foo(), means that class-variable |
---|
| 229 | // initContext is changed multiple time because the LHS is analysed twice. The second analysis changes |
---|
| 230 | // initContext because of a function type can contain object declarations in the return and parameter types. So |
---|
| 231 | // each value of initContext is retained, so the type on the first analysis is preserved and used for selecting |
---|
| 232 | // the RHS. |
---|
[a4ca48c] | 233 | GuardValue( currentObject ); |
---|
[e4d829b] | 234 | currentObject = CurrentObject( objectDecl->get_type() ); |
---|
| 235 | if ( inEnumDecl && dynamic_cast< EnumInstType * >( objectDecl->get_type() ) ) { |
---|
[a436947] | 236 | // enumerator initializers should not use the enum type to initialize, since |
---|
| 237 | // the enum type is still incomplete at this point. Use signed int instead. |
---|
[e4d829b] | 238 | currentObject = CurrentObject( new BasicType( Type::Qualifiers(), BasicType::SignedInt ) ); |
---|
[a436947] | 239 | } |
---|
[bfbf97f] | 240 | } |
---|
| 241 | |
---|
[40e636a] | 242 | template< typename PtrType > |
---|
| 243 | void Resolver::handlePtrType( PtrType * type ) { |
---|
| 244 | if ( type->get_dimension() ) { |
---|
[08da53d] | 245 | findSingleExpression( type->dimension, SymTab::SizeType->clone(), indexer ); |
---|
[d1d17f5] | 246 | } |
---|
[40e636a] | 247 | } |
---|
| 248 | |
---|
[a4ca48c] | 249 | void Resolver::previsit( ArrayType * at ) { |
---|
[40e636a] | 250 | handlePtrType( at ); |
---|
[a32b204] | 251 | } |
---|
[94b4364] | 252 | |
---|
[a4ca48c] | 253 | void Resolver::previsit( PointerType * pt ) { |
---|
[40e636a] | 254 | handlePtrType( pt ); |
---|
| 255 | } |
---|
| 256 | |
---|
[a4ca48c] | 257 | void Resolver::previsit( TypeDecl *typeDecl ) { |
---|
[a32b204] | 258 | if ( typeDecl->get_base() ) { |
---|
[a4ca48c] | 259 | Type *new_type = resolveTypeof( typeDecl->get_base(), indexer ); |
---|
[a32b204] | 260 | typeDecl->set_base( new_type ); |
---|
| 261 | } // if |
---|
| 262 | } |
---|
[94b4364] | 263 | |
---|
[a4ca48c] | 264 | void Resolver::previsit( FunctionDecl *functionDecl ) { |
---|
[d9a0e76] | 265 | #if 0 |
---|
[a4ca48c] | 266 | std::cerr << "resolver visiting functiondecl "; |
---|
| 267 | functionDecl->print( std::cerr ); |
---|
| 268 | std::cerr << std::endl; |
---|
[d9a0e76] | 269 | #endif |
---|
[c28a038d] | 270 | Type *new_type = resolveTypeof( functionDecl->type, indexer ); |
---|
[a32b204] | 271 | functionDecl->set_type( new_type ); |
---|
[a4ca48c] | 272 | GuardValue( functionReturn ); |
---|
[60914351] | 273 | functionReturn = ResolvExpr::extractResultType( functionDecl->type ); |
---|
| 274 | |
---|
| 275 | { |
---|
| 276 | // resolve with-exprs with parameters in scope and add any newly generated declarations to the |
---|
| 277 | // front of the function body. |
---|
| 278 | auto guard = makeFuncGuard( [this]() { indexer.enterScope(); }, [this](){ indexer.leaveScope(); } ); |
---|
| 279 | indexer.addFunctionType( functionDecl->type ); |
---|
| 280 | std::list< Statement * > newStmts; |
---|
| 281 | resolveWithExprs( functionDecl->withExprs, newStmts ); |
---|
| 282 | functionDecl->statements->kids.splice( functionDecl->statements->kids.begin(), newStmts ); |
---|
| 283 | } |
---|
[a4ca48c] | 284 | } |
---|
[88d1066] | 285 | |
---|
[a4ca48c] | 286 | void Resolver::postvisit( FunctionDecl *functionDecl ) { |
---|
[88d1066] | 287 | // default value expressions have an environment which shouldn't be there and trips up later passes. |
---|
| 288 | // xxx - it might be necessary to somehow keep the information from this environment, but I can't currently |
---|
| 289 | // see how it's useful. |
---|
[c28a038d] | 290 | for ( Declaration * d : functionDecl->type->parameters ) { |
---|
[88d1066] | 291 | if ( ObjectDecl * obj = dynamic_cast< ObjectDecl * >( d ) ) { |
---|
[c28a038d] | 292 | if ( SingleInit * init = dynamic_cast< SingleInit * >( obj->init ) ) { |
---|
| 293 | delete init->value->env; |
---|
| 294 | init->value->env = nullptr; |
---|
[88d1066] | 295 | } |
---|
| 296 | } |
---|
| 297 | } |
---|
[a32b204] | 298 | } |
---|
[51b7345] | 299 | |
---|
[a4ca48c] | 300 | void Resolver::previsit( EnumDecl * ) { |
---|
[a436947] | 301 | // in case we decide to allow nested enums |
---|
[a4ca48c] | 302 | GuardValue( inEnumDecl ); |
---|
[a436947] | 303 | inEnumDecl = true; |
---|
| 304 | } |
---|
| 305 | |
---|
[a4ca48c] | 306 | void Resolver::previsit( ExprStmt *exprStmt ) { |
---|
| 307 | visit_children = false; |
---|
[08da53d] | 308 | assertf( exprStmt->expr, "ExprStmt has null Expression in resolver" ); |
---|
| 309 | findVoidExpression( exprStmt->expr, indexer ); |
---|
[a32b204] | 310 | } |
---|
[51b7345] | 311 | |
---|
[a4ca48c] | 312 | void Resolver::previsit( AsmExpr *asmExpr ) { |
---|
| 313 | visit_children = false; |
---|
[08da53d] | 314 | findVoidExpression( asmExpr->operand, indexer ); |
---|
[7f5566b] | 315 | if ( asmExpr->get_inout() ) { |
---|
[08da53d] | 316 | findVoidExpression( asmExpr->inout, indexer ); |
---|
[7f5566b] | 317 | } // if |
---|
| 318 | } |
---|
| 319 | |
---|
[a4ca48c] | 320 | void Resolver::previsit( AsmStmt *asmStmt ) { |
---|
| 321 | visit_children = false; |
---|
| 322 | acceptAll( asmStmt->get_input(), *visitor ); |
---|
| 323 | acceptAll( asmStmt->get_output(), *visitor ); |
---|
[7f5566b] | 324 | } |
---|
| 325 | |
---|
[a4ca48c] | 326 | void Resolver::previsit( IfStmt *ifStmt ) { |
---|
[8587878e] | 327 | findIntegralExpression( ifStmt->condition, indexer ); |
---|
[a32b204] | 328 | } |
---|
[51b7345] | 329 | |
---|
[a4ca48c] | 330 | void Resolver::previsit( WhileStmt *whileStmt ) { |
---|
[8587878e] | 331 | findIntegralExpression( whileStmt->condition, indexer ); |
---|
[a32b204] | 332 | } |
---|
[51b7345] | 333 | |
---|
[a4ca48c] | 334 | void Resolver::previsit( ForStmt *forStmt ) { |
---|
[08da53d] | 335 | if ( forStmt->condition ) { |
---|
[8587878e] | 336 | findIntegralExpression( forStmt->condition, indexer ); |
---|
[a32b204] | 337 | } // if |
---|
[71f4e4f] | 338 | |
---|
[08da53d] | 339 | if ( forStmt->increment ) { |
---|
| 340 | findVoidExpression( forStmt->increment, indexer ); |
---|
[a32b204] | 341 | } // if |
---|
| 342 | } |
---|
[51b7345] | 343 | |
---|
[a4ca48c] | 344 | void Resolver::previsit( SwitchStmt *switchStmt ) { |
---|
| 345 | GuardValue( currentObject ); |
---|
[08da53d] | 346 | findIntegralExpression( switchStmt->condition, indexer ); |
---|
[71f4e4f] | 347 | |
---|
[08da53d] | 348 | currentObject = CurrentObject( switchStmt->condition->result ); |
---|
[a32b204] | 349 | } |
---|
[51b7345] | 350 | |
---|
[a4ca48c] | 351 | void Resolver::previsit( CaseStmt *caseStmt ) { |
---|
[32b8144] | 352 | if ( caseStmt->get_condition() ) { |
---|
[e4d829b] | 353 | std::list< InitAlternative > initAlts = currentObject.getOptions(); |
---|
| 354 | assertf( initAlts.size() == 1, "SwitchStmt did not correctly resolve an integral expression." ); |
---|
[08da53d] | 355 | // must remove cast from case statement because RangeExpr cannot be cast. |
---|
| 356 | Expression * newExpr = new CastExpr( caseStmt->condition, initAlts.front().type->clone() ); |
---|
| 357 | findSingleExpression( newExpr, indexer ); |
---|
| 358 | CastExpr * castExpr = strict_dynamic_cast< CastExpr * >( newExpr ); |
---|
| 359 | caseStmt->condition = castExpr->arg; |
---|
| 360 | castExpr->arg = nullptr; |
---|
[32b8144] | 361 | delete castExpr; |
---|
| 362 | } |
---|
[a32b204] | 363 | } |
---|
[51b7345] | 364 | |
---|
[a4ca48c] | 365 | void Resolver::previsit( BranchStmt *branchStmt ) { |
---|
| 366 | visit_children = false; |
---|
[de62360d] | 367 | // must resolve the argument for a computed goto |
---|
| 368 | if ( branchStmt->get_type() == BranchStmt::Goto ) { // check for computed goto statement |
---|
[08da53d] | 369 | if ( branchStmt->computedTarget ) { |
---|
| 370 | // computed goto argument is void * |
---|
| 371 | findSingleExpression( branchStmt->computedTarget, new PointerType( Type::Qualifiers(), new VoidType( Type::Qualifiers() ) ), indexer ); |
---|
[de62360d] | 372 | } // if |
---|
| 373 | } // if |
---|
| 374 | } |
---|
| 375 | |
---|
[a4ca48c] | 376 | void Resolver::previsit( ReturnStmt *returnStmt ) { |
---|
| 377 | visit_children = false; |
---|
[08da53d] | 378 | if ( returnStmt->expr ) { |
---|
| 379 | findSingleExpression( returnStmt->expr, functionReturn->clone(), indexer ); |
---|
[a32b204] | 380 | } // if |
---|
| 381 | } |
---|
[51b7345] | 382 | |
---|
[a4ca48c] | 383 | void Resolver::previsit( ThrowStmt *throwStmt ) { |
---|
| 384 | visit_children = false; |
---|
[cbce272] | 385 | // TODO: Replace *exception type with &exception type. |
---|
[307a732] | 386 | if ( throwStmt->get_expr() ) { |
---|
[cbce272] | 387 | StructDecl * exception_decl = |
---|
[36982fc] | 388 | indexer.lookupStruct( "__cfaabi_ehm__base_exception_t" ); |
---|
[cbce272] | 389 | assert( exception_decl ); |
---|
[08da53d] | 390 | Type * exceptType = new PointerType( noQualifiers, new StructInstType( noQualifiers, exception_decl ) ); |
---|
| 391 | findSingleExpression( throwStmt->expr, exceptType, indexer ); |
---|
[307a732] | 392 | } |
---|
| 393 | } |
---|
| 394 | |
---|
[a4ca48c] | 395 | void Resolver::previsit( CatchStmt *catchStmt ) { |
---|
[08da53d] | 396 | if ( catchStmt->cond ) { |
---|
| 397 | findSingleExpression( catchStmt->cond, new BasicType( noQualifiers, BasicType::Bool ), indexer ); |
---|
[cbce272] | 398 | } |
---|
| 399 | } |
---|
| 400 | |
---|
[1dcd9554] | 401 | template< typename iterator_t > |
---|
| 402 | inline bool advance_to_mutex( iterator_t & it, const iterator_t & end ) { |
---|
| 403 | while( it != end && !(*it)->get_type()->get_mutex() ) { |
---|
| 404 | it++; |
---|
| 405 | } |
---|
| 406 | |
---|
| 407 | return it != end; |
---|
| 408 | } |
---|
| 409 | |
---|
[695e00d] | 410 | void Resolver::previsit( WaitForStmt * stmt ) { |
---|
[8f98b78] | 411 | visit_children = false; |
---|
[1dcd9554] | 412 | |
---|
| 413 | // Resolve all clauses first |
---|
| 414 | for( auto& clause : stmt->clauses ) { |
---|
| 415 | |
---|
| 416 | TypeEnvironment env; |
---|
[8f98b78] | 417 | AlternativeFinder funcFinder( indexer, env ); |
---|
[1dcd9554] | 418 | |
---|
| 419 | // Find all alternatives for a function in canonical form |
---|
| 420 | funcFinder.findWithAdjustment( clause.target.function ); |
---|
| 421 | |
---|
| 422 | if ( funcFinder.get_alternatives().empty() ) { |
---|
| 423 | stringstream ss; |
---|
| 424 | ss << "Use of undeclared indentifier '"; |
---|
| 425 | ss << strict_dynamic_cast<NameExpr*>( clause.target.function )->name; |
---|
| 426 | ss << "' in call to waitfor"; |
---|
| 427 | throw SemanticError( ss.str() ); |
---|
| 428 | } |
---|
| 429 | |
---|
| 430 | // Find all alternatives for all arguments in canonical form |
---|
[bd4f2e9] | 431 | std::vector< AlternativeFinder > argAlternatives; |
---|
[1dcd9554] | 432 | funcFinder.findSubExprs( clause.target.arguments.begin(), clause.target.arguments.end(), back_inserter( argAlternatives ) ); |
---|
| 433 | |
---|
| 434 | // List all combinations of arguments |
---|
[bd4f2e9] | 435 | std::vector< AltList > possibilities; |
---|
[1dcd9554] | 436 | combos( argAlternatives.begin(), argAlternatives.end(), back_inserter( possibilities ) ); |
---|
| 437 | |
---|
| 438 | AltList func_candidates; |
---|
| 439 | std::vector< AltList > args_candidates; |
---|
| 440 | |
---|
| 441 | // For every possible function : |
---|
| 442 | // try matching the arguments to the parameters |
---|
| 443 | // not the other way around because we have more arguments than parameters |
---|
| 444 | SemanticError errors; |
---|
| 445 | for ( Alternative & func : funcFinder.get_alternatives() ) { |
---|
| 446 | try { |
---|
| 447 | PointerType * pointer = dynamic_cast< PointerType* >( func.expr->get_result()->stripReferences() ); |
---|
| 448 | if( !pointer ) { |
---|
| 449 | throw SemanticError( "candidate not viable: not a pointer type\n", func.expr->get_result() ); |
---|
| 450 | } |
---|
| 451 | |
---|
| 452 | FunctionType * function = dynamic_cast< FunctionType* >( pointer->get_base() ); |
---|
| 453 | if( !function ) { |
---|
| 454 | throw SemanticError( "candidate not viable: not a function type\n", pointer->get_base() ); |
---|
| 455 | } |
---|
| 456 | |
---|
| 457 | |
---|
| 458 | { |
---|
| 459 | auto param = function->parameters.begin(); |
---|
| 460 | auto param_end = function->parameters.end(); |
---|
| 461 | |
---|
| 462 | if( !advance_to_mutex( param, param_end ) ) { |
---|
| 463 | throw SemanticError("candidate function not viable: no mutex parameters\n", function); |
---|
| 464 | } |
---|
| 465 | } |
---|
| 466 | |
---|
| 467 | Alternative newFunc( func ); |
---|
| 468 | // Strip reference from function |
---|
| 469 | referenceToRvalueConversion( newFunc.expr ); |
---|
| 470 | |
---|
| 471 | // For all the set of arguments we have try to match it with the parameter of the current function alternative |
---|
| 472 | for ( auto & argsList : possibilities ) { |
---|
| 473 | |
---|
| 474 | try { |
---|
| 475 | // Declare data structures need for resolution |
---|
| 476 | OpenVarSet openVars; |
---|
| 477 | AssertionSet resultNeed, resultHave; |
---|
| 478 | TypeEnvironment resultEnv; |
---|
| 479 | |
---|
| 480 | // Load type variables from arguemnts into one shared space |
---|
| 481 | simpleCombineEnvironments( argsList.begin(), argsList.end(), resultEnv ); |
---|
| 482 | |
---|
| 483 | // Make sure we don't widen any existing bindings |
---|
| 484 | for ( auto & i : resultEnv ) { |
---|
| 485 | i.allowWidening = false; |
---|
| 486 | } |
---|
| 487 | |
---|
| 488 | // Find any unbound type variables |
---|
| 489 | resultEnv.extractOpenVars( openVars ); |
---|
| 490 | |
---|
| 491 | auto param = function->parameters.begin(); |
---|
| 492 | auto param_end = function->parameters.end(); |
---|
| 493 | |
---|
| 494 | // For every arguments of its set, check if it matches one of the parameter |
---|
| 495 | // The order is important |
---|
| 496 | for( auto & arg : argsList ) { |
---|
| 497 | |
---|
| 498 | // Ignore non-mutex arguments |
---|
| 499 | if( !advance_to_mutex( param, param_end ) ) { |
---|
| 500 | // We ran out of parameters but still have arguments |
---|
| 501 | // this function doesn't match |
---|
| 502 | throw SemanticError("candidate function not viable: too many mutex arguments\n", function); |
---|
| 503 | } |
---|
| 504 | |
---|
| 505 | // Check if the argument matches the parameter type in the current scope |
---|
[8f98b78] | 506 | if( ! unify( (*param)->get_type(), arg.expr->get_result(), resultEnv, resultNeed, resultHave, openVars, this->indexer ) ) { |
---|
[1dcd9554] | 507 | // Type doesn't match |
---|
| 508 | stringstream ss; |
---|
| 509 | ss << "candidate function not viable: no known convertion from '"; |
---|
| 510 | arg.expr->get_result()->print( ss ); |
---|
| 511 | ss << "' to '"; |
---|
| 512 | (*param)->get_type()->print( ss ); |
---|
| 513 | ss << "'\n"; |
---|
| 514 | throw SemanticError(ss.str(), function); |
---|
| 515 | } |
---|
| 516 | |
---|
| 517 | param++; |
---|
| 518 | } |
---|
| 519 | |
---|
| 520 | // All arguments match ! |
---|
| 521 | |
---|
| 522 | // Check if parameters are missing |
---|
| 523 | if( advance_to_mutex( param, param_end ) ) { |
---|
| 524 | // We ran out of arguments but still have parameters left |
---|
| 525 | // this function doesn't match |
---|
| 526 | throw SemanticError("candidate function not viable: too few mutex arguments\n", function); |
---|
| 527 | } |
---|
| 528 | |
---|
| 529 | // All parameters match ! |
---|
| 530 | |
---|
| 531 | // Finish the expressions to tie in the proper environments |
---|
| 532 | finishExpr( newFunc.expr, resultEnv ); |
---|
| 533 | for( Alternative & alt : argsList ) { |
---|
| 534 | finishExpr( alt.expr, resultEnv ); |
---|
| 535 | } |
---|
| 536 | |
---|
| 537 | // This is a match store it and save it for later |
---|
| 538 | func_candidates.push_back( newFunc ); |
---|
| 539 | args_candidates.push_back( argsList ); |
---|
| 540 | |
---|
| 541 | } |
---|
| 542 | catch( SemanticError &e ) { |
---|
| 543 | errors.append( e ); |
---|
| 544 | } |
---|
| 545 | } |
---|
| 546 | } |
---|
| 547 | catch( SemanticError &e ) { |
---|
| 548 | errors.append( e ); |
---|
| 549 | } |
---|
| 550 | } |
---|
| 551 | |
---|
| 552 | // Make sure we got the right number of arguments |
---|
| 553 | if( func_candidates.empty() ) { SemanticError top( "No alternatives for function in call to waitfor" ); top.append( errors ); throw top; } |
---|
| 554 | if( args_candidates.empty() ) { SemanticError top( "No alternatives for arguments in call to waitfor" ); top.append( errors ); throw top; } |
---|
| 555 | if( func_candidates.size() > 1 ) { SemanticError top( "Ambiguous function in call to waitfor" ); top.append( errors ); throw top; } |
---|
| 556 | if( args_candidates.size() > 1 ) { SemanticError top( "Ambiguous arguments in call to waitfor" ); top.append( errors ); throw top; } |
---|
| 557 | |
---|
| 558 | |
---|
| 559 | // Swap the results from the alternative with the unresolved values. |
---|
| 560 | // Alternatives will handle deletion on destruction |
---|
| 561 | std::swap( clause.target.function, func_candidates.front().expr ); |
---|
| 562 | for( auto arg_pair : group_iterate( clause.target.arguments, args_candidates.front() ) ) { |
---|
| 563 | std::swap ( std::get<0>( arg_pair), std::get<1>( arg_pair).expr ); |
---|
| 564 | } |
---|
| 565 | |
---|
| 566 | // Resolve the conditions as if it were an IfStmt |
---|
| 567 | // Resolve the statments normally |
---|
[08da53d] | 568 | findSingleExpression( clause.condition, this->indexer ); |
---|
[8f98b78] | 569 | clause.statement->accept( *visitor ); |
---|
[1dcd9554] | 570 | } |
---|
| 571 | |
---|
| 572 | |
---|
| 573 | if( stmt->timeout.statement ) { |
---|
| 574 | // Resolve the timeout as an size_t for now |
---|
| 575 | // Resolve the conditions as if it were an IfStmt |
---|
| 576 | // Resolve the statments normally |
---|
[08da53d] | 577 | findSingleExpression( stmt->timeout.time, new BasicType( noQualifiers, BasicType::LongLongUnsignedInt ), this->indexer ); |
---|
| 578 | findSingleExpression( stmt->timeout.condition, this->indexer ); |
---|
[8f98b78] | 579 | stmt->timeout.statement->accept( *visitor ); |
---|
[1dcd9554] | 580 | } |
---|
| 581 | |
---|
| 582 | if( stmt->orelse.statement ) { |
---|
| 583 | // Resolve the conditions as if it were an IfStmt |
---|
| 584 | // Resolve the statments normally |
---|
[08da53d] | 585 | findSingleExpression( stmt->orelse.condition, this->indexer ); |
---|
[8f98b78] | 586 | stmt->orelse.statement->accept( *visitor ); |
---|
[1dcd9554] | 587 | } |
---|
| 588 | } |
---|
| 589 | |
---|
[882ad37] | 590 | bool isStructOrUnion( Type * t ) { |
---|
| 591 | t = t->stripReferences(); |
---|
| 592 | return dynamic_cast< StructInstType * >( t ) || dynamic_cast< UnionInstType * >( t ); |
---|
| 593 | } |
---|
| 594 | |
---|
[c28a038d] | 595 | void Resolver::resolveWithExprs( std::list< Expression * > & withExprs, std::list< Statement * > & newStmts ) { |
---|
| 596 | for ( Expression *& expr : withExprs ) { |
---|
[882ad37] | 597 | // only struct- and union-typed expressions are viable candidates |
---|
[8587878e] | 598 | findKindExpression( expr, indexer, "with statement", isStructOrUnion ); |
---|
[0a60c04] | 599 | |
---|
| 600 | // if with expression might be impure, create a temporary so that it is evaluated once |
---|
| 601 | if ( Tuples::maybeImpure( expr ) ) { |
---|
| 602 | static UniqueName tmpNamer( "_with_tmp_" ); |
---|
| 603 | ObjectDecl * tmp = ObjectDecl::newObject( tmpNamer.newName(), expr->result->clone(), new SingleInit( expr ) ); |
---|
| 604 | expr = new VariableExpr( tmp ); |
---|
[c28a038d] | 605 | newStmts.push_back( new DeclStmt( tmp ) ); |
---|
[0a60c04] | 606 | if ( InitTweak::isConstructable( tmp->type ) ) { |
---|
| 607 | // generate ctor/dtor and resolve them |
---|
| 608 | tmp->init = InitTweak::genCtorInit( tmp ); |
---|
| 609 | tmp->accept( *visitor ); |
---|
| 610 | } |
---|
| 611 | } |
---|
[882ad37] | 612 | } |
---|
| 613 | } |
---|
| 614 | |
---|
[c28a038d] | 615 | void Resolver::previsit( WithStmt * withStmt ) { |
---|
| 616 | resolveWithExprs( withStmt->exprs, stmtsToAddBefore ); |
---|
| 617 | } |
---|
| 618 | |
---|
[b5c5684] | 619 | template< typename T > |
---|
| 620 | bool isCharType( T t ) { |
---|
| 621 | if ( BasicType * bt = dynamic_cast< BasicType * >( t ) ) { |
---|
[71f4e4f] | 622 | return bt->get_kind() == BasicType::Char || bt->get_kind() == BasicType::SignedChar || |
---|
[b5c5684] | 623 | bt->get_kind() == BasicType::UnsignedChar; |
---|
| 624 | } |
---|
| 625 | return false; |
---|
| 626 | } |
---|
| 627 | |
---|
[a4ca48c] | 628 | void Resolver::previsit( SingleInit *singleInit ) { |
---|
| 629 | visit_children = false; |
---|
[62423350] | 630 | // resolve initialization using the possibilities as determined by the currentObject cursor |
---|
[0a22cda] | 631 | Expression * newExpr = new UntypedInitExpr( singleInit->value, currentObject.getOptions() ); |
---|
[08da53d] | 632 | findSingleExpression( newExpr, indexer ); |
---|
[e3e16bc] | 633 | InitExpr * initExpr = strict_dynamic_cast< InitExpr * >( newExpr ); |
---|
[62423350] | 634 | |
---|
| 635 | // move cursor to the object that is actually initialized |
---|
[e4d829b] | 636 | currentObject.setNext( initExpr->get_designation() ); |
---|
[62423350] | 637 | |
---|
| 638 | // discard InitExpr wrapper and retain relevant pieces |
---|
[08da53d] | 639 | newExpr = initExpr->expr; |
---|
| 640 | initExpr->expr = nullptr; |
---|
| 641 | std::swap( initExpr->env, newExpr->env ); |
---|
[bb666f64] | 642 | std::swap( initExpr->inferParams, newExpr->inferParams ) ; |
---|
[e4d829b] | 643 | delete initExpr; |
---|
| 644 | |
---|
[62423350] | 645 | // get the actual object's type (may not exactly match what comes back from the resolver due to conversions) |
---|
| 646 | Type * initContext = currentObject.getCurrentType(); |
---|
| 647 | |
---|
[0a22cda] | 648 | removeExtraneousCast( newExpr, indexer ); |
---|
| 649 | |
---|
[62423350] | 650 | // check if actual object's type is char[] |
---|
| 651 | if ( ArrayType * at = dynamic_cast< ArrayType * >( initContext ) ) { |
---|
| 652 | if ( isCharType( at->get_base() ) ) { |
---|
| 653 | // check if the resolved type is char * |
---|
| 654 | if ( PointerType * pt = dynamic_cast< PointerType *>( newExpr->get_result() ) ) { |
---|
| 655 | if ( isCharType( pt->get_base() ) ) { |
---|
[0a22cda] | 656 | if ( CastExpr *ce = dynamic_cast< CastExpr * >( newExpr ) ) { |
---|
| 657 | // strip cast if we're initializing a char[] with a char *, e.g. char x[] = "hello"; |
---|
| 658 | newExpr = ce->get_arg(); |
---|
| 659 | ce->set_arg( nullptr ); |
---|
| 660 | std::swap( ce->env, newExpr->env ); |
---|
| 661 | delete ce; |
---|
| 662 | } |
---|
[62423350] | 663 | } |
---|
| 664 | } |
---|
| 665 | } |
---|
| 666 | } |
---|
[94b4364] | 667 | |
---|
[62423350] | 668 | // set initializer expr to resolved express |
---|
[0a22cda] | 669 | singleInit->value = newExpr; |
---|
[62423350] | 670 | |
---|
| 671 | // move cursor to next object in preparation for next initializer |
---|
| 672 | currentObject.increment(); |
---|
| 673 | } |
---|
[94b4364] | 674 | |
---|
[a4ca48c] | 675 | void Resolver::previsit( ListInit * listInit ) { |
---|
| 676 | visit_children = false; |
---|
[62423350] | 677 | // move cursor into brace-enclosed initializer-list |
---|
[e4d829b] | 678 | currentObject.enterListInit(); |
---|
| 679 | // xxx - fix this so that the list isn't copied, iterator should be used to change current element |
---|
| 680 | std::list<Designation *> newDesignations; |
---|
| 681 | for ( auto p : group_iterate(listInit->get_designations(), listInit->get_initializers()) ) { |
---|
[62423350] | 682 | // iterate designations and initializers in pairs, moving the cursor to the current designated object and resolving |
---|
| 683 | // the initializer against that object. |
---|
[e4d829b] | 684 | Designation * des = std::get<0>(p); |
---|
| 685 | Initializer * init = std::get<1>(p); |
---|
| 686 | newDesignations.push_back( currentObject.findNext( des ) ); |
---|
[a4ca48c] | 687 | init->accept( *visitor ); |
---|
[b5c5684] | 688 | } |
---|
[62423350] | 689 | // set the set of 'resolved' designations and leave the brace-enclosed initializer-list |
---|
[e4d829b] | 690 | listInit->get_designations() = newDesignations; // xxx - memory management |
---|
| 691 | currentObject.exitListInit(); |
---|
| 692 | |
---|
[62423350] | 693 | // xxx - this part has not be folded into CurrentObject yet |
---|
[e4d829b] | 694 | // } else if ( TypeInstType * tt = dynamic_cast< TypeInstType * >( initContext ) ) { |
---|
| 695 | // Type * base = tt->get_baseType()->get_base(); |
---|
| 696 | // if ( base ) { |
---|
| 697 | // // know the implementation type, so try using that as the initContext |
---|
| 698 | // ObjectDecl tmpObj( "", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, base->clone(), nullptr ); |
---|
| 699 | // currentObject = &tmpObj; |
---|
| 700 | // visit( listInit ); |
---|
| 701 | // } else { |
---|
| 702 | // // missing implementation type -- might be an unknown type variable, so try proceeding with the current init context |
---|
| 703 | // Parent::visit( listInit ); |
---|
| 704 | // } |
---|
| 705 | // } else { |
---|
[a32b204] | 706 | } |
---|
[71f4e4f] | 707 | |
---|
[f1e012b] | 708 | // ConstructorInit - fall back on C-style initializer |
---|
| 709 | void Resolver::fallbackInit( ConstructorInit * ctorInit ) { |
---|
| 710 | // could not find valid constructor, or found an intrinsic constructor |
---|
| 711 | // fall back on C-style initializer |
---|
| 712 | delete ctorInit->get_ctor(); |
---|
| 713 | ctorInit->set_ctor( NULL ); |
---|
[71a145de] | 714 | delete ctorInit->get_dtor(); |
---|
| 715 | ctorInit->set_dtor( NULL ); |
---|
[a4ca48c] | 716 | maybeAccept( ctorInit->get_init(), *visitor ); |
---|
[f1e012b] | 717 | } |
---|
| 718 | |
---|
[1d2b64f] | 719 | // needs to be callable from outside the resolver, so this is a standalone function |
---|
| 720 | void resolveCtorInit( ConstructorInit * ctorInit, const SymTab::Indexer & indexer ) { |
---|
| 721 | assert( ctorInit ); |
---|
[a4ca48c] | 722 | PassVisitor<Resolver> resolver( indexer ); |
---|
[1d2b64f] | 723 | ctorInit->accept( resolver ); |
---|
| 724 | } |
---|
| 725 | |
---|
| 726 | void resolveStmtExpr( StmtExpr * stmtExpr, const SymTab::Indexer & indexer ) { |
---|
| 727 | assert( stmtExpr ); |
---|
[a4ca48c] | 728 | PassVisitor<Resolver> resolver( indexer ); |
---|
[1d2b64f] | 729 | stmtExpr->accept( resolver ); |
---|
[5e2c348] | 730 | stmtExpr->computeResult(); |
---|
[1d2b64f] | 731 | } |
---|
| 732 | |
---|
[a4ca48c] | 733 | void Resolver::previsit( ConstructorInit *ctorInit ) { |
---|
| 734 | visit_children = false; |
---|
[1ba88a0] | 735 | // xxx - fallback init has been removed => remove fallbackInit function and remove complexity from FixInit and remove C-init from ConstructorInit |
---|
[a4ca48c] | 736 | maybeAccept( ctorInit->get_ctor(), *visitor ); |
---|
| 737 | maybeAccept( ctorInit->get_dtor(), *visitor ); |
---|
[071a31a] | 738 | |
---|
[5b2f5bb] | 739 | // found a constructor - can get rid of C-style initializer |
---|
| 740 | delete ctorInit->get_init(); |
---|
| 741 | ctorInit->set_init( NULL ); |
---|
[ec79847] | 742 | |
---|
| 743 | // intrinsic single parameter constructors and destructors do nothing. Since this was |
---|
| 744 | // implicitly generated, there's no way for it to have side effects, so get rid of it |
---|
| 745 | // to clean up generated code. |
---|
[f9cebb5] | 746 | if ( InitTweak::isIntrinsicSingleArgCallStmt( ctorInit->get_ctor() ) ) { |
---|
[ec79847] | 747 | delete ctorInit->get_ctor(); |
---|
| 748 | ctorInit->set_ctor( NULL ); |
---|
| 749 | } |
---|
[f9cebb5] | 750 | |
---|
| 751 | if ( InitTweak::isIntrinsicSingleArgCallStmt( ctorInit->get_dtor() ) ) { |
---|
[ec79847] | 752 | delete ctorInit->get_dtor(); |
---|
| 753 | ctorInit->set_dtor( NULL ); |
---|
| 754 | } |
---|
[a465caf] | 755 | |
---|
| 756 | // xxx - todo -- what about arrays? |
---|
| 757 | // if ( dtor == NULL && InitTweak::isIntrinsicCallStmt( ctorInit->get_ctor() ) ) { |
---|
| 758 | // // can reduce the constructor down to a SingleInit using the |
---|
| 759 | // // second argument from the ctor call, since |
---|
| 760 | // delete ctorInit->get_ctor(); |
---|
| 761 | // ctorInit->set_ctor( NULL ); |
---|
| 762 | |
---|
| 763 | // Expression * arg = |
---|
| 764 | // ctorInit->set_init( new SingleInit( arg ) ); |
---|
| 765 | // } |
---|
[71f4e4f] | 766 | } |
---|
[51b7345] | 767 | } // namespace ResolvExpr |
---|
[a32b204] | 768 | |
---|
| 769 | // Local Variables: // |
---|
| 770 | // tab-width: 4 // |
---|
| 771 | // mode: c++ // |
---|
| 772 | // compile-command: "make install" // |
---|
| 773 | // End: // |
---|