Changeset f229fc2 for src/ResolvExpr
- Timestamp:
- Apr 13, 2018, 12:25:33 PM (6 years ago)
- Branches:
- new-env, with_gc
- Children:
- b5aa3d8
- Parents:
- 09a1ae6
- Location:
- src/ResolvExpr
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/Alternative.cc
r09a1ae6 rf229fc2 20 20 #include <utility> // for move 21 21 22 #include "Common/GC.h" 23 #include "Common/PassVisitor.h" 22 24 #include "Common/utility.h" // for maybeClone 23 25 #include "ResolvExpr/Cost.h" // for Cost, Cost::zero, operator<< 24 26 #include "ResolvExpr/TypeEnvironment.h" // for TypeEnvironment 25 27 #include "SynTree/Expression.h" // for Expression 28 #include "SynTree/GcTracer.h" 26 29 #include "SynTree/Type.h" // for Type 27 30 … … 64 67 } 65 68 69 const GC& operator<< ( const GC& gc, const Alternative& alt ) { 70 PassVisitor<GcTracer> tracer{ gc }; 71 maybeAccept( alt.expr, tracer ); 72 tracer << alt.env; 73 return gc; 74 } 75 66 76 } // namespace ResolvExpr 67 77 -
src/ResolvExpr/Alternative.h
r09a1ae6 rf229fc2 23 23 24 24 class Expression; 25 26 class GC; 25 27 26 28 namespace ResolvExpr { … … 52 54 return os; 53 55 } 56 57 const GC& operator<< ( const GC&, const Alternative& ); 54 58 } // namespace ResolvExpr 55 59 -
src/ResolvExpr/Resolver.cc
r09a1ae6 rf229fc2 22 22 #include "Alternative.h" // for Alternative, AltList 23 23 #include "AlternativeFinder.h" // for AlternativeFinder, resolveIn... 24 #include "Common/GC.h" // for new_generation, collect_young 24 25 #include "Common/PassVisitor.h" // for PassVisitor 25 26 #include "Common/SemanticError.h" // for SemanticError … … 146 147 void findUnfinishedKindExpression(Expression * untyped, Alternative & alt, const SymTab::Indexer & indexer, const std::string & kindStr, std::function<bool(const Alternative &)> pred, bool adjust = false, bool prune = true, bool failFast = true) { 147 148 assertf( untyped, "expected a non-null expression." ); 149 150 new_generation(); // set up GC young generation for this top-level expression 151 148 152 TypeEnvironment env; 149 153 AlternativeFinder finder( indexer, env ); … … 173 177 findMinCost( candidates.begin(), candidates.end(), back_inserter( winners ) ); 174 178 if ( winners.size() == 0 ) { 175 SemanticError( untyped, toString( "No reasonable alternatives for ", kindStr, (kindStr != "" ? " " : ""), "expression: ") ); 179 collect_young(); 180 SemanticError( untyped, toString( 181 "No reasonable alternatives for ", kindStr, (kindStr != "" ? " " : ""), 182 "expression: ") ); 176 183 } else if ( winners.size() != 1 ) { 177 184 std::ostringstream stream; 178 stream << "Cannot choose between " << winners.size() << " alternatives for " << kindStr << (kindStr != "" ? " " : "") << "expression\n"; 185 stream << "Cannot choose between " << winners.size() << " alternatives for " 186 << kindStr << (kindStr != "" ? " " : "") << "expression\n"; 179 187 untyped->print( stream ); 180 188 stream << " Alternatives are:\n"; 181 189 printAlts( winners, stream, 1 ); 190 191 collect_young(); 182 192 SemanticError( untyped->location, stream.str() ); 183 193 } … … 186 196 Alternative & choice = winners.front(); 187 197 if ( findDeletedExpr( choice.expr ) ) { 188 SemanticError( choice.expr, "Unique best alternative includes deleted identifier in " ); 198 collect_young( choice.expr ); 199 SemanticError( choice.expr, 200 "Unique best alternative includes deleted identifier in " ); 189 201 } 190 202 alt = std::move( choice ); 203 collect_young( alt ); 191 204 } 192 205 -
src/ResolvExpr/TypeEnvironment.cc
r09a1ae6 rf229fc2 19 19 #include <utility> // for pair 20 20 21 #include "Common/PassVisitor.h" // for PassVisitor<GcTracer> 21 22 #include "Common/utility.h" // for maybeClone 23 #include "SynTree/GcTracer.h" // for PassVisitor<GcTracer> 22 24 #include "SynTree/Type.h" // for Type, FunctionType, Type::Fora... 23 25 #include "SynTree/TypeSubstitution.h" // for TypeSubstitution … … 222 224 return out; 223 225 } 226 227 PassVisitor<GcTracer> & operator<<( PassVisitor<GcTracer> & gc, const TypeEnvironment & env ) { 228 for ( const EqvClass & c : env ) { 229 maybeAccept( c.type, gc ); 230 } 231 return gc; 232 } 224 233 } // namespace ResolvExpr 225 234 -
src/ResolvExpr/TypeEnvironment.h
r09a1ae6 rf229fc2 26 26 #include "SynTree/Type.h" // for Type, Type::ForallList 27 27 #include "SynTree/TypeSubstitution.h" // for TypeSubstitution 28 29 template< typename Pass > 30 class PassVisitor; 31 class GcTracer; 28 32 29 33 namespace ResolvExpr { … … 116 120 117 121 std::ostream & operator<<( std::ostream & out, const TypeEnvironment & env ); 122 123 PassVisitor<GcTracer> & operator<<( PassVisitor<GcTracer> & gc, const TypeEnvironment & env ); 118 124 } // namespace ResolvExpr 119 125
Note: See TracChangeset
for help on using the changeset viewer.