Evaluate an expression stack, returning a boolean result. - stack - the stack - isSupported - function taking a version or extension name string and returning True or False if that name is supported or not.
(stack, isSupported)
| 196 | } |
| 197 | |
| 198 | def evaluateStack(stack, isSupported): |
| 199 | """Evaluate an expression stack, returning a boolean result. |
| 200 | |
| 201 | - stack - the stack |
| 202 | - isSupported - function taking a version or extension name string and |
| 203 | returning True or False if that name is supported or not.""" |
| 204 | |
| 205 | op, num_args = stack.pop(), 0 |
| 206 | if isinstance(op, tuple): |
| 207 | op, num_args = op |
| 208 | |
| 209 | if op in '+,': |
| 210 | # Note: operands are pushed onto the stack in reverse order |
| 211 | op2 = evaluateStack(stack, isSupported) |
| 212 | op1 = evaluateStack(stack, isSupported) |
| 213 | return _opn[op](op1, op2) |
| 214 | elif op[0].isalpha(): |
| 215 | return isSupported(op) |
| 216 | else: |
| 217 | raise Exception(f'invalid op: {op}') |
| 218 | |
| 219 | def evaluateDependency(dependency, isSupported): |
| 220 | """Evaluate a dependency expression, returning a boolean result. |
no outgoing calls
no test coverage detected