(self: Instruction)
| 882 | } |
| 883 | |
| 884 | const getMaxSizeInternal = (self: Instruction): number => { |
| 885 | switch (self._tag) { |
| 886 | case "Empty": { |
| 887 | return 0 |
| 888 | } |
| 889 | case "Single": { |
| 890 | return 1 |
| 891 | } |
| 892 | case "KeyValueMap": { |
| 893 | return Number.MAX_SAFE_INTEGER |
| 894 | } |
| 895 | case "Map": |
| 896 | case "WithDefault": |
| 897 | case "WithFallback": { |
| 898 | return getMaxSizeInternal(self.options as Instruction) |
| 899 | } |
| 900 | case "Both": { |
| 901 | const leftMaxSize = getMaxSizeInternal(self.left as Instruction) |
| 902 | const rightMaxSize = getMaxSizeInternal(self.right as Instruction) |
| 903 | return leftMaxSize + rightMaxSize |
| 904 | } |
| 905 | case "OrElse": { |
| 906 | const leftMin = getMaxSizeInternal(self.left as Instruction) |
| 907 | const rightMin = getMaxSizeInternal(self.right as Instruction) |
| 908 | return Math.min(leftMin, rightMin) |
| 909 | } |
| 910 | case "Variadic": { |
| 911 | const selfMaxSize = Option.getOrElse(self.max, () => Number.MAX_SAFE_INTEGER / 2) |
| 912 | const optionsMaxSize = getMaxSizeInternal(self.argumentOption as Instruction) |
| 913 | return Math.floor(selfMaxSize * optionsMaxSize) |
| 914 | } |
| 915 | } |
| 916 | } |
| 917 | |
| 918 | const getUsageInternal = (self: Instruction): Usage.Usage => { |
| 919 | switch (self._tag) { |
no outgoing calls
no test coverage detected