Before this commit, there were many places where we had to generate
dummy line nodes to hold both the line number and the node id that
would then immediately get pulled out from the created node. Now
we pass them explicitly so that we don't have to generate these
nodes.
This makes a clearer line between the parser and compiler, and also
makes it easier to generate instructions when we don't have a
specific node to tie them to. As such, it removes almost every
single place where we needed to previously generate dummy nodes.
This also makes it easier for the prism compiler, because now we
can pass in line number and node id instead of trying to generate
dummy nodes for every instruction that we compile.
This is essentially an adaptation of aae8223c70 ("Dup splat array in
certain cases where there is a block argument") to pass
`TestCall#test_call_block_order`.
This also makes PRISM emit `getblockparamproxy` in cases like
`def foo(&blk) = bar(&blk)` where it used the less efficient
`getblockparam` previously.
Remove the `popped` parameter from setup_args() because it should always
be ignored, and is in fact unused.
Previously, the local index of numbered parameters were assigned to
names of regular locals, making it hard to read both of them. Use proper
`_[1-9]` numbered parameters. This fixes `test_shapes.rb`.
Also, properly mark the iseq as having lead parameters.
In addition to saving space by deduplicating, this also makes the
literals have code range like TestObjSpace#test_dump_string_coderange
expects. It's testing a detail, but we might as well use rb_fstring().
Note that `putstring` makes a mutable duplicate, so passing it an
fstring is fine.
There are several prism tests failing related to the `source_location`
for lambda returning line of the operator (`->`)
while original parser execution results in `source_location` line
pointing to the block opening location (`{` or `do`)
This commit changes `PM_LAMBDA_NODE` compilation case
to use block opening location instead of the whole node (operator)
opening location to get the line number to build block iseq
Previously, `return *array, 1` didn't behave like `return [*array, 1]`
properly. Also, it crashed when splat and kwsplat is combined like in
`array = [*things, **hash]`.
Fix this by grouping `PM_ARGUMENTS_NODE` with `PM_ARRAY_NODE` handling and
combining splat and kwsplat handling.
Before this commit, we were mixing a lot of concerns with the prism
compile between RubyVM::InstructionSequence and the general entry
points to the prism parser/compiler.
This commit makes all of the various prism-related APIs mirror
their corresponding APIs in the existing parser/compiler. This means
we now have the correct frame naming, and it's much easier to follow
where the logic actually flows. Furthermore this consolidates a lot
of the prism initialization, making it easier to see where we could
potentially be raising errors.