Prior to this commit, we weren't accounting for hidden variables
on the locals table, so we would have inconsistencies on the stack.
This commit fixes params, and introduces a hidden_variable_count
on the scope, both of which fix parameters.
Instead of incrementing the depth using call by reference as we're
recursing up the stack we could instead store an offset for each known
scope where we know the depth is going to represented differently in the
Prism ast.
It's possible for `defined?(A::B::C)` to raise an exception. `defined?`
must swallow the exception and return nil, so this commit adds a rescue
entry for `defined?` expressions on constant paths
Prior to this commit, we were compiling an empty array as a
duparray of [] which meant we were allocating a new value
unnecessarily. With this commit, we emit a newarray with size 0
instead.
This commit fixes a bug with locals in ensure nodes by setting
the local tables correctly. It also changes accessing locals to
look at local tables in parent scopes, and account for this
correctly on depths of get or setlocals.
Prior to this commit, we were conflating the size of the locals
list with the number of parameters. This commit distinguishes
the two, and fixes a related bug which would occur if we set a local
that was not a parameter
SplatNodes within ArrayNodes (e.g. [*1..2, 3]) need to be special
cased in the compiler because they use a combination of concatarray
and newarray instructions to treat each sequence of splat or non-splat
elements as independent arrays which get concatenated. This commit
implements those cases.
This PR implements the once node on interpolated regexes.
There is a bug in Prism where the interpolated regex with the once flag
only works when there is not a local variable so the test uses a "1".
We'll need to fix that.
We know where it is in the iseq local table, because we forced it using
`iseq_set_exception_local_table` when compiling the BEGIN_NODE, so we
can always look it up from the same place.
Co-Authored-By Peter Zhu <peter@peterzhu.ca>
This commit compiles most parameter types, setting appropriate values on
the ISEQ_BODY. It also adds tests for callers and callees of methods,
using many versions of tests from bootstraptest