search: propagate and simplify expressions dependent on global mode
Created by: rvantonder
Stacked on https://github.com/sourcegraph/sourcegraph/pull/26625.
This basically does what a compiler would and reduces an expression to a value that we can compute up front and then propagates that value instead of retesting expressions. In the context of what this achieves, see the next PR: https://github.com/sourcegraph/sourcegraph/pull/26629