Implemented RangedLayer for determining ranges for layer compilation.

In order to do layer compilation into a single loop, we need to know the
range over which each layer will be evaluated, so that we can minimize
the amount of compuation we have to do at runtime.