2#include "internal/box.h"
3#include "internal/string.h"
4#include "internal/variable.h"
9#include "builtin_binary.rbbin"
11#ifndef BUILTIN_BINARY_SIZE
13#define BUILTIN_LOADED(feature_name, iseq) ((void)0)
14#include "mini_builtin.c"
18static const unsigned char *
19bin4feature(
const struct builtin_binary *bb,
const char *feature,
size_t *psize)
21 *psize = bb->bin_size;
22 return strcmp(bb->feature, feature) ? NULL : bb->bin;
25static const unsigned char*
26builtin_lookup(
const char *feature,
size_t *psize)
28 static size_t index = 0;
29 const unsigned char *bin = NULL;
52 bin = bin4feature(bb, feature, psize);
66 const unsigned char *bin = builtin_lookup(feature_name, &size);
68 rb_bug(
"builtin_lookup: can not find %s", feature_name);
73 if (vm->builtin_function_table != NULL) rb_bug(
"vm->builtin_function_table should be NULL.");
74 vm->builtin_function_table = table;
75 const rb_iseq_t *iseq = rb_iseq_ibf_load_bytes((
const char *)bin, size);
77 vm->builtin_function_table = NULL;
80 rb_iseq_eval(rb_iseq_check(iseq), target_box);
84rb_load_with_builtin_functions(
const char *feature_name,
const struct rb_builtin_function *table)
86 load_with_builtin_functions(feature_name, table, rb_root_box());
95 rb_define_module(
"Gem");
99 if (flags->error_highlight) {
100 rb_autoload_str(
rb_cObject, rb_intern(
"ErrorHighlight"), rb_fstring_cstr(
"error_highlight"));
102 if (flags->did_you_mean) {
103 rb_autoload_str(
rb_cObject, rb_intern(
"DidYouMean"), rb_fstring_cstr(
"did_you_mean"));
105 if (flags->syntax_suggest) {
106 rb_autoload_str(
rb_cObject, rb_intern(
"SyntaxSuggest"), rb_fstring_cstr(
"syntax_suggest"));
114rb_load_gem_prelude(
VALUE box)
116 load_with_builtin_functions(
"gem_prelude", NULL, (
const rb_box_t *)box);
122rb_free_loaded_builtin_table(
void)
134Init_builtin_features(
void)
137#ifdef BUILTIN_BINARY_SIZE
139 rb_load_gem_prelude((
VALUE)rb_root_box());
141 rb_load_gem_prelude((
VALUE)rb_main_box());
#define ASSUME
Old name of RBIMPL_ASSUME.
#define Qnil
Old name of RUBY_Qnil.
VALUE rb_cObject
Object class.
Defines RBIMPL_HAS_BUILTIN.
#define _(args)
This was a transition path from K&R to ANSI.
Internal header for Ruby Box.
uintptr_t VALUE
Type that represents a Ruby object.