summaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-05-31 15:51:40 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-06-19 18:46:55 +0900
commit49f0fd21e468e567dc122547d516eef42c0ce0d3 (patch)
treecfda3922a7a61f4c9c189e3076e11eaa0ea162a5 /compile.c
parentd863f4bccdd1b5566fbdbe87af766e54b995f8af (diff)
[Feature #16254] Allow `Primitive.func` style
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3165
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/compile.c b/compile.c
index 13df6a0062..0753792aaf 100644
--- a/compile.c
+++ b/compile.c
@@ -7045,7 +7045,8 @@ iseq_builtin_function_name(const enum node_type type, const NODE *recv, ID mid)
static const char prefix[] = "__builtin_";
const size_t prefix_len = sizeof(prefix) - 1;
- if (type == NODE_CALL) {
+ switch (type) {
+ case NODE_CALL:
if (recv) {
switch (nd_type(recv)) {
case NODE_VCALL:
@@ -7053,14 +7054,22 @@ iseq_builtin_function_name(const enum node_type type, const NODE *recv, ID mid)
return name;
}
break;
+ case NODE_CONST:
+ if (recv->nd_vid == rb_intern("Primitive")) {
+ return name;
+ }
+ break;
default: break;
}
}
- }
- else if (type == NODE_VCALL || type == NODE_FCALL) {
+ break;
+ case NODE_VCALL:
+ case NODE_FCALL:
if (UNLIKELY(strncmp(prefix, name, prefix_len) == 0)) {
return &name[prefix_len];
}
+ break;
+ default: break;
}
return NULL;
}