Faster context lookups

 * Replace is_object/is_array with switch on gettype — When checking multiple types, this is ~10% slower in the worst case, and ~30-33% faster for the average and best case.
 * Use a reference to the current stack frame to avoid calling `$stack[$i]` too many times — this is ~6% faster for most cases, so not a huge gain, but that method call runs hot so any little bit helps.

/cc @nizsheanez

See #218