Changeset 46da46b for src/ResolvExpr/FindOpenVars.cc
- Timestamp:
- May 2, 2023, 3:44:31 AM (17 months ago)
- Branches:
- ast-experimental, master
- Children:
- 0c840fc
- Parents:
- 1ab773e0
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/FindOpenVars.cc
r1ab773e0 r46da46b 21 21 #include "AST/Pass.hpp" 22 22 #include "AST/Type.hpp" 23 #include "AST/TypeEnvironment.hpp" 23 24 #include "Common/PassVisitor.h" 24 25 #include "SynTree/Declaration.h" // for TypeDecl, DeclarationWithType (ptr ... 25 26 #include "SynTree/Type.h" // for Type, Type::ForallList, ArrayType 27 28 #include <iostream> 26 29 27 30 namespace ResolvExpr { … … 102 105 ast::AssertionSet & need; 103 106 ast::AssertionSet & have; 107 ast::TypeEnvironment & env; 104 108 bool nextIsOpen; 105 109 106 110 FindOpenVars_new( 107 111 ast::OpenVarSet & o, ast::OpenVarSet & c, ast::AssertionSet & n, 108 ast::AssertionSet & h, FirstMode firstIsOpen )109 : open( o ), closed( c ), need( n ), have( h ), nextIsOpen( firstIsOpen ) {}112 ast::AssertionSet & h, ast::TypeEnvironment & env, FirstMode firstIsOpen ) 113 : open( o ), closed( c ), need( n ), have( h ), env (env), nextIsOpen( firstIsOpen ) {} 110 114 111 115 void previsit( const ast::FunctionType * type ) { 112 116 // mark open/closed variables 113 117 if ( nextIsOpen ) { 118 // trying to remove this from resolver. 119 // occasionally used in other parts so not deleting right now. 120 121 // insert open variables unbound to environment. 122 env.add(type->forall); 123 114 124 for ( auto & decl : type->forall ) { 115 125 open[ *decl ] = ast::TypeData{ decl->base }; … … 137 147 void findOpenVars( 138 148 const ast::Type * type, ast::OpenVarSet & open, ast::OpenVarSet & closed, 139 ast::AssertionSet & need, ast::AssertionSet & have, FirstMode firstIsOpen ) {140 ast::Pass< FindOpenVars_new > finder{ open, closed, need, have, firstIsOpen };149 ast::AssertionSet & need, ast::AssertionSet & have, ast::TypeEnvironment & env, FirstMode firstIsOpen ) { 150 ast::Pass< FindOpenVars_new > finder{ open, closed, need, have, env, firstIsOpen }; 141 151 type->accept( finder ); 152 153 if (!closed.empty()) { 154 std::cerr << "closed: "; 155 for (auto& i : closed) { 156 std::cerr << i.first.base->location << ":" << i.first.base->name << ' '; 157 } 158 std::cerr << std::endl; 159 } 142 160 } 143 161 } // namespace ResolvExpr
Note: See TracChangeset
for help on using the changeset viewer.