<s> from collect_vars import collect_var_names , collect_var_names_from_exprs <EOL> from escape_analysis import escape_analysis <EOL> from syntax_visitor import SyntaxVisitor <EOL> class ArrayWriteAnalysis ( SyntaxVisitor ) : <EOL> def __init__ ( self , fn , fresh_alloc_args = set ( [ ] ) ) : <EOL> self . fn = fn <EOL> self . fresh_alloc_args = fresh_alloc_args <EOL> def visit_fn ( self , fn ) : <EOL> escape_info = escape_analysis ( fn , self . fresh_alloc_args ) <EOL> self . may_alias = escape_info . may_alias <EOL> SyntaxVisitor . visit_fn ( self , fn ) <EOL> self . writes = set ( [ ] ) <EOL> def visit_Assign ( self , stmt ) : <EOL> if stmt . lhs . __class__ is Tuple : <EOL> for elt in stmt . lhs . elts : <EOL> self . visit_Assign ( elt ) <EOL> elif stmt . lhs . __class__ is Index : <EOL> for name in collect_var_names ( stmt . lhs . value ) : <EOL> self . writes . append ( name ) <EOL> for alias_name in self . may_alias [ name ] : <EOL> self . writes . append ( alias_name ) <EOL> def visit_Index ( self ) : <EOL> pass </s>
