2#include "internal/array.h"
3#include "internal/eval.h"
8#include "miniprelude.c"
11prelude_ast_value(
VALUE name,
VALUE code,
int line)
14 VALUE ast_value = rb_parser_compile_string_path(rb_parser_new(), name, code, line);
15 ast = rb_ruby_ast_data_get(ast_value);
16 if (!ast || !ast->body.root) {
17 if (ast) rb_ast_dispose(ast);
26 pm_options_line_set(&result->
options, line);
27 VALUE error = pm_parse_string(result, code, name, NULL);
30 pm_parse_result_free(result);
35static const rb_iseq_t *
40 const rb_iseq_t *iseq;
41 VALUE code = rb_builtin_find(feature_name, &name_str, &start_line);
43 rb_fatal(
"builtin_iseq_load: can not find %s; "
44 "probably miniprelude.c is out of date",
48 rb_vm_t *vm = GET_VM();
49 static const rb_compile_option_t optimization = {
50 .inline_const_cache = TRUE,
51 .peephole_optimization = TRUE,
52 .tailcall_optimization = FALSE,
53 .specialized_instruction = TRUE,
54 .operands_unification = TRUE,
55 .instructions_unification = TRUE,
56 .frozen_string_literal = TRUE,
57 .debug_frozen_string_literal = FALSE,
58 .coverage_enabled = FALSE,
62 if (rb_ruby_prism_p()) {
64 pm_prelude_load(&result, name_str, code, start_line);
66 vm->builtin_function_table = table;
68 iseq = pm_iseq_new_with_opt(&result.
node, name_str, name_str,
Qnil, 0, NULL, 0, ISEQ_TYPE_TOP, &optimization, &error_state);
70 vm->builtin_function_table = NULL;
71 pm_parse_result_free(&result);
75 rb_jump_tag(error_state);
79 VALUE ast_value = prelude_ast_value(name_str, code, start_line);
80 rb_ast_t *ast = rb_ruby_ast_data_get(ast_value);
82 vm->builtin_function_table = table;
83 iseq = rb_iseq_new_with_opt(ast_value, name_str, name_str,
Qnil, 0, NULL, 0, ISEQ_TYPE_TOP, &optimization,
Qnil);
85 vm->builtin_function_table = NULL;
90 if (0 && strcmp(
"prelude", feature_name) == 0) {
91 rb_io_write(
rb_stdout, rb_iseq_disasm((
const rb_iseq_t *)iseq));
94 BUILTIN_LOADED(feature_name, iseq);
100rb_load_with_builtin_functions(
const char *feature_name,
const struct rb_builtin_function *table)
102 const rb_iseq_t *iseq = builtin_iseq_load(feature_name, table);
103 rb_iseq_eval(iseq, rb_root_box());
#define RUBY_ASSERT(...)
Asserts that the given expression is truthy if and only if RUBY_DEBUG is truthy.
#define Qnil
Old name of RUBY_Qnil.
#define NIL_P
Old name of RB_NIL_P.
void rb_exc_raise(VALUE mesg)
Raises an exception in the current thread.
VALUE rb_errinfo(void)
This is the same as $! in Ruby.
VALUE rb_stdout
STDOUT constant.
pm_scope_node_t node
The resulting scope node that will hold the generated AST.
pm_options_t options
The options that will be passed to the parser.
uintptr_t VALUE
Type that represents a Ruby object.