| 728 | |
| 729 | |
| 730 | class CaptureContext: |
| 731 | def __init__(self, type, childset): |
| 732 | self.type = type |
| 733 | self.blocks = {childset: []} |
| 734 | self.childset = childset |
| 735 | |
| 736 | def startChildSet(self, childset): |
| 737 | self.childset = childset |
| 738 | if childset not in self.blocks: |
| 739 | self.blocks[childset] = [] |
| 740 | |
| 741 | def addStatementResult(self, type, data, sideEffects): |
| 742 | res = {"data": data} |
| 743 | if type: |
| 744 | res["type"] = type |
| 745 | if sideEffects: |
| 746 | res["sideEffects"] = sideEffects |
| 747 | self.blocks[self.childset].append(res) |
| 748 | |
| 749 | def addExceptionResult(self, exceptionType, message, inFunction=None): |
| 750 | exception_details = { |
| 751 | "type": "EXCEPTION", |
| 752 | "exceptionType": exceptionType, |
| 753 | "exceptionMessage": message, |
| 754 | } |
| 755 | if inFunction: |
| 756 | exception_details["exceptionInFunction"] = inFunction |
| 757 | self.blocks[self.childset].append(exception_details) |
| 758 | |
| 759 | def checkFrameLimit(self): |
| 760 | if iterationLimit and len(self.blocks[self.childset]) > iterationLimit: |
| 761 | raise Exception('Too many iterations.') |
| 762 | |
| 763 | def toDict(self): |
| 764 | return { |
| 765 | "type": self.type, |
| 766 | "data": self.blocks, |
| 767 | } |
| 768 | |
| 769 | |
| 770 | class FunctionFrame: |
no outgoing calls
no test coverage detected