Commit graph

345 commits

Author SHA1 Message Date
Jemma Issroff
103bbd21f8 [PRISM] Updated LocalVariableTargetNodes too 2023-11-20 13:48:46 -08:00
Jemma Issroff
b913626bea [PRISM] Fix LocalVariableWriteNodes within blocks
Prior to this commit, we weren't recursing up scopes to look for
the local definition. With this commit, we do so, fixing local writes
within blocks
2023-11-20 13:48:46 -08:00
eileencodes
2796e4ece2 [PRISM] Implement once node for interpolated regex
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.
2023-11-20 12:42:05 -08:00
Jemma Issroff
c5d5929443 [PRISM] Don't pop args to YieldNode 2023-11-20 12:12:34 -08:00
eileencodes
4dd11c067d Switching first argument in pm_interpolated_node_compile
This changes the first argument in `pm_interpolated_node_compile` to use
a pointer.
2023-11-20 07:05:09 -08:00
Jemma Issroff
775ed27d6d [PRISM] Initialize keyword to silence warning 2023-11-13 17:48:55 -05:00
Jemma Issroff
ae1fad4cd7 [PRISM] Implement compilation for ForwardingArgumentssNode 2023-11-09 09:45:59 -03:00
Nobuyoshi Nakada
0f02fbd9ff Range check in pm_constant_id_lookup 2023-11-09 18:21:45 +09:00
Nobuyoshi Nakada
e824b69a86 Remove useless casts 2023-11-09 18:21:45 +09:00
Matt Valentine-House
5c8d2c2d45 [PRISM] Always lookup idERROR_INFO consistently.
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>
2023-11-08 20:28:58 -05:00
Jemma Issroff
f9e34a1fd3 [PRISM] Add tests for OptionalKeywordParameterNode
This commit adds tests for the compilation of the
OptionalKeywordParameterNode, and fixes cases on the
RequiredKeywordParameterNode
2023-11-08 18:15:47 -03:00
Jemma Issroff
70e4ff9feb [PRISM] Added tests for ForwardingParameterNode, KeywordRestParameterNode 2023-11-08 18:15:47 -03:00
Jemma Issroff
26cff6ae2b [PRISM] Add tests for several parameters nodes
This commit adds tests for BlockParameterNode, RequiredParameterNode,
RequiredKeywordParameterNode and RestParameterNode
2023-11-08 18:15:47 -03:00
Jemma Issroff
bc07b0b9e1 [PRISM] Implement compilation for different parameters
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
2023-11-07 15:15:16 -03:00
Matt Valentine-House
e7bdd9e498 [PRISM] Move Local table setup into EnsureNode compilation 2023-11-07 14:03:57 +00:00
Matt Valentine-House
b7d5a63b9a [PRISM] Don't generate leave insns for Ensure nodes 2023-11-07 14:03:57 +00:00
Matt Valentine-House
8ef7f27321 [PRISM] CompileEnsureNode 2023-11-07 14:03:57 +00:00
Matt Valentine-House
237b85c256 [PRISM] PM_COMPILE into a specified LINK_ANCHOR 2023-11-07 14:03:57 +00:00
Jemma Issroff
f6ba87ca88 [PRISM] Implement compilation for MultiWriteNodes, fix MultiTargetNodes
Compilation now works for MultiWriteNodes and MultiTargetNodes, with
nesting on MultiWrites. See the tests added in this commit for example
behavior.
2023-11-06 10:39:07 -03:00
Matt Valentine-House
cdb410f688 [PRISM] Fix stack consistency with Popped begin
When a begin node is popped it only needs to putnil if that nil is going
to be the return value, otherwise it can successfully be optimised out.
2023-11-03 15:19:28 +00:00
Matt Valentine-House
dcb9ded6c9 [PRISM] Fix CallNode with arguments when popped
Previously emitting a call node with an argument followed by another
node would cause the argument to be mistakenly omitted from the argument
list causing a stack underflow.

```
PRISM: **************************************************
-- raw disasm--------
   0000 putself                                                          (   0)
   0001 send                 <calldata:puts, 1>, nil                     (   0)
*  0004 pop                                                              (   0)
   0005 putobject            1                                           (   0)
   0007 leave                                                            (   0)
---------------------
```
2023-11-03 07:28:05 +00:00
Jemma Issroff
c6f5c64639 [PRISM] Fix popped for ForNode 2023-11-02 17:46:43 -03:00
Jemma Issroff
7f18448a8e [PRISM] Fix popped for CallOperatorWriteNode 2023-11-02 17:46:43 -03:00
Jemma Issroff
d8bdb15a8b [PRISM] Fix popped for Call{And,Or}WriteNode 2023-11-02 17:46:43 -03:00
Jemma Issroff
5acced49c2 [PRISM] Fix popped for SingletonClassNode 2023-11-02 17:46:43 -03:00
Jemma Issroff
33f18b3d2f [PRISM] Fix popped for CaseNode 2023-11-02 17:46:43 -03:00
Jemma Issroff
62baf723b6 [PRISM] Fix popped for AssocSplatNode 2023-11-02 17:46:43 -03:00
Jemma Issroff
8b4b3b1d38 [PRISM] Fix popped for MatchWriteNode 2023-11-02 17:46:43 -03:00
Jemma Issroff
0359f9ca67 [PRISM] Fix popped for ConstantPathOperatorWriteNode 2023-11-02 17:46:43 -03:00
Jemma Issroff
ddf12e8a3b [PRISM] Fix popped for ConstantPathOrWriteNode 2023-11-02 17:46:43 -03:00
Jemma Issroff
ca24136da6 [PRISM] Fix popped on DefinedNode 2023-11-02 17:46:43 -03:00
Jemma Issroff
698654ca84 [PRISM] Fixed popped for ConstantPathAndWriteNode 2023-11-02 17:46:43 -03:00
Kevin Newton
717fb5bb0b [prism] Use a pointer for optional node list 2023-11-01 10:36:21 -04:00
Jemma Issroff
b7a3e2e71d
[PRISM] Remove unnecessary variable 2023-10-31 15:57:25 -03:00
Jemma Issroff
b3744c749d [PRISM] Implement compilation for SuperNode 2023-10-31 13:59:40 -03:00
Jemma Issroff
57748ef2a2 [PRISM] Compile forwarding super node 2023-10-31 13:08:09 -03:00
Jemma Issroff
85ad102532 [PRISM] Implement compilation for PostExecutionNode
This commit implements compilation for the PostExeuctionNode by
using the ScopeNode to create child iseqs where appropriate.
2023-10-31 12:51:06 -03:00
HParker
d8a9245513 Add defined array node 2023-10-31 07:01:00 -03:00
HParker
b05a7bc512 compile defined with nested constants and stovetop 2023-10-31 07:01:00 -03:00
Matt Valentine-House
962c62057f Fix warning in Prism compile For Node 2023-10-31 09:01:56 +00:00
Jemma Issroff
f0b7895637 [PRISM] Implement all argument types for CallNodes 2023-10-30 18:07:04 -03:00
Matt Valentine-House
b17b0336b6 Document TEMP_CONSTANT_IDENTIFIER 2023-10-30 19:44:42 +00:00
Matt Valentine-House
9249b8622b Move constant indexing into rb_translate_prism 2023-10-30 19:44:42 +00:00
Matt Valentine-House
5dfba84cff [Prism] Compile ForNode
Fixes ruby/prism#1648
2023-10-30 19:44:42 +00:00
Matt Valentine-House
b0f715fa3b More accurate functions documentation 2023-10-30 19:44:42 +00:00
Kevin Newton
e3258dd627
Integrate new prism multi target names 2023-10-26 15:03:33 -04:00
eileencodes
a082e560bb [PRISM] Implement regex encoding flags
Added the  correct encoding to the allocated regex. This required making
a new method to set the encoding and pass that to `rb_enc_reg_new`
instead of `rb_reg_new`. The former `rb_reg_new` would set the encoding
to ASCII8BIT regardless of encoding flag.
2023-10-26 11:11:52 -07:00
Jemma Issroff
4f8a33eb05 [PRISM] Cleanup macro usage for common ADD_INSN 2023-10-26 12:47:28 -03:00
HParker
8f4a8cd05b teach prism define to compile basic types 2023-10-26 11:54:26 -03:00
Jemma Issroff
9570a88bb3 [PRISM] Implement compilation for ConstantPathAndWriteNode 2023-10-26 11:42:15 -03:00