| import threading |
| from contextlib import contextmanager |
| from typing import Iterator |
| |
| # Simple dynamic scoping implementation. The name "parametrize" comes |
| # from Racket. |
| # |
| # WARNING WARNING: LOOKING TO EDIT THIS FILE? Think carefully about |
| # why you need to add a toggle to the global behavior of code |
| # generation. The parameters here should really only be used |
| # for "temporary" situations, where we need to temporarily change |
| # the codegen in some cases because we cannot conveniently update |
| # all call sites, and are slated to be eliminated once all call |
| # sites are eliminated. If you don't have a plan for how to get there, |
| # DON'T add a new entry here. |
| |
| class Locals(threading.local): |
| pass |
| |
| _locals = Locals() |
| |
| @contextmanager |
| def parametrize() -> Iterator[None]: |
| yield |