summaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
authorS.H <[email protected]>2024-01-27 17:11:10 +0900
committerGitHub <[email protected]>2024-01-27 08:11:10 +0000
commit9b40f42c22232aaae1b2b17bd6118eacc4c0bee3 (patch)
tree93393a4d7df5aa7d25252ace459543affde045db /compile.c
parent68b9a32a624edf0cb497d344a2a8650658500517 (diff)
Introduce `NODE_ENCODING`
`__ENCODING__ `was managed by `NODE_LIT` with Encoding object. Introduce `NODE_ENCODING` for 1. `__ENCODING__` is detectable from AST Node. 2. Reduce dependency Ruby object for parse.y
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/compile.c b/compile.c
index 4ae1174caa..eea92b3638 100644
--- a/compile.c
+++ b/compile.c
@@ -1960,6 +1960,9 @@ iseq_set_arguments_keywords(rb_iseq_t *iseq, LINK_ANCHOR *const optargs,
case NODE_IMAGINARY:
dv = rb_node_imaginary_literal_val(val_node);
break;
+ case NODE_ENCODING:
+ dv = rb_node_encoding_val(val_node);
+ break;
case NODE_NIL:
dv = Qnil;
break;
@@ -4512,6 +4515,7 @@ compile_branch_condition(rb_iseq_t *iseq, LINK_ANCHOR *ret, const NODE *cond,
case NODE_SYM:
case NODE_LINE:
case NODE_FILE:
+ case NODE_ENCODING:
case NODE_INTEGER: /* NODE_INTEGER is always true */
case NODE_FLOAT: /* NODE_FLOAT is always true */
case NODE_RATIONAL: /* NODE_RATIONAL is always true */
@@ -4722,6 +4726,7 @@ static_literal_node_p(const NODE *node, const rb_iseq_t *iseq, bool hash_key)
case NODE_LIT:
case NODE_SYM:
case NODE_LINE:
+ case NODE_ENCODING:
case NODE_INTEGER:
case NODE_FLOAT:
case NODE_RATIONAL:
@@ -4760,6 +4765,8 @@ static_literal_value(const NODE *node, rb_iseq_t *iseq)
return rb_node_sym_string_val(node);
case NODE_LINE:
return rb_node_line_lineno_val(node);
+ case NODE_ENCODING:
+ return rb_node_encoding_val(node);
case NODE_FILE:
case NODE_STR:
if (ISEQ_COMPILE_DATA(iseq)->option->debug_frozen_string_literal || RTEST(ruby_debug)) {
@@ -5790,6 +5797,7 @@ defined_expr0(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
case NODE_SYM:
case NODE_LINE:
case NODE_FILE:
+ case NODE_ENCODING:
case NODE_INTEGER:
case NODE_FLOAT:
case NODE_RATIONAL:
@@ -7221,6 +7229,7 @@ iseq_compile_pattern_each(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *c
case NODE_RATIONAL:
case NODE_IMAGINARY:
case NODE_FILE:
+ case NODE_ENCODING:
case NODE_STR:
case NODE_XSTR:
case NODE_DSTR:
@@ -10273,6 +10282,12 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
}
break;
}
+ case NODE_ENCODING:{
+ if (!popped) {
+ ADD_INSN1(ret, node, putobject, rb_node_encoding_val(node));
+ }
+ break;
+ }
case NODE_INTEGER:{
VALUE lit = rb_node_integer_literal_val(node);
debugp_param("integer", lit);