def add_declaration_to_update_block(declaration: ASTDeclaration, neuron: ASTNeuron) -> ASTNeuron: """ Adds a single declaration to the end of the update block of the handed over neuron. :param declaration: ASTDeclaration node to add :param neuron: a single neuron instance :return: a modified neuron """ small_stmt = ASTNodeFactory.create_ast_small_stmt(declaration=declaration, source_position=ASTSourceLocation.get_added_source_position()) stmt = ASTNodeFactory.create_ast_stmt(small_stmt=small_stmt, source_position=ASTSourceLocation.get_added_source_position()) if not neuron.get_update_blocks(): neuron.create_empty_update_block() neuron.get_update_blocks().get_block().get_stmts().append(stmt) small_stmt.update_scope(neuron.get_update_blocks().get_block().get_scope()) stmt.update_scope(neuron.get_update_blocks().get_block().get_scope()) return neuron
def add_assignment_to_update_block(assignment: ASTAssignment, neuron: ASTNeuron) -> ASTNeuron: """ Adds a single assignment to the end of the update block of the handed over neuron. :param assignment: a single assignment :param neuron: a single neuron instance :return: the modified neuron """ small_stmt = ASTNodeFactory.create_ast_small_stmt(assignment=assignment, source_position=ASTSourceLocation.get_added_source_position()) stmt = ASTNodeFactory.create_ast_stmt(small_stmt=small_stmt, source_position=ASTSourceLocation.get_added_source_position()) if not neuron.get_update_blocks(): neuron.create_empty_update_block() neuron.get_update_blocks().get_block().get_stmts().append(stmt) small_stmt.update_scope(neuron.get_update_blocks().get_block().get_scope()) stmt.update_scope(neuron.get_update_blocks().get_block().get_scope()) return neuron