Граф коммитов

18 Коммитов

Автор SHA1 Сообщение Дата
Jemma Issroff 34add1e595
[PRISM] Compile fixes (#8644)
* Fix compiling UndefNodes
* Fix compiling super on ClassNode
* Fix compile popped for ModuleNode
* Add checks for NULL nodes
* Only add newhash if not popped
2023-10-13 10:59:37 -07:00
Matt Valentine-House 05b9b58d55 [Prism] Fix IfNode and ElseNode
ElseNode looks to have been implemented at the same time as IfNode, but
was resulting in a stack underflow error.

The following is from the test code

```
if foo
  bar
end
```

```
❯ make run
compiling compile.c
linking miniruby
./miniruby -I./lib -I. -I.ext/common  -r./arm64-darwin22-fake  ./test.rb
CRUBY: **************************************************
== disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(2,19)>
0000 putself                                                          (   2)[Li]
0001 opt_send_without_block                 <calldata!mid:foo, argc:0, FCALL|VCALL|ARGS_SIMPLE>
0003 branchunless                           9
0005 putself
0006 opt_send_without_block                 <calldata!mid:bar, argc:0, FCALL|VCALL|ARGS_SIMPLE>
0008 pop
0009 putobject_INT2FIX_1_
0010 leave
PRISM: **************************************************
-- raw disasm--------
   0000 putself                                                          (   2)
   0001 send                 <calldata:foo, 0>, nil                      (   2)
   0004 branchunless         <L001>                                      (   2)
   0006 jump                 <L000>                                      (   2)
 <L000> [sp: 0]
*  0008 pop                                                              (   1)
   0009 putself                                                          (   2)
   0010 send                 <calldata:bar, 0>, nil                      (   2)
   0013 pop                                                              (   2)
   0014 jump                 <L002>                                      (   1)
 <L001> [sp: 0]
 <L002> [sp: -1]
   0016 putobject            1                                           (   2)
   0018 leave                                                            (   1)
---------------------
<compiled>: <compiled>:1: argument stack underflow (-1) (SyntaxError)
make: *** [run] Error 1
```

This commit fixes the stack underflow error for both IfNode and ElseNode
and introduces tests for them.
2023-10-04 13:53:31 -04:00
Benoit Daloze fd984ac869 Adopt prism CallNode#name changes 2023-10-02 09:18:56 -04:00
Kevin Newton 2de5c57dce Move more things through pm_static_literal_value 2023-09-29 09:51:23 -04:00
Kevin Newton 2e25289aee Handle static array nodes 2023-09-29 09:51:23 -04:00
Kevin Newton 38e3cafe62 Compile implicit nodes 2023-09-29 09:51:23 -04:00
Kevin Newton 396042a25c Fix up static hash compilation 2023-09-29 09:51:23 -04:00
Kevin Newton 3ec6be1a4b More documentation for pattern matching compilation 2023-09-28 15:13:09 -04:00
Kevin Newton 9c8ba84675 Support if and unless guards on patterns 2023-09-28 15:13:09 -04:00
Kevin Newton b1a28b05db Support local variable targeting in pattern matching 2023-09-28 15:13:09 -04:00
Kevin Newton 41d3e23582 Support the AlternationPatternNode 2023-09-28 15:13:09 -04:00
Kevin Newton 64da9be3af Fill in other missing pattern matching expression types 2023-09-28 15:13:09 -04:00
Kevin Newton 6e88a56f63 Compile basic pattern matching expressions 2023-09-28 15:13:09 -04:00
Kevin Newton 5a376f0f71 Consolidate regexp options, interpolated match last line 2023-09-28 14:11:34 -04:00
Nobuyoshi Nakada d2c5867357
Fix up indentation [ci skip] 2023-09-29 00:55:43 +09:00
Matt Valentine-House 414c781158 [YARP] Implement MatchWriteNode 2023-09-28 16:51:30 +01:00
Kevin Newton 40b2c8e5e7
Fix up indentation in prism_compile.c 2023-09-28 09:47:46 -04:00
Kevin Newton a213d21448 Move CRuby-specific prism files to top level 2023-09-28 09:44:16 -04:00