Ruby  2.5.0dev(2017-10-22revision60238)
Data Structures | Macros | Typedefs | Enumerations | Functions
compile.c File Reference
#include "internal.h"
#include "ruby/re.h"
#include "encindex.h"
#include <math.h>
#include "vm_core.h"
#include "iseq.h"
#include "insns.inc"
#include "insns_info.inc"
#include "id_table.h"
#include "gc.h"
#include "optinsn.inc"

Go to the source code of this file.

Data Structures

struct  iseq_link_element
 
struct  iseq_link_anchor
 
struct  iseq_label_data
 
struct  iseq_insn_data
 
struct  iseq_adjust_data
 
struct  ensure_range
 
struct  iseq_compile_data_ensure_node_stack
 
struct  cdhash_set_label_struct
 
struct  accessor_args
 
struct  ibf_header
 
struct  ibf_id_entry
 
struct  ibf_dump
 
struct  ibf_load
 
struct  ibf_dump_id_list_i_arg
 
struct  ibf_object_header
 
struct  ibf_object_string
 
struct  ibf_object_regexp
 
struct  ibf_object_array
 
struct  ibf_object_hash
 
struct  ibf_object_struct_range
 
struct  ibf_object_bignum
 
struct  ibf_object_complex_rational
 
struct  ibf_object_symbol
 

Macros

#define USE_INSN_STACK_INCREASE   1
 
#define RUBY_UNTYPED_DATA_WARNING   0
 
#define ISEQ_TYPE_ONCE_GUARD   ISEQ_TYPE_DEFINED_GUARD
 
#define FIXNUM_INC(n, i)   ((n)+(INT2FIX(i)&~FIXNUM_FLAG))
 
#define FIXNUM_OR(n, i)   ((n)|INT2FIX(i))
 
#define CPDEBUG   0
 debug function(macro) interface depend on CPDEBUG if it is less than 0, runtime option is in effect. More...
 
#define compile_debug   CPDEBUG
 
#define debugi(header, id)   ((void)0)
 
#define debugp(header, value)   ((void)0)
 
#define debugp_verbose(header, value)   ((void)0)
 
#define debugp_verbose_node(header, value)   ((void)0)
 
#define debugp_param(header, value)   ((void)0)
 
#define debug_node_start(node)   ((void)0)
 
#define debug_node_end()   ((void)0)
 
#define debugs   if(0)printf
 
#define debug_compile(msg, v)   (v)
 
#define LVAR_ERRINFO   (1)
 
#define NEW_LABEL(l)   new_label_body(iseq, (l))
 
#define LABEL_FORMAT   "<L%03d>"
 
#define NEW_ISEQ(node, name, type, line_no)   new_child_iseq(iseq, (node), rb_fstring(name), 0, (type), (line_no))
 
#define NEW_CHILD_ISEQ(node, name, type, line_no)   new_child_iseq(iseq, (node), rb_fstring(name), iseq, (type), (line_no))
 
#define ADD_SEQ(seq1, seq2)   APPEND_LIST((seq1), (seq2))
 
#define ADD_INSN(seq, line, insn)   ADD_ELEM((seq), (LINK_ELEMENT *) new_insn_body(iseq, (line), BIN(insn), 0))
 
#define INSERT_BEFORE_INSN(prev, line, insn)   INSERT_ELEM_PREV(&(prev)->link, (LINK_ELEMENT *) new_insn_body(iseq, (line), BIN(insn), 0))
 
#define ADD_INSN1(seq, line, insn, op1)
 
#define INSERT_BEFORE_INSN1(prev, line, insn, op1)
 
#define LABEL_REF(label)   ((label)->refcnt++)
 
#define ADD_INSNL(seq, line, insn, label)   (ADD_INSN1(seq, line, insn, label), LABEL_REF(label))
 
#define ADD_INSN2(seq, line, insn, op1, op2)
 
#define ADD_INSN3(seq, line, insn, op1, op2, op3)
 
#define ADD_SEND(seq, line, id, argc)   ADD_SEND_R((seq), (line), (id), (argc), NULL, (VALUE)INT2FIX(0), NULL)
 
#define ADD_SEND_WITH_FLAG(seq, line, id, argc, flag)   ADD_SEND_R((seq), (line), (id), (argc), NULL, (VALUE)(flag), NULL)
 
#define ADD_SEND_WITH_BLOCK(seq, line, id, argc, block)   ADD_SEND_R((seq), (line), (id), (argc), (block), (VALUE)INT2FIX(0), NULL)
 
#define ADD_CALL_RECEIVER(seq, line)   ADD_INSN((seq), (line), putself)
 
#define ADD_CALL(seq, line, id, argc)   ADD_SEND_R((seq), (line), (id), (argc), NULL, (VALUE)INT2FIX(VM_CALL_FCALL), NULL)
 
#define ADD_CALL_WITH_BLOCK(seq, line, id, argc, block)   ADD_SEND_R((seq), (line), (id), (argc), (block), (VALUE)INT2FIX(VM_CALL_FCALL), NULL)
 
#define ADD_SEND_R(seq, line, id, argc, block, flag, keywords)   ADD_ELEM((seq), (LINK_ELEMENT *) new_insn_send(iseq, (line), (id), (VALUE)(argc), (block), (VALUE)(flag), (keywords)))
 
#define ADD_TRACE_LINE_COVERAGE(seq, line)
 
#define DECL_BRANCH_BASE(branches, line, type)
 
#define ADD_TRACE_BRANCH_COVERAGE(seq, line, type, branches)
 
#define ADD_TRACE_METHOD_COVERAGE(seq, line, method_name)
 
#define ADD_TRACE(seq, line, event)
 
#define ADD_GETLOCAL(seq, line, idx, level)
 
#define ADD_SETLOCAL(seq, line, idx, level)
 
#define ADD_LABEL(seq, label)   ADD_ELEM((seq), (LINK_ELEMENT *) (label))
 
#define APPEND_LABEL(seq, before, label)   APPEND_ELEM((seq), (before), (LINK_ELEMENT *) (label))
 
#define ADD_ADJUST(seq, line, label)   ADD_ELEM((seq), (LINK_ELEMENT *) new_adjust_body(iseq, (label), (line)))
 
#define ADD_ADJUST_RESTORE(seq, label)   ADD_ELEM((seq), (LINK_ELEMENT *) new_adjust_body(iseq, (label), -1))
 
#define LABEL_UNREMOVABLE(label)   ((label) ? (LABEL_REF(label), (label)->unremovable=1) : 0)
 
#define ADD_CATCH_ENTRY(type, ls, le, iseqv, lc)
 
#define COMPILE(anchor, desc, node)
 
#define COMPILE_POPPED(anchor, desc, node)
 
#define COMPILE_(anchor, desc, node, popped)
 
#define COMPILE_RECV(anchor, desc, node)
 
#define OPERAND_AT(insn, idx)   (((INSN*)(insn))->operands[(idx)])
 
#define INSN_OF(insn)   (((INSN*)(insn))->insn_id)
 
#define IS_INSN(link)   ((link)->type == ISEQ_ELEMENT_INSN)
 
#define IS_LABEL(link)   ((link)->type == ISEQ_ELEMENT_LABEL)
 
#define IS_ADJUST(link)   ((link)->type == ISEQ_ELEMENT_ADJUST)
 
#define IS_INSN_ID(iobj, insn)   (INSN_OF(iobj) == BIN(insn))
 
#define IS_NEXT_INSN_ID(link, insn)   ((link)->next && IS_INSN((link)->next) && IS_INSN_ID((link)->next, insn))
 
#define COMPILE_ERROR   append_compile_error
 
#define ERROR_ARGS_AT(n)   iseq, nd_line(n),
 
#define ERROR_ARGS   ERROR_ARGS_AT(node)
 
#define EXPECT_NODE(prefix, node, ndtype, errval)
 
#define EXPECT_NODE_NONULL(prefix, parent, ndtype, errval)
 
#define UNKNOWN_NODE(prefix, node, errval)
 
#define COMPILE_OK   1
 
#define COMPILE_NG   0
 
#define CHECK(sub)   if (!(sub)) {BEFORE_RETURN;return COMPILE_NG;}
 
#define BEFORE_RETURN
 
#define DECL_ANCHOR(name)   LINK_ANCHOR name[1] = {{{0,},}}
 
#define INIT_ANCHOR(name)   (name->last = &name->anchor)
 
#define ISEQ_ARG
 
#define ISEQ_ARG_DECLARE
 
#define PADDING_SIZE_MAX   0
 
#define debug_list(anc)   ((void)0)
 
#define BADINSN_DUMP(anchor, list, dest)   dump_disasm_list_with_cursor(&anchor->anchor, list, dest)
 
#define BADINSN_ERROR
 
#define IS_TRACE_LINE(insn)
 
#define SP_INSN(opt)   insn_set_specialized_instruction(iseq, iobj, BIN(opt_##opt))
 
#define MEMORY(v)
 
#define private_recv_p(node)   (nd_type((node)->nd_recv) == NODE_SELF)
 
#define BEFORE_RETURN   debug_node_end()
 
#define rb_intern(str)   rb_intern_const(str)
 
#define CHECK_ARRAY(v)   rb_convert_type_with_id((v), T_ARRAY, "Array", idTo_ary)
 
#define CHECK_SYMBOL(v)   rb_convert_type_with_id((v), T_SYMBOL, "Symbol", idTo_sym)
 
#define SYM(s)   ID2SYM(rb_intern(#s))
 
#define SYM(s)   ID2SYM(rb_intern(#s))
 
#define INT_PARAM(F)   int_param(&iseq->body->param.F, params, SYM(F))
 
#define INT_PARAM(F)   F = (int_param(&x, misc, SYM(F)) ? (unsigned int)x : 0)
 
#define IBF_OFFSET(ptr)   ((ibf_offset_t)(VALUE)(ptr))
 
#define IBF_W(b, type, n)   (type *)(VALUE)ibf_dump_write(dump, (b), sizeof(type) * (n))
 
#define IBF_WV(variable)   ibf_dump_write(dump, &(variable), sizeof(variable))
 
#define IBF_WP(b, type, n)   ibf_dump_write(dump, (b), sizeof(type) * (n))
 
#define IBF_R(val, type, n)   (type *)ibf_load_alloc(load, IBF_OFFSET(val), sizeof(type) * (n))
 
#define IBF_OBJECT_INTERNAL   FL_PROMOTED0
 
#define IBF_OBJHEADER(offset)   (struct ibf_object_header *)(load->buff + (offset))
 
#define IBF_OBJBODY(type, offset)   (type *)(load->buff + sizeof(struct ibf_object_header) + (offset))
 

Typedefs

typedef struct iseq_link_element LINK_ELEMENT
 
typedef struct iseq_link_anchor LINK_ANCHOR
 
typedef struct iseq_label_data LABEL
 
typedef struct iseq_insn_data INSN
 
typedef struct iseq_adjust_data ADJUST
 
typedef unsigned int ibf_offset_t
 
typedef void(* ibf_dump_object_function) (struct ibf_dump *dump, VALUE obj)
 
typedef VALUE(* ibf_load_object_function) (const struct ibf_load *load, const struct ibf_object_header *header, ibf_offset_t)
 

Enumerations

enum  LABEL_RESCUE_TYPE { LABEL_RESCUE_NONE, LABEL_RESCUE_BEG, LABEL_RESCUE_END, LABEL_RESCUE_TYPE_MAX }
 
enum  compile_array_type_t { COMPILE_ARRAY_TYPE_ARRAY, COMPILE_ARRAY_TYPE_HASH, COMPILE_ARRAY_TYPE_ARGS }
 
enum  ibf_object_class_index { IBF_OBJECT_CLASS_OBJECT, IBF_OBJECT_CLASS_ARRAY, IBF_OBJECT_CLASS_STANDARD_ERROR }
 
enum  ibf_object_data_type { IBF_OBJECT_DATA_ENCODING }
 

Functions

VALUE rb_iseq_compile_node (rb_iseq_t *iseq, NODE *node)
 
int rb_iseq_translate_threaded_code (rb_iseq_t *iseq)
 
VALUErb_iseq_original_iseq (const rb_iseq_t *iseq)
 
const char * rb_insns_name (int i)
 
VALUE rb_insns_name_array (void)
 
void rb_iseq_build_from_ary (rb_iseq_t *iseq, VALUE misc, VALUE locals, VALUE params, VALUE exception, VALUE body)
 
int rb_dvar_defined (ID id, const struct rb_block *base_block)
 
int rb_local_defined (ID id, const struct rb_block *base_block)
 
const rb_iseq_trb_method_for_self_aref (VALUE name, VALUE arg, rb_insn_func_t func)
 
const rb_iseq_trb_method_for_self_aset (VALUE name, VALUE arg, rb_insn_func_t func)
 
rb_iseq_tiseq_alloc (void)
 
VALUE iseq_ibf_dump (const rb_iseq_t *iseq, VALUE opt)
 
void ibf_load_iseq_complete (rb_iseq_t *iseq)
 
const rb_iseq_tiseq_ibf_load (VALUE str)
 
VALUE iseq_ibf_load_extra_data (VALUE str)
 

Macro Definition Documentation

◆ ADD_ADJUST

#define ADD_ADJUST (   seq,
  line,
  label 
)    ADD_ELEM((seq), (LINK_ELEMENT *) new_adjust_body(iseq, (label), (line)))

Definition at line 318 of file compile.c.

◆ ADD_ADJUST_RESTORE

#define ADD_ADJUST_RESTORE (   seq,
  label 
)    ADD_ELEM((seq), (LINK_ELEMENT *) new_adjust_body(iseq, (label), -1))

Definition at line 321 of file compile.c.

◆ ADD_CALL

#define ADD_CALL (   seq,
  line,
  id,
  argc 
)    ADD_SEND_R((seq), (line), (id), (argc), NULL, (VALUE)INT2FIX(VM_CALL_FCALL), NULL)

Definition at line 234 of file compile.c.

◆ ADD_CALL_RECEIVER

#define ADD_CALL_RECEIVER (   seq,
  line 
)    ADD_INSN((seq), (line), putself)

Definition at line 231 of file compile.c.

◆ ADD_CALL_WITH_BLOCK

#define ADD_CALL_WITH_BLOCK (   seq,
  line,
  id,
  argc,
  block 
)    ADD_SEND_R((seq), (line), (id), (argc), (block), (VALUE)INT2FIX(VM_CALL_FCALL), NULL)

Definition at line 237 of file compile.c.

◆ ADD_CATCH_ENTRY

#define ADD_CATCH_ENTRY (   type,
  ls,
  le,
  iseqv,
  lc 
)
Value:
do { \
VALUE _e = rb_ary_new3(5, (type), \
(VALUE)(ls) | 1, (VALUE)(le) | 1, \
(VALUE)(iseqv), (VALUE)(lc) | 1); \
LABEL_UNREMOVABLE(ls); \
LABEL_UNREMOVABLE(le); \
LABEL_UNREMOVABLE(lc); \
rb_ary_push(ISEQ_COMPILE_DATA(iseq)->catch_table_ary, freeze_hide_obj(_e)); \
} while (0)
#define le(x, y)
Definition: time.c:75
unsigned long VALUE
Definition: ruby.h:85
#define rb_ary_new3
Definition: intern.h:91
#define ISEQ_COMPILE_DATA(iseq)
Definition: iseq.h:80

Definition at line 326 of file compile.c.

◆ ADD_GETLOCAL

#define ADD_GETLOCAL (   seq,
  line,
  idx,
  level 
)
Value:
do { \
ADD_INSN2((seq), (line), getlocal, INT2FIX((idx) + VM_ENV_DATA_SIZE - 1), INT2FIX(level)); \
} while (0)
#define level
#define VM_ENV_DATA_SIZE
Definition: vm_core.h:1047
#define INT2FIX(i)
Definition: ruby.h:232

Definition at line 301 of file compile.c.

◆ ADD_INSN

#define ADD_INSN (   seq,
  line,
  insn 
)    ADD_ELEM((seq), (LINK_ELEMENT *) new_insn_body(iseq, (line), BIN(insn), 0))

Definition at line 191 of file compile.c.

◆ ADD_INSN1

#define ADD_INSN1 (   seq,
  line,
  insn,
  op1 
)
Value:
ADD_ELEM((seq), (LINK_ELEMENT *) \
new_insn_body(iseq, (line), BIN(insn), 1, (VALUE)(op1)))
unsigned long VALUE
Definition: ruby.h:85

Definition at line 199 of file compile.c.

◆ ADD_INSN2

#define ADD_INSN2 (   seq,
  line,
  insn,
  op1,
  op2 
)
Value:
ADD_ELEM((seq), (LINK_ELEMENT *) \
new_insn_body(iseq, (line), BIN(insn), 2, (VALUE)(op1), (VALUE)(op2)))
unsigned long VALUE
Definition: ruby.h:85

Definition at line 213 of file compile.c.

◆ ADD_INSN3

#define ADD_INSN3 (   seq,
  line,
  insn,
  op1,
  op2,
  op3 
)
Value:
ADD_ELEM((seq), (LINK_ELEMENT *) \
new_insn_body(iseq, (line), BIN(insn), 3, (VALUE)(op1), (VALUE)(op2), (VALUE)(op3)))
unsigned long VALUE
Definition: ruby.h:85

Definition at line 217 of file compile.c.

◆ ADD_INSNL

#define ADD_INSNL (   seq,
  line,
  insn,
  label 
)    (ADD_INSN1(seq, line, insn, label), LABEL_REF(label))

Definition at line 211 of file compile.c.

◆ ADD_LABEL

#define ADD_LABEL (   seq,
  label 
)    ADD_ELEM((seq), (LINK_ELEMENT *) (label))

Definition at line 312 of file compile.c.

◆ ADD_SEND

#define ADD_SEND (   seq,
  line,
  id,
  argc 
)    ADD_SEND_R((seq), (line), (id), (argc), NULL, (VALUE)INT2FIX(0), NULL)

Definition at line 222 of file compile.c.

◆ ADD_SEND_R

#define ADD_SEND_R (   seq,
  line,
  id,
  argc,
  block,
  flag,
  keywords 
)    ADD_ELEM((seq), (LINK_ELEMENT *) new_insn_send(iseq, (line), (id), (VALUE)(argc), (block), (VALUE)(flag), (keywords)))

Definition at line 240 of file compile.c.

◆ ADD_SEND_WITH_BLOCK

#define ADD_SEND_WITH_BLOCK (   seq,
  line,
  id,
  argc,
  block 
)    ADD_SEND_R((seq), (line), (id), (argc), (block), (VALUE)INT2FIX(0), NULL)

Definition at line 228 of file compile.c.

◆ ADD_SEND_WITH_FLAG

#define ADD_SEND_WITH_FLAG (   seq,
  line,
  id,
  argc,
  flag 
)    ADD_SEND_R((seq), (line), (id), (argc), NULL, (VALUE)(flag), NULL)

Definition at line 225 of file compile.c.

◆ ADD_SEQ

#define ADD_SEQ (   seq1,
  seq2 
)    APPEND_LIST((seq1), (seq2))

Definition at line 187 of file compile.c.

◆ ADD_SETLOCAL

#define ADD_SETLOCAL (   seq,
  line,
  idx,
  level 
)
Value:
do { \
ADD_INSN2((seq), (line), setlocal, INT2FIX((idx) + VM_ENV_DATA_SIZE - 1), INT2FIX(level)); \
} while (0)
#define level
#define VM_ENV_DATA_SIZE
Definition: vm_core.h:1047
#define INT2FIX(i)
Definition: ruby.h:232

Definition at line 306 of file compile.c.

◆ ADD_TRACE

#define ADD_TRACE (   seq,
  line,
  event 
)
Value:
do { \
if (ISEQ_COMPILE_DATA(iseq)->option->trace_instruction) { \
ADD_INSN1((seq), (line), trace, INT2FIX(event)); \
} \
} while (0)
#define INT2FIX(i)
Definition: ruby.h:232
#define ISEQ_COMPILE_DATA(iseq)
Definition: iseq.h:80

Definition at line 294 of file compile.c.

◆ ADD_TRACE_BRANCH_COVERAGE

#define ADD_TRACE_BRANCH_COVERAGE (   seq,
  line,
  type,
  branches 
)
Value:
do { \
if (ISEQ_COVERAGE(iseq) && \
(line) > 0) { \
VALUE counters = RARRAY_AREF(ISEQ_BRANCH_COVERAGE(iseq), 1); \
long counter_idx = RARRAY_LEN(counters); \
rb_ary_push(counters, INT2FIX(0)); \
rb_ary_push(branches, ID2SYM(rb_intern(type))); \
rb_ary_push(branches, INT2FIX(line)); \
rb_ary_push(branches, INT2FIX(counter_idx)); \
ADD_INSN2((seq), (line), trace2, INT2FIX(RUBY_EVENT_COVERAGE), INT2FIX(counter_idx * 16 + COVERAGE_INDEX_BRANCHES)); \
} \
} while (0)
#define RARRAY_LEN(a)
Definition: ruby.h:1019
#define COVERAGE_INDEX_BRANCHES
Definition: internal.h:1695
#define ISEQ_COVERAGE(iseq)
Definition: iseq.h:48
#define ISEQ_BRANCH_COVERAGE(iseq)
Definition: iseq.h:51
#define rb_intern(str)
#define INT2FIX(i)
Definition: ruby.h:232
#define RARRAY_AREF(a, i)
Definition: ruby.h:1033
#define RUBY_EVENT_COVERAGE
Definition: ruby.h:2100
#define ID2SYM(x)
Definition: ruby.h:383

Definition at line 266 of file compile.c.

◆ ADD_TRACE_LINE_COVERAGE

#define ADD_TRACE_LINE_COVERAGE (   seq,
  line 
)
Value:
do { \
if (ISEQ_COVERAGE(iseq) && \
ISEQ_LINE_COVERAGE(iseq) && \
(line) > 0 && \
(line) != ISEQ_COMPILE_DATA(iseq)->last_coverable_line) { \
RARRAY_ASET(ISEQ_LINE_COVERAGE(iseq), (line) - 1, INT2FIX(0)); \
ISEQ_COMPILE_DATA(iseq)->last_coverable_line = (line); \
ADD_INSN2((seq), (line), trace2, INT2FIX(RUBY_EVENT_COVERAGE), INT2FIX(COVERAGE_INDEX_LINES)); \
} \
} while (0)
#define ISEQ_COVERAGE(iseq)
Definition: iseq.h:48
#define COVERAGE_INDEX_LINES
Definition: internal.h:1694
#define ISEQ_LINE_COVERAGE(iseq)
Definition: iseq.h:50
#define INT2FIX(i)
Definition: ruby.h:232
#define RUBY_EVENT_COVERAGE
Definition: ruby.h:2100
#define ISEQ_COMPILE_DATA(iseq)
Definition: iseq.h:80

Definition at line 243 of file compile.c.

◆ ADD_TRACE_METHOD_COVERAGE

#define ADD_TRACE_METHOD_COVERAGE (   seq,
  line,
  method_name 
)
Value:
do { \
if (ISEQ_COVERAGE(iseq) && \
(line) > 0) { \
VALUE methods = ISEQ_METHOD_COVERAGE(iseq); \
long counter_idx = RARRAY_LEN(methods) / 3; \
rb_ary_push(methods, ID2SYM(method_name)); \
rb_ary_push(methods, INT2FIX(line)); \
rb_ary_push(methods, INT2FIX(0)); \
ADD_INSN2((seq), (line), trace2, INT2FIX(RUBY_EVENT_COVERAGE), INT2FIX(counter_idx * 16 + COVERAGE_INDEX_METHODS)); \
} \
} while (0)
#define RARRAY_LEN(a)
Definition: ruby.h:1019
#define ISEQ_COVERAGE(iseq)
Definition: iseq.h:48
#define INT2FIX(i)
Definition: ruby.h:232
#define RUBY_EVENT_COVERAGE
Definition: ruby.h:2100
#define ID2SYM(x)
Definition: ruby.h:383
#define ISEQ_METHOD_COVERAGE(iseq)
Definition: iseq.h:52
#define COVERAGE_INDEX_METHODS
Definition: internal.h:1696

Definition at line 280 of file compile.c.

◆ APPEND_LABEL

#define APPEND_LABEL (   seq,
  before,
  label 
)    APPEND_ELEM((seq), (before), (LINK_ELEMENT *) (label))

Definition at line 315 of file compile.c.

◆ BADINSN_DUMP

#define BADINSN_DUMP (   anchor,
  list,
  dest 
)    dump_disasm_list_with_cursor(&anchor->anchor, list, dest)

Definition at line 1614 of file compile.c.

◆ BADINSN_ERROR

#define BADINSN_ERROR
Value:
(xfree(generated_iseq), \
xfree(line_info_table), \
BADINSN_DUMP(anchor, list, NULL), \
COMPILE_ERROR)
struct rb_encoding_entry * list
Definition: encoding.c:55
void void xfree(void *)
#define NULL
Definition: _sdbm.c:102

Definition at line 1617 of file compile.c.

◆ BEFORE_RETURN [1/2]

#define BEFORE_RETURN

Definition at line 443 of file compile.c.

◆ BEFORE_RETURN [2/2]

#define BEFORE_RETURN   debug_node_end()

Definition at line 443 of file compile.c.

◆ CHECK

#define CHECK (   sub)    if (!(sub)) {BEFORE_RETURN;return COMPILE_NG;}

Definition at line 442 of file compile.c.

◆ CHECK_ARRAY

#define CHECK_ARRAY (   v)    rb_convert_type_with_id((v), T_ARRAY, "Array", idTo_ary)

Definition at line 7300 of file compile.c.

◆ CHECK_SYMBOL

#define CHECK_SYMBOL (   v)    rb_convert_type_with_id((v), T_SYMBOL, "Symbol", idTo_sym)

Definition at line 7301 of file compile.c.

Referenced by rb_iseq_build_from_ary().

◆ COMPILE

#define COMPILE (   anchor,
  desc,
  node 
)
Value:
(debug_compile("== " desc "\n", \
iseq_compile_each(iseq, (anchor), (node), 0)))
#define debug_compile(msg, v)
Definition: compile.c:171

Definition at line 337 of file compile.c.

Referenced by rb_iseq_compile_node().

◆ COMPILE_

#define COMPILE_ (   anchor,
  desc,
  node,
  popped 
)
Value:
(debug_compile("== " desc "\n", \
iseq_compile_each(iseq, (anchor), (node), (popped))))
#define debug_compile(msg, v)
Definition: compile.c:171

Definition at line 347 of file compile.c.

◆ compile_debug

#define compile_debug   CPDEBUG

Definition at line 117 of file compile.c.

◆ COMPILE_ERROR

#define COMPILE_ERROR   append_compile_error

Definition at line 407 of file compile.c.

◆ COMPILE_NG

#define COMPILE_NG   0

Definition at line 440 of file compile.c.

◆ COMPILE_OK

#define COMPILE_OK   1

Definition at line 439 of file compile.c.

Referenced by rb_iseq_translate_threaded_code().

◆ COMPILE_POPPED

#define COMPILE_POPPED (   anchor,
  desc,
  node 
)
Value:
(debug_compile("== " desc "\n", \
iseq_compile_each(iseq, (anchor), (node), 1)))
#define debug_compile(msg, v)
Definition: compile.c:171

Definition at line 342 of file compile.c.

◆ COMPILE_RECV

#define COMPILE_RECV (   anchor,
  desc,
  node 
)
Value:
(private_recv_p(node) ? \
(ADD_INSN(anchor, nd_line(node), putself), VM_CALL_FCALL) : \
(COMPILE(anchor, desc, node->nd_recv), 0))
#define VM_CALL_FCALL
Definition: vm_core.h:964
#define nd_line(n)
Definition: node.h:278
#define ADD_INSN(seq, line, insn)
Definition: compile.c:191
#define COMPILE(anchor, desc, node)
Definition: compile.c:337
#define private_recv_p(node)
Definition: compile.c:3771

Definition at line 351 of file compile.c.

◆ CPDEBUG

#define CPDEBUG   0

debug function(macro) interface depend on CPDEBUG if it is less than 0, runtime option is in effect.

debug level: 0: no debug output 1: show node type 2: show node important parameters ... 5: show other parameters 10: show every AST array

Definition at line 113 of file compile.c.

◆ debug_compile

#define debug_compile (   msg,
 
)    (v)

Definition at line 171 of file compile.c.

◆ debug_list

#define debug_list (   anc)    ((void)0)

Definition at line 1049 of file compile.c.

◆ debug_node_end

#define debug_node_end ( )    ((void)0)

Definition at line 162 of file compile.c.

◆ debug_node_start

#define debug_node_start (   node)    ((void)0)

Definition at line 161 of file compile.c.

◆ debugi

#define debugi (   header,
  id 
)    ((void)0)

Definition at line 156 of file compile.c.

◆ debugp

#define debugp (   header,
  value 
)    ((void)0)

Definition at line 157 of file compile.c.

◆ debugp_param

#define debugp_param (   header,
  value 
)    ((void)0)

Definition at line 160 of file compile.c.

◆ debugp_verbose

#define debugp_verbose (   header,
  value 
)    ((void)0)

Definition at line 158 of file compile.c.

◆ debugp_verbose_node

#define debugp_verbose_node (   header,
  value 
)    ((void)0)

Definition at line 159 of file compile.c.

◆ debugs

#define debugs   if(0)printf

Definition at line 170 of file compile.c.

◆ DECL_ANCHOR

#define DECL_ANCHOR (   name)    LINK_ANCHOR name[1] = {{{0,},}}

Definition at line 447 of file compile.c.

Referenced by rb_iseq_build_from_ary(), and rb_iseq_compile_node().

◆ DECL_BRANCH_BASE

#define DECL_BRANCH_BASE (   branches,
  line,
  type 
)
Value:
do { \
if (ISEQ_COVERAGE(iseq) && \
(line) > 0) { \
VALUE structure = RARRAY_AREF(ISEQ_BRANCH_COVERAGE(iseq), 0); \
branches = rb_ary_tmp_new(0); \
rb_ary_push(structure, branches); \
rb_ary_push(branches, ID2SYM(rb_intern(type))); \
rb_ary_push(branches, INT2FIX(line)); \
} \
} while (0)
VALUE rb_ary_tmp_new(long capa)
Definition: array.c:544
#define ISEQ_COVERAGE(iseq)
Definition: iseq.h:48
#define ISEQ_BRANCH_COVERAGE(iseq)
Definition: iseq.h:51
#define rb_intern(str)
#define INT2FIX(i)
Definition: ruby.h:232
#define RARRAY_AREF(a, i)
Definition: ruby.h:1033
#define ID2SYM(x)
Definition: ruby.h:383

Definition at line 254 of file compile.c.

◆ ERROR_ARGS

#define ERROR_ARGS   ERROR_ARGS_AT(node)

Definition at line 410 of file compile.c.

◆ ERROR_ARGS_AT

#define ERROR_ARGS_AT (   n)    iseq, nd_line(n),

Definition at line 409 of file compile.c.

◆ EXPECT_NODE

#define EXPECT_NODE (   prefix,
  node,
  ndtype,
  errval 
)
Value:
do { \
NODE *error_node = (node); \
enum node_type error_type = nd_type(error_node); \
if (error_type != (ndtype)) { \
COMPILE_ERROR(ERROR_ARGS_AT(error_node) \
prefix ": " #ndtype " is expected, but %s", \
ruby_node_name(error_type)); \
return errval; \
} \
} while (0)
node_type
Definition: node.h:22
#define nd_type(n)
Definition: node.h:272
const char * ruby_node_name(int node)
Definition: iseq.c:1767
#define ERROR_ARGS_AT(n)
Definition: compile.c:409

Definition at line 412 of file compile.c.

◆ EXPECT_NODE_NONULL

#define EXPECT_NODE_NONULL (   prefix,
  parent,
  ndtype,
  errval 
)
Value:
do { \
COMPILE_ERROR(ERROR_ARGS_AT(parent) \
prefix ": must be " #ndtype ", but 0"); \
return errval; \
} while (0)
#define ERROR_ARGS_AT(n)
Definition: compile.c:409

Definition at line 424 of file compile.c.

◆ FIXNUM_INC

#define FIXNUM_INC (   n,
 
)    ((n)+(INT2FIX(i)&~FIXNUM_FLAG))

Definition at line 34 of file compile.c.

◆ FIXNUM_OR

#define FIXNUM_OR (   n,
 
)    ((n)|INT2FIX(i))

Definition at line 35 of file compile.c.

◆ IBF_OBJBODY

#define IBF_OBJBODY (   type,
  offset 
)    (type *)(load->buff + sizeof(struct ibf_object_header) + (offset))

Definition at line 8396 of file compile.c.

◆ IBF_OBJECT_INTERNAL

#define IBF_OBJECT_INTERNAL   FL_PROMOTED0

Definition at line 8328 of file compile.c.

◆ IBF_OBJHEADER

#define IBF_OBJHEADER (   offset)    (struct ibf_object_header *)(load->buff + (offset))

Definition at line 8395 of file compile.c.

◆ IBF_OFFSET

#define IBF_OFFSET (   ptr)    ((ibf_offset_t)(VALUE)(ptr))

Definition at line 7629 of file compile.c.

◆ IBF_R

#define IBF_R (   val,
  type,
 
)    (type *)ibf_load_alloc(load, IBF_OFFSET(val), sizeof(type) * (n))

Definition at line 7713 of file compile.c.

◆ IBF_W

#define IBF_W (   b,
  type,
 
)    (type *)(VALUE)ibf_dump_write(dump, (b), sizeof(type) * (n))

Definition at line 7710 of file compile.c.

◆ IBF_WP

#define IBF_WP (   b,
  type,
 
)    ibf_dump_write(dump, (b), sizeof(type) * (n))

Definition at line 7712 of file compile.c.

◆ IBF_WV

#define IBF_WV (   variable)    ibf_dump_write(dump, &(variable), sizeof(variable))

Definition at line 7711 of file compile.c.

◆ INIT_ANCHOR

#define INIT_ANCHOR (   name)    (name->last = &name->anchor)

Definition at line 449 of file compile.c.

Referenced by rb_iseq_build_from_ary(), and rb_iseq_compile_node().

◆ INSERT_BEFORE_INSN

#define INSERT_BEFORE_INSN (   prev,
  line,
  insn 
)    INSERT_ELEM_PREV(&(prev)->link, (LINK_ELEMENT *) new_insn_body(iseq, (line), BIN(insn), 0))

Definition at line 195 of file compile.c.

◆ INSERT_BEFORE_INSN1

#define INSERT_BEFORE_INSN1 (   prev,
  line,
  insn,
  op1 
)
Value:
INSERT_ELEM_PREV(&(prev)->link, (LINK_ELEMENT *) \
new_insn_body(iseq, (line), BIN(insn), 1, (VALUE)(op1)))
int link(const char *, const char *)
Definition: win32.c:4925
unsigned long VALUE
Definition: ruby.h:85

Definition at line 204 of file compile.c.

◆ INSN_OF

#define INSN_OF (   insn)    (((INSN*)(insn))->insn_id)

Definition at line 359 of file compile.c.

◆ INT_PARAM [1/2]

#define INT_PARAM (   F)    int_param(&iseq->body->param.F, params, SYM(F))

Referenced by rb_iseq_build_from_ary().

◆ INT_PARAM [2/2]

#define INT_PARAM (   F)    F = (int_param(&x, misc, SYM(F)) ? (unsigned int)x : 0)

◆ IS_ADJUST

#define IS_ADJUST (   link)    ((link)->type == ISEQ_ELEMENT_ADJUST)

Definition at line 364 of file compile.c.

◆ IS_INSN

#define IS_INSN (   link)    ((link)->type == ISEQ_ELEMENT_INSN)

Definition at line 362 of file compile.c.

◆ IS_INSN_ID

#define IS_INSN_ID (   iobj,
  insn 
)    (INSN_OF(iobj) == BIN(insn))

Definition at line 365 of file compile.c.

◆ IS_LABEL

#define IS_LABEL (   link)    ((link)->type == ISEQ_ELEMENT_LABEL)

Definition at line 363 of file compile.c.

◆ IS_NEXT_INSN_ID

#define IS_NEXT_INSN_ID (   link,
  insn 
)    ((link)->next && IS_INSN((link)->next) && IS_INSN_ID((link)->next, insn))

Definition at line 366 of file compile.c.

◆ IS_TRACE_LINE

#define IS_TRACE_LINE (   insn)
Value:
(IS_INSN_ID(insn, trace) && \
OPERAND_AT(insn, 0) == INT2FIX(RUBY_EVENT_LINE))
#define IS_INSN_ID(iobj, insn)
Definition: compile.c:365
#define RUBY_EVENT_LINE
Definition: ruby.h:2080
#define INT2FIX(i)
Definition: ruby.h:232

◆ ISEQ_ARG

#define ISEQ_ARG

Definition at line 470 of file compile.c.

◆ ISEQ_ARG_DECLARE

#define ISEQ_ARG_DECLARE

Definition at line 471 of file compile.c.

◆ ISEQ_TYPE_ONCE_GUARD

#define ISEQ_TYPE_ONCE_GUARD   ISEQ_TYPE_DEFINED_GUARD

Definition at line 32 of file compile.c.

◆ LABEL_FORMAT

#define LABEL_FORMAT   "<L%03d>"

Definition at line 178 of file compile.c.

◆ LABEL_REF

#define LABEL_REF (   label)    ((label)->refcnt++)

Definition at line 208 of file compile.c.

◆ LABEL_UNREMOVABLE

#define LABEL_UNREMOVABLE (   label)    ((label) ? (LABEL_REF(label), (label)->unremovable=1) : 0)

Definition at line 324 of file compile.c.

◆ LVAR_ERRINFO

#define LVAR_ERRINFO   (1)

Definition at line 174 of file compile.c.

◆ MEMORY

#define MEMORY (   v)
Value:
{ \
int i; \
if (memindex == memsize) return 0; \
for (i=0; i<memindex; i++) { \
if (mem[i] == (v)) return 0; \
} \
mem[memindex++] = (v); \
}

◆ NEW_CHILD_ISEQ

#define NEW_CHILD_ISEQ (   node,
  name,
  type,
  line_no 
)    new_child_iseq(iseq, (node), rb_fstring(name), iseq, (type), (line_no))

Definition at line 183 of file compile.c.

◆ NEW_ISEQ

#define NEW_ISEQ (   node,
  name,
  type,
  line_no 
)    new_child_iseq(iseq, (node), rb_fstring(name), 0, (type), (line_no))

Definition at line 180 of file compile.c.

◆ NEW_LABEL

#define NEW_LABEL (   l)    new_label_body(iseq, (l))

Definition at line 177 of file compile.c.

◆ OPERAND_AT

#define OPERAND_AT (   insn,
  idx 
)    (((INSN*)(insn))->operands[(idx)])

Definition at line 356 of file compile.c.

◆ PADDING_SIZE_MAX

#define PADDING_SIZE_MAX   0

Definition at line 801 of file compile.c.

◆ private_recv_p

#define private_recv_p (   node)    (nd_type((node)->nd_recv) == NODE_SELF)

Definition at line 3771 of file compile.c.

◆ rb_intern

#define rb_intern (   str)    rb_intern_const(str)

Referenced by rb_iseq_build_from_ary().

◆ RUBY_UNTYPED_DATA_WARNING

#define RUBY_UNTYPED_DATA_WARNING   0

Definition at line 30 of file compile.c.

◆ SP_INSN

#define SP_INSN (   opt)    insn_set_specialized_instruction(iseq, iobj, BIN(opt_##opt))

◆ SYM [1/2]

#define SYM (   s)    ID2SYM(rb_intern(#s))

Referenced by rb_iseq_build_from_ary().

◆ SYM [2/2]

#define SYM (   s)    ID2SYM(rb_intern(#s))

◆ UNKNOWN_NODE

#define UNKNOWN_NODE (   prefix,
  node,
  errval 
)
Value:
do { \
NODE *error_node = (node); \
COMPILE_ERROR(ERROR_ARGS_AT(error_node) prefix ": unknown node (%s)", \
ruby_node_name(nd_type(error_node))); \
return errval; \
} while (0)
#define nd_type(n)
Definition: node.h:272
const char * ruby_node_name(int node)
Definition: iseq.c:1767
#define ERROR_ARGS_AT(n)
Definition: compile.c:409

Definition at line 431 of file compile.c.

◆ USE_INSN_STACK_INCREASE

#define USE_INSN_STACK_INCREASE   1

Definition at line 17 of file compile.c.

Typedef Documentation

◆ ADJUST

typedef struct iseq_adjust_data ADJUST

◆ ibf_dump_object_function

typedef void(* ibf_dump_object_function) (struct ibf_dump *dump, VALUE obj)

Definition at line 8726 of file compile.c.

◆ ibf_load_object_function

typedef VALUE(* ibf_load_object_function) (const struct ibf_load *load, const struct ibf_object_header *header, ibf_offset_t)

Definition at line 8793 of file compile.c.

◆ ibf_offset_t

typedef unsigned int ibf_offset_t

Definition at line 7628 of file compile.c.

◆ INSN

typedef struct iseq_insn_data INSN

◆ LABEL

typedef struct iseq_label_data LABEL

◆ LINK_ANCHOR

typedef struct iseq_link_anchor LINK_ANCHOR

◆ LINK_ELEMENT

Enumeration Type Documentation

◆ compile_array_type_t

Enumerator
COMPILE_ARRAY_TYPE_ARRAY 
COMPILE_ARRAY_TYPE_HASH 
COMPILE_ARRAY_TYPE_ARGS 

Definition at line 3235 of file compile.c.

◆ ibf_object_class_index

Enumerator
IBF_OBJECT_CLASS_OBJECT 
IBF_OBJECT_CLASS_ARRAY 
IBF_OBJECT_CLASS_STANDARD_ERROR 

Definition at line 8343 of file compile.c.

◆ ibf_object_data_type

Enumerator
IBF_OBJECT_DATA_ENCODING 

Definition at line 8383 of file compile.c.

◆ LABEL_RESCUE_TYPE

Enumerator
LABEL_RESCUE_NONE 
LABEL_RESCUE_BEG 
LABEL_RESCUE_END 
LABEL_RESCUE_TYPE_MAX 

Definition at line 53 of file compile.c.

Function Documentation

◆ ibf_load_iseq_complete()

void ibf_load_iseq_complete ( rb_iseq_t iseq)

◆ iseq_alloc()

rb_iseq_t* iseq_alloc ( void  )

Referenced by rb_iseq_new_with_opt().

◆ iseq_ibf_dump()

VALUE iseq_ibf_dump ( const rb_iseq_t iseq,
VALUE  opt 
)

◆ iseq_ibf_load()

const rb_iseq_t* iseq_ibf_load ( VALUE  str)

Definition at line 9112 of file compile.c.

References ibf_load::iseq, and TypedData_Make_Struct.

◆ iseq_ibf_load_extra_data()

VALUE iseq_ibf_load_extra_data ( VALUE  str)

Definition at line 9126 of file compile.c.

References TypedData_Make_Struct.

◆ rb_dvar_defined()

int rb_dvar_defined ( ID  id,
const struct rb_block base_block 
)

Definition at line 7492 of file compile.c.

◆ rb_insns_name()

const char* rb_insns_name ( int  i)

Definition at line 6970 of file compile.c.

◆ rb_insns_name_array()

VALUE rb_insns_name_array ( void  )

Definition at line 6976 of file compile.c.

References rb_ary_new(), rb_ary_push(), rb_fstring_cstr(), and rb_obj_freeze().

◆ rb_iseq_build_from_ary()

void rb_iseq_build_from_ary ( rb_iseq_t iseq,
VALUE  misc,
VALUE  locals,
VALUE  params,
VALUE  exception,
VALUE  body 
)

◆ rb_iseq_compile_node()

VALUE rb_iseq_compile_node ( rb_iseq_t iseq,
NODE node 
)

Definition at line 611 of file compile.c.

References COMPILE, DECL_ANCHOR, and INIT_ANCHOR.

◆ rb_iseq_original_iseq()

VALUE* rb_iseq_original_iseq ( const rb_iseq_t iseq)

Definition at line 753 of file compile.c.

Referenced by rb_vmdebug_debug_print_pre().

◆ rb_iseq_translate_threaded_code()

int rb_iseq_translate_threaded_code ( rb_iseq_t iseq)

◆ rb_local_defined()

int rb_local_defined ( ID  id,
const struct rb_block base_block 
)

Definition at line 7517 of file compile.c.

◆ rb_method_for_self_aref()

const rb_iseq_t* rb_method_for_self_aref ( VALUE  name,
VALUE  arg,
rb_insn_func_t  func 
)

Definition at line 7612 of file compile.c.

◆ rb_method_for_self_aset()

const rb_iseq_t* rb_method_for_self_aset ( VALUE  name,
VALUE  arg,
rb_insn_func_t  func 
)

Definition at line 7621 of file compile.c.