<s> """<STR_LIT>""" <EOL> from . NodeBases import NodeBase , StatementChildrenHavingBase <EOL> def checkStatements ( value ) : <EOL> """<STR_LIT>""" <EOL> assert value is not None <EOL> assert None not in value <EOL> for statement in value : <EOL> assert statement . isStatement ( ) or statement . isStatementsFrame ( ) , statement . asXmlText ( ) <EOL> return tuple ( value ) <EOL> class StatementsSequence ( StatementChildrenHavingBase ) : <EOL> kind = "<STR_LIT>" <EOL> named_children = ( <EOL> "<STR_LIT>" , <EOL> ) <EOL> checkers = { <EOL> "<STR_LIT>" : checkStatements <EOL> } <EOL> def __init__ ( self , statements , source_ref ) : <EOL> StatementChildrenHavingBase . __init__ ( <EOL> self , <EOL> values = { <EOL> "<STR_LIT>" : statements <EOL> } , <EOL> source_ref = source_ref <EOL> ) <EOL> getStatements = StatementChildrenHavingBase . childGetter ( "<STR_LIT>" ) <EOL> setStatements = StatementChildrenHavingBase . childSetter ( "<STR_LIT>" ) <EOL> def getDetailsForDisplay ( self ) : <EOL> if self . getStatements ( ) : <EOL> return { <EOL> "<STR_LIT>" : len ( self . getStatements ( ) ) <EOL> } <EOL> else : <EOL> return { <EOL> "<STR_LIT>" : <NUM_LIT:0> <EOL> } <EOL> def isStatementsSequence ( self ) : <EOL> return True <EOL> def trimStatements ( self , statement ) : <EOL> assert statement . parent is self <EOL> old_statements = list ( self . getStatements ( ) ) <EOL> assert statement in old_statements , ( statement , self ) <EOL> new_statements = old_statements [ : old_statements . index ( statement ) + <NUM_LIT:1> ] <EOL> self . setChild ( "<STR_LIT>" , new_statements ) <EOL> def removeStatement ( self , statement ) : <EOL> assert statement . parent is self <EOL> statements = list ( self . getStatements ( ) ) <EOL> statements . remove ( statement ) <EOL> self . setChild ( "<STR_LIT>" , statements ) <EOL> def mergeStatementsSequence ( self , statement_sequence ) : <EOL> assert statement_sequence . parent is self <EOL> old_statements = list ( self . getStatements ( ) ) <EOL> assert statement_sequence in old_statements , ( statement_sequence , self ) <EOL> merge_index = old_statements . index ( statement_sequence ) <EOL> new_statements = tuple ( old_statements [ : merge_index ] ) + statement_sequence . getStatements ( ) + tuple ( old_statements [ merge_index + <NUM_LIT:1> : ] ) <EOL> self . setChild ( "<STR_LIT>" , new_statements ) <EOL> def mayHaveSideEffects ( self ) : <EOL> for statement in self . getStatements ( ) : <EOL> if statement . mayHaveSideEffects ( ) : <EOL> return True <EOL> return False <EOL> def mayRaiseException ( self , exception_type ) : <EOL> for statement in self . getStatements ( ) : <EOL> if statement . mayRaiseException ( exception_type ) : <EOL> return True <EOL> return False <EOL> def needsFrame ( self ) : <EOL> for statement in self . getStatements ( ) : <EOL> if statement . needsFrame ( ) : <EOL> return True <EOL> return False <EOL> def mayReturn ( self ) : <EOL> for statement in self . getStatements ( ) : <EOL> if statement . mayReturn ( ) : <EOL> return True <EOL> return False <EOL> def mayBreak ( self ) : <EOL> for statement in self . getStatements ( ) : <EOL> if statement . mayBreak ( ) : <EOL> return True <EOL> return False <EOL> def mayContinue ( self ) : <EOL> for statement in self . getStatements ( ) : <EOL> if statement . mayContinue ( ) : <EOL> return True <EOL> return False <EOL> def mayRaiseExceptionOrAbort ( self , exception_type ) : <EOL> return self . mayRaiseException ( exception_type ) or self . mayReturn ( ) or self . mayBreak ( ) or self . mayContinue ( ) <EOL> def isStatementAborting ( self ) : <EOL> return self . getStatements ( ) [ - <NUM_LIT:1> ] . isStatementAborting ( ) <EOL> def computeStatement ( self , constraint_collection ) : <EOL> assert False , self <EOL> def computeStatementsSequence ( self , constraint_collection ) : <EOL> new_statements = [ ] <EOL> statements = self . getStatements ( ) <EOL> assert statements , self <EOL> for count , statement in enumerate ( statements ) : <EOL> if statement . isStatementsFrame ( ) : <EOL> new_statement = statement . computeStatementsSequence ( <EOL> constraint_collection <EOL> ) <EOL> else : <EOL> new_statement = constraint_collection . onStatement ( <EOL> statement = statement <EOL> ) <EOL> if new_statement is not None : <EOL> if new_statement . isStatementsSequence ( ) and not new_statement . isStatementsFrame ( ) : <EOL> new_statements . extend ( <EOL> new_statement . getStatements ( ) <EOL> ) <EOL> else : <EOL> new_statements . append ( <EOL> new_statement <EOL> ) <EOL> if statement is not statements [ - <NUM_LIT:1> ] and new_statement . isStatementAborting ( ) : <EOL> constraint_collection . signalChange ( <EOL> "<STR_LIT>" , <EOL> statements [ count + <NUM_LIT:1> ] . getSourceReference ( ) , <EOL> "<STR_LIT>" <EOL> ) <EOL> break <EOL> if statements != new_statements : <EOL> if new_statements : <EOL> self . setStatements ( new_statements ) <EOL> return self <EOL> else : <EOL> return None <EOL> else : <EOL> return self <EOL> class StatementExpressionOnly ( StatementChildrenHavingBase ) : <EOL> kind = "<STR_LIT>" <EOL> named_children = ( <EOL> "<STR_LIT>" , <EOL> ) <EOL> def __init__ ( self , expression , source_ref ) : <EOL> assert expression . isExpression ( ) <EOL> StatementChildrenHavingBase . __init__ ( <EOL> self , <EOL> values = { <EOL> "<STR_LIT>" : expression <EOL> } , <EOL> source_ref = source_ref <EOL> ) <EOL> def getDetail ( self ) : <EOL> return "<STR_LIT>" % self . getExpression ( ) <EOL> def mayHaveSideEffects ( self ) : <EOL> return self . getExpression ( ) . mayHaveSideEffects ( ) <EOL> def mayRaiseException ( self , exception_type ) : <EOL> return self . getExpression ( ) . mayRaiseException ( exception_type ) <EOL> getExpression = StatementChildrenHavingBase . childGetter ( <EOL> "<STR_LIT>" <EOL> ) <EOL> def computeStatement ( self , constraint_collection ) : <EOL> constraint_collection . onExpression ( <EOL> expression = self . getExpression ( ) <EOL> ) <EOL> expression = self . getExpression ( ) <EOL> if expression . mayRaiseException ( BaseException ) : <EOL> constraint_collection . onExceptionRaiseExit ( BaseException ) <EOL> result , change_tags , change_desc = expression . computeExpressionDrop ( <EOL> statement = self , <EOL> constraint_collection = constraint_collection <EOL> ) <EOL> if result is not self : <EOL> return result , change_tags , change_desc <EOL> return self , None , None <EOL> class StatementGeneratorEntry ( NodeBase ) : <EOL> kind = "<STR_LIT>" <EOL> def __init__ ( self , source_ref ) : <EOL> NodeBase . __init__ ( <EOL> self , <EOL> source_ref = source_ref <EOL> ) <EOL> def mayRaiseException ( self , exception_type ) : <EOL> return True <EOL> def computeStatement ( self , constraint_collection ) : <EOL> constraint_collection . onExceptionRaiseExit ( BaseException ) <EOL> return self , None , None <EOL> class StatementPreserveFrameException ( NodeBase ) : <EOL> kind = "<STR_LIT>" <EOL> def __init__ ( self , preserver_id , source_ref ) : <EOL> NodeBase . __init__ ( <EOL> self , <EOL> source_ref = source_ref <EOL> ) <EOL> self . preserver_id = preserver_id <EOL> def getDetails ( self ) : <EOL> return { <EOL> "<STR_LIT>" : self . preserver_id <EOL> } <EOL> def getPreserverId ( self ) : <EOL> return self . preserver_id <EOL> def computeStatement ( self , constraint_collection ) : <EOL> if self . getParentStatementsFrame ( ) . needsExceptionFramePreservation ( ) : <EOL> return self , None , None <EOL> else : <EOL> return ( <EOL> None , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" <EOL> ) <EOL> def mayRaiseException ( self , exception_type ) : <EOL> return False <EOL> def needsFrame ( self ) : <EOL> return True <EOL> class StatementRestoreFrameException ( NodeBase ) : <EOL> kind = "<STR_LIT>" <EOL> def __init__ ( self , preserver_id , source_ref ) : <EOL> NodeBase . __init__ ( <EOL> self , <EOL> source_ref = source_ref <EOL> ) <EOL> self . preserver_id = preserver_id <EOL> def getDetails ( self ) : <EOL> return { <EOL> "<STR_LIT>" : self . preserver_id <EOL> } <EOL> def getPreserverId ( self ) : <EOL> return self . preserver_id <EOL> def computeStatement ( self , constraint_collection ) : <EOL> return self , None , None <EOL> def mayRaiseException ( self , exception_type ) : <EOL> return False <EOL> class StatementPublishException ( NodeBase ) : <EOL> kind = "<STR_LIT>" <EOL> def __init__ ( self , source_ref ) : <EOL> NodeBase . __init__ ( <EOL> self , <EOL> source_ref = source_ref <EOL> ) <EOL> def computeStatement ( self , constraint_collection ) : <EOL> return self , None , None <EOL> def mayRaiseException ( self , exception_type ) : <EOL> return False </s>
