Commit graph

591 commits

Author SHA1 Message Date
Kevin Newton
a7b47f96f3 [PRISM] Add splatkw to super calls when necessary 2024-01-31 22:18:55 -05:00
Kevin Newton
d96b4586e4 [PRISM] Fix up index write nodes to match 2024-01-31 22:18:55 -05:00
Kevin Newton
d36c31ed9b [PRISM] Fix keywords in index write nodes 2024-01-31 22:18:55 -05:00
Kevin Newton
8acd1f708f [PRISM] Fix combination of safe navigation and ||= and &&= operators 2024-01-31 22:18:55 -05:00
Kevin Newton
4d01c59042 [PRISM] Fix combination of attribute write and safe navigation 2024-01-31 22:18:55 -05:00
Kevin Newton
b5a2c60d0a [PRISM] Support SCRIPT_LINES__ 2024-01-31 15:49:32 -05:00
Peter Zhu
cb98b018c0 [PRISM] Fix else with rescue
Fixes ruby/prism#2307.
2024-01-31 14:11:14 -05:00
Étienne Barrié
c28ee91263 [PRISM] Fix incorrect use of VM_CALL_KW_SPLAT_MUT in zsuper with keyword splat
This copies the changes from 771a2f039b.
Fixes ruby/prism#2310.
2024-01-31 13:41:49 -05:00
Kevin Newton
610636fd6b [PRISM] Mirror iseq APIs
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.
2024-01-31 13:41:36 -05:00
Matt Valentine-House
8041b7d967 [PRISM] pm_compile_logical: Fix OrNode in IfNode predicate
Fixes: https://github.com/ruby/prism/issues/2294
2024-01-30 22:22:39 +00:00
Matt Valentine-House
1142ed2f50 [PRISM] Remove unneccessary uses of cond_seq
As this is compiled into only on the recursive call and then added, we
can just use `ret` directly
2024-01-30 22:22:39 +00:00
Aaron Patterson
8e708e4a07 Update forwarding locals for prism 2024-01-30 13:19:06 -05:00
Peter Zhu
c85e28d12a [PRISM] Remove unused variable 2024-01-30 10:29:11 -05:00
Kevin Newton
83966a57fe [PRISM] Method location for calls 2024-01-29 22:22:30 -05:00
Peter Zhu
bbb7ab906e [PRISM] Fix crash when multiple underscores
Fixes ruby/prism#2295.
2024-01-29 17:15:33 -05:00
Kevin Newton
3fb741069d [PRISM] Fix rescue frame label 2024-01-29 16:38:11 -05:00
Peter Zhu
8e1fe15b4a [PRISM] Implement opt_str_uminus 2024-01-29 16:34:25 -05:00
Peter Zhu
32bbf47500 [PRISM] Use opt_str_freeze instruction
Fixes ruby/prism#2290.
2024-01-29 14:53:34 -05:00
Matt Valentine-House
d7501c4031 [PRISM] Fix InterpolatedStringNode
If the first element of an interpolated string node is an embedded
statement, CRuby "pre-initializes" the interpolation with a string of
known encoding to concat into.

This patch replicates thate behaviour in Prism
2024-01-29 19:13:53 +00:00
Peter Zhu
3d3d9e8397 [PRISM] Support US-ASCII symbols 2024-01-29 13:56:54 -05:00
Peter Zhu
d980c89273 [PRISM] Support ASCII-8BIT symbols 2024-01-29 13:56:54 -05:00
Peter Zhu
f634c7a268 [PRISM] Support UTF-8 symbols
Fixes ruby/prism#2242.
2024-01-29 13:56:54 -05:00
Peter Zhu
9a5a11f3d0 [PRISM] Use the splatkw instruction
Fixes ruby/prism#2272.
2024-01-29 11:42:40 -05:00
Matt Valentine-House
c422805bbb [PRISM] Fix encoding for interpolated strings.
This wasn't taking into account strings with flags set on the containing
node that could affect the encoding. It does now
2024-01-29 10:04:16 -05:00
Kevin Newton
cb9a47f2ac [PRISM] Fix branchif ADD_INSN1 2024-01-26 16:46:31 -05:00
Peter Zhu
a120529020 [PRISM] Fix loop in rescue blocks
Fixes ruby/prism#2250.

Co-Authored-By: Kevin Newton <kddnewton@gmail.com>
2024-01-26 16:07:24 -05:00
Peter Zhu
59bb78ebd0 [PRISM] Fix for s390x
On s390x, a long is 8 bytes. st_data_t is an unsigned long but
pm_constant_id_t is a 4 byte integer. We need to cast it to st_data_t
when passing it to ST functions.
2024-01-26 15:41:06 -05:00
Peter Zhu
3d996e827f [PRISM] Keyword arguments incorrectly passed as mutable
Fixes ruby/prism#2279.
2024-01-26 14:58:29 -05:00
Matt Valentine-House
e452caac10 [PRISM] Fix next inside rescue 2024-01-25 15:10:52 -05:00
Kevin Newton
1301422dfe [PRISM] Fix VM_CALL_ARGS_SPLAT_MUT failures 2024-01-25 11:11:50 -05:00
Peter Zhu
f769d68a69 [PRISM] Fix getblockparamproxy for forwarding arguments 2024-01-24 17:32:43 -05:00
Peter Zhu
7d61454f2e [PRISM] Fix method calls in keyword arguments
Fixes ruby/prism#2248.
2024-01-24 15:18:06 -05:00
Aaron Patterson
94f3f9502c Fix repeated block param
Co-Authored-By: Matt Valentine-House <matt@eightbitraptor.com>
2024-01-24 12:04:44 -08:00
Aaron Patterson
1817af5074 Fix local table size / index for repeated kwrest
Co-Authored-By: Matt Valentine-House <matt@eightbitraptor.com>
2024-01-24 12:04:44 -08:00
Aaron Patterson
13c76e40d3 Fix local table size and variable offset for repeated keywords
Co-Authored-By: Matt Valentine-House <matt@eightbitraptor.com>
2024-01-24 12:04:44 -08:00
Aaron Patterson
8b7e78f156 Fix local table size and index for required post underscore
Co-Authored-By: Matt Valentine-House <matt@eightbitraptor.com>
2024-01-24 12:04:44 -08:00
Aaron Patterson
bb6af9287b Fix local table space for *_
We need to make sure there is enough room in the local table for
repeated `*_` parameters

Co-Authored-By: Matt Valentine-House <matt@eightbitraptor.com>
2024-01-24 12:04:44 -08:00
Aaron Patterson
03f76f098a Fix repeated optional _ parameters
Ensure there is enough space in the local table for repeated optional
parameters.

Co-Authored-By: Matt Valentine-House <matt@eightbitraptor.com>
2024-01-24 12:04:44 -08:00
Aaron Patterson
29c3ec3d49 Fix required positional repeated _ parameters
Co-Authored-By: Matt Valentine-House <matt@eightbitraptor.com>
2024-01-24 12:04:44 -08:00
Kevin Newton
44c337a397 [PRISM] Support __LINE__, __FILE__, and __ENCODING__ in patterns, fix pinned expressions 2024-01-24 15:02:32 -05:00
Kevin Newton
c888b8d63b [PRISM] Handle implicit lvar write in hash pattern 2024-01-24 14:18:33 -05:00
Peter Zhu
020fe6e0ca [PRISM] Fix forwarding from within block
Fixes ruby/prism#2253.
2024-01-24 14:18:25 -05:00
Peter Zhu
dc8fb7d97f [PRISM] Fix crash in anonymous block with forwarding arguments
Fixes ruby/prism#2262.
2024-01-24 13:42:21 -05:00
Aaron Patterson
578ff32611 Move filling in the rest of the locals to the end 2024-01-24 09:40:30 -08:00
Aaron Patterson
7a33a1aee2 Insert all locals in the locals index table
Prism provides an index (local_body_index) which is supposed to point at
the start of locals declared in the method body. Prism assumed that
method body locals would only occur _after_ parameter names.
Unfortunately this assumption is not correct, which meant that we would
in some cases not insert all locals in the local table.  This commit
iterates over locals a second time, inserting any that didn't get
inserted on the first pass.

Fixes: https://github.com/ruby/prism/issues/2245

Co-Authored-By: Matt Valentine-House <matt@eightbitraptor.com>
2024-01-24 09:40:30 -08:00
Peter Zhu
927928badb [PRISM] Fix anonymous keyword arguments
Fixes ruby/prism#2256.
2024-01-24 11:41:08 -05:00
Kevin Newton
4220bdba39 [PRISM] Remove dead code from prism_compile.c
Previously, we were using the main pm_compile_node switch to compile
target nodes. Eventually we switched to pm_compile_target_node and
updated all the call sites. As such, all of this has become dead
code.

However, the multi target code was reused for both parameters and
multi writes (it was just incorrect for multi writes). So that code
has now been moved into its own function that is more specific to
destructured parameters (and has more assertions to that effect).

Overall now you should not see target nodes when you call into
pm_compile_node, since they are more specialized and require more
special handling.
2024-01-24 11:18:58 -05:00
Kevin Newton
767f5d045f [PRISM] Use lvar depths for starting 2024-01-24 10:37:08 -05:00
Peter Zhu
529700d314 [PRISM] Nested MultiWriteNode with method calls
Fixes ruby/prism#2247.
2024-01-24 10:08:25 -05:00
Peter Zhu
909a710a69 [PRISM] Fix anonymous splat nodes
Fixes ruby/prism#2257.
2024-01-23 17:45:51 -05:00