[PRISM] Implement `PM_SOURCE_ENCODING_NODE` for `defined?

Ruby code:

```ruby
defined?(__ENCODING__)
```

Instructions:

```
"********* Ruby *************"
== disasm: #<ISeq:<compiled>@<compiled>:0 (0,0)-(0,22)>
0000 putobject                              "expression"
0002 leave

"********* PRISM *************"
== disasm: #<ISeq:<compiled>@<compiled>:0 (0,0)-(0,22)>
0000 putobject                              "expression"
0002 leave
```
This commit is contained in:
eileencodes 2023-12-05 12:07:26 -05:00 коммит произвёл Jemma Issroff
Родитель b04255deff
Коммит 41b117e50c
2 изменённых файлов: 2 добавлений и 0 удалений

Просмотреть файл

@ -1491,6 +1491,7 @@ pm_compile_defined_expr0(rb_iseq_t *iseq, const pm_node_t *node, LINK_ANCHOR *co
case PM_OR_NODE:
case PM_RANGE_NODE:
case PM_REGULAR_EXPRESSION_NODE:
case PM_SOURCE_ENCODING_NODE:
case PM_STRING_NODE:
case PM_SYMBOL_NODE:
case PM_X_STRING_NODE:

Просмотреть файл

@ -110,6 +110,7 @@ module Prism
assert_prism_eval("defined? -> { 1 + 1 }")
assert_prism_eval("defined? a && b")
assert_prism_eval("defined? a || b")
assert_prism_eval("defined? __ENCODING__")
assert_prism_eval("defined? %[1,2,3]")
assert_prism_eval("defined? %q[1,2,3]")