2006-12-31 10:02:22 -05:00
|
|
|
/**********************************************************************
|
|
|
|
|
|
|
|
compile.h -
|
|
|
|
|
|
|
|
$Author$
|
|
|
|
$Date$
|
|
|
|
created at: 04/01/01 23:36:57 JST
|
|
|
|
|
|
|
|
Copyright (C) 2004-2006 Koichi Sasada
|
|
|
|
|
|
|
|
**********************************************************************/
|
|
|
|
|
|
|
|
#ifndef _COMPILER_H_INCLUDED_
|
|
|
|
#define _COMPILER_H_INCLUDED_
|
|
|
|
|
|
|
|
#include "version.h"
|
|
|
|
|
|
|
|
#if YARVDEBUG > CPDEBUG
|
|
|
|
#undef CPDEBUG
|
|
|
|
#define CPDEBUG YARVDEBUG
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* */
|
|
|
|
/**
|
|
|
|
* debug function(macro) interface depend on CPDEBUG
|
|
|
|
*
|
|
|
|
* debug level:
|
|
|
|
* 0: no debug output
|
|
|
|
* 1: show node type
|
|
|
|
* 2: show node important parameters
|
|
|
|
* ...
|
|
|
|
* 5: show other parameters
|
|
|
|
* 10: show every AST array
|
|
|
|
*/
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
#undef CPDEBUG
|
|
|
|
#define CPDEBUG 2
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if CPDEBUG > 0
|
|
|
|
|
|
|
|
#define debugp(header, value) \
|
* parse.y, node.h, compile.c: change node tree structure. a purpose
of this change is to unify argument structure of method and block.
this change prohibits duplicate block parameter name.
new argument infromation:
NODE_ARGS [m: int, o: NODE_OPT_ARG, ->]
NODE_ARGS_AUX [r: ID, b: ID, ->]
NODE_ARGS_AUX [Pst: id, Plen: int, init: NODE*]
optarg information:
NODE_OPT_ARGS [idx, expr, ->]
* vm_macro.def: ditto.
* gc.c: ditto.
* iseq.c: ditto.
* compile.h: fix debug function name.
* test/ripper/test_scanner_events.rb: |_,_,foo| -> |_1,_2,foo|
* test/ruby/test_lambda.rb: disalbe test temporarily.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11840 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-23 21:07:05 -05:00
|
|
|
(ruby_debug_indent(0, CPDEBUG, gl_node_level * 2), \
|
* this commit is a result of refactoring. only renaming functions,
moving definitions place, add/remove prototypes, deleting
unused variables and removing yarv.h.
This commit doesn't change any behavior of ruby/vm.
* yarv.h, common.mk: remove yarv.h (contents are moved to yarvcore.h).
* error.c, eval_intern.h: include yarvcore.h instead yarv.h
* rename some functions:
* debug.[ch]: debug_*() -> ruby_debug_*()
* iseq.c: iseq_*() -> rb_iseq_*(), ruby_iseq_disasm()
* iseq.c: node_name() -> ruby_node_name()
* vm.c: yarv_check_redefinition_opt_method() ->
rb_vm_check_redefinition_opt_method()
* some refactoring with checking -Wall.
* array.c: remove rb_ary_ptr() (unused) and remove unused
local variables.
* object.c: add a prototype of rb_mod_module_exec().
* eval_intern.h (ruby_cref): set it inline.
* eval_load.c (rb_load), yarvcore.c: yarv_load() -> rb_load_internal().
* parse.y: add a prototype of rb_parse_in_eval() (in eval.c).
* process.c: add a prototype of rb_thread_stop_timer_thread() (in thread.c).
* thread.c: remove raw_gets() function (unused) and fix some format
mismatch (format mismatchs have remained yet. this is todo).
* thread.c (rb_thread_wait_fd_rw): fix typo on label name.
* thread_pthread.ci: comment out codes with USE_THREAD_CACHE.
* vm.c (rb_svar, rb_backref_get, rb_backref_get,
rb_lastline_get, rb_lastline_set) : moved from yarvcore.c.
* vm.c (yarv_init_redefined_flag): add a prototype and rename
yarv_opt_method_table to vm_opt_method_table.
* vm.c (rb_thread_eval): moved from yarvcore.c.
* yarvcore.c: remove unused global variables and fix to use nsdr().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11652 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 20:25:05 -05:00
|
|
|
ruby_debug_value(0, CPDEBUG, header, value))
|
2006-12-31 10:02:22 -05:00
|
|
|
|
|
|
|
#define debugi(header, id) \
|
* parse.y, node.h, compile.c: change node tree structure. a purpose
of this change is to unify argument structure of method and block.
this change prohibits duplicate block parameter name.
new argument infromation:
NODE_ARGS [m: int, o: NODE_OPT_ARG, ->]
NODE_ARGS_AUX [r: ID, b: ID, ->]
NODE_ARGS_AUX [Pst: id, Plen: int, init: NODE*]
optarg information:
NODE_OPT_ARGS [idx, expr, ->]
* vm_macro.def: ditto.
* gc.c: ditto.
* iseq.c: ditto.
* compile.h: fix debug function name.
* test/ripper/test_scanner_events.rb: |_,_,foo| -> |_1,_2,foo|
* test/ruby/test_lambda.rb: disalbe test temporarily.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11840 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-23 21:07:05 -05:00
|
|
|
(ruby_debug_indent(0, CPDEBUG, gl_node_level * 2), \
|
|
|
|
ruby_debug_id(0, CPDEBUG, header, id))
|
2006-12-31 10:02:22 -05:00
|
|
|
|
|
|
|
#define debugp_param(header, value) \
|
* parse.y, node.h, compile.c: change node tree structure. a purpose
of this change is to unify argument structure of method and block.
this change prohibits duplicate block parameter name.
new argument infromation:
NODE_ARGS [m: int, o: NODE_OPT_ARG, ->]
NODE_ARGS_AUX [r: ID, b: ID, ->]
NODE_ARGS_AUX [Pst: id, Plen: int, init: NODE*]
optarg information:
NODE_OPT_ARGS [idx, expr, ->]
* vm_macro.def: ditto.
* gc.c: ditto.
* iseq.c: ditto.
* compile.h: fix debug function name.
* test/ripper/test_scanner_events.rb: |_,_,foo| -> |_1,_2,foo|
* test/ruby/test_lambda.rb: disalbe test temporarily.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11840 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-23 21:07:05 -05:00
|
|
|
(ruby_debug_indent(1, CPDEBUG, gl_node_level * 2), \
|
* this commit is a result of refactoring. only renaming functions,
moving definitions place, add/remove prototypes, deleting
unused variables and removing yarv.h.
This commit doesn't change any behavior of ruby/vm.
* yarv.h, common.mk: remove yarv.h (contents are moved to yarvcore.h).
* error.c, eval_intern.h: include yarvcore.h instead yarv.h
* rename some functions:
* debug.[ch]: debug_*() -> ruby_debug_*()
* iseq.c: iseq_*() -> rb_iseq_*(), ruby_iseq_disasm()
* iseq.c: node_name() -> ruby_node_name()
* vm.c: yarv_check_redefinition_opt_method() ->
rb_vm_check_redefinition_opt_method()
* some refactoring with checking -Wall.
* array.c: remove rb_ary_ptr() (unused) and remove unused
local variables.
* object.c: add a prototype of rb_mod_module_exec().
* eval_intern.h (ruby_cref): set it inline.
* eval_load.c (rb_load), yarvcore.c: yarv_load() -> rb_load_internal().
* parse.y: add a prototype of rb_parse_in_eval() (in eval.c).
* process.c: add a prototype of rb_thread_stop_timer_thread() (in thread.c).
* thread.c: remove raw_gets() function (unused) and fix some format
mismatch (format mismatchs have remained yet. this is todo).
* thread.c (rb_thread_wait_fd_rw): fix typo on label name.
* thread_pthread.ci: comment out codes with USE_THREAD_CACHE.
* vm.c (rb_svar, rb_backref_get, rb_backref_get,
rb_lastline_get, rb_lastline_set) : moved from yarvcore.c.
* vm.c (yarv_init_redefined_flag): add a prototype and rename
yarv_opt_method_table to vm_opt_method_table.
* vm.c (rb_thread_eval): moved from yarvcore.c.
* yarvcore.c: remove unused global variables and fix to use nsdr().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11652 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 20:25:05 -05:00
|
|
|
ruby_debug_value(1, CPDEBUG, header, value))
|
2006-12-31 10:02:22 -05:00
|
|
|
|
|
|
|
#define debugp_verbose(header, value) \
|
* parse.y, node.h, compile.c: change node tree structure. a purpose
of this change is to unify argument structure of method and block.
this change prohibits duplicate block parameter name.
new argument infromation:
NODE_ARGS [m: int, o: NODE_OPT_ARG, ->]
NODE_ARGS_AUX [r: ID, b: ID, ->]
NODE_ARGS_AUX [Pst: id, Plen: int, init: NODE*]
optarg information:
NODE_OPT_ARGS [idx, expr, ->]
* vm_macro.def: ditto.
* gc.c: ditto.
* iseq.c: ditto.
* compile.h: fix debug function name.
* test/ripper/test_scanner_events.rb: |_,_,foo| -> |_1,_2,foo|
* test/ruby/test_lambda.rb: disalbe test temporarily.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11840 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-23 21:07:05 -05:00
|
|
|
(ruby_debug_indent(2, CPDEBUG, gl_node_level * 2), \
|
* this commit is a result of refactoring. only renaming functions,
moving definitions place, add/remove prototypes, deleting
unused variables and removing yarv.h.
This commit doesn't change any behavior of ruby/vm.
* yarv.h, common.mk: remove yarv.h (contents are moved to yarvcore.h).
* error.c, eval_intern.h: include yarvcore.h instead yarv.h
* rename some functions:
* debug.[ch]: debug_*() -> ruby_debug_*()
* iseq.c: iseq_*() -> rb_iseq_*(), ruby_iseq_disasm()
* iseq.c: node_name() -> ruby_node_name()
* vm.c: yarv_check_redefinition_opt_method() ->
rb_vm_check_redefinition_opt_method()
* some refactoring with checking -Wall.
* array.c: remove rb_ary_ptr() (unused) and remove unused
local variables.
* object.c: add a prototype of rb_mod_module_exec().
* eval_intern.h (ruby_cref): set it inline.
* eval_load.c (rb_load), yarvcore.c: yarv_load() -> rb_load_internal().
* parse.y: add a prototype of rb_parse_in_eval() (in eval.c).
* process.c: add a prototype of rb_thread_stop_timer_thread() (in thread.c).
* thread.c: remove raw_gets() function (unused) and fix some format
mismatch (format mismatchs have remained yet. this is todo).
* thread.c (rb_thread_wait_fd_rw): fix typo on label name.
* thread_pthread.ci: comment out codes with USE_THREAD_CACHE.
* vm.c (rb_svar, rb_backref_get, rb_backref_get,
rb_lastline_get, rb_lastline_set) : moved from yarvcore.c.
* vm.c (yarv_init_redefined_flag): add a prototype and rename
yarv_opt_method_table to vm_opt_method_table.
* vm.c (rb_thread_eval): moved from yarvcore.c.
* yarvcore.c: remove unused global variables and fix to use nsdr().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11652 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 20:25:05 -05:00
|
|
|
ruby_debug_value(2, CPDEBUG, header, value))
|
2006-12-31 10:02:22 -05:00
|
|
|
|
|
|
|
#define debugp_verbose_node(header, value) \
|
* parse.y, node.h, compile.c: change node tree structure. a purpose
of this change is to unify argument structure of method and block.
this change prohibits duplicate block parameter name.
new argument infromation:
NODE_ARGS [m: int, o: NODE_OPT_ARG, ->]
NODE_ARGS_AUX [r: ID, b: ID, ->]
NODE_ARGS_AUX [Pst: id, Plen: int, init: NODE*]
optarg information:
NODE_OPT_ARGS [idx, expr, ->]
* vm_macro.def: ditto.
* gc.c: ditto.
* iseq.c: ditto.
* compile.h: fix debug function name.
* test/ripper/test_scanner_events.rb: |_,_,foo| -> |_1,_2,foo|
* test/ruby/test_lambda.rb: disalbe test temporarily.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11840 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-23 21:07:05 -05:00
|
|
|
(ruby_debug_indent(10, CPDEBUG, gl_node_level * 2), \
|
* this commit is a result of refactoring. only renaming functions,
moving definitions place, add/remove prototypes, deleting
unused variables and removing yarv.h.
This commit doesn't change any behavior of ruby/vm.
* yarv.h, common.mk: remove yarv.h (contents are moved to yarvcore.h).
* error.c, eval_intern.h: include yarvcore.h instead yarv.h
* rename some functions:
* debug.[ch]: debug_*() -> ruby_debug_*()
* iseq.c: iseq_*() -> rb_iseq_*(), ruby_iseq_disasm()
* iseq.c: node_name() -> ruby_node_name()
* vm.c: yarv_check_redefinition_opt_method() ->
rb_vm_check_redefinition_opt_method()
* some refactoring with checking -Wall.
* array.c: remove rb_ary_ptr() (unused) and remove unused
local variables.
* object.c: add a prototype of rb_mod_module_exec().
* eval_intern.h (ruby_cref): set it inline.
* eval_load.c (rb_load), yarvcore.c: yarv_load() -> rb_load_internal().
* parse.y: add a prototype of rb_parse_in_eval() (in eval.c).
* process.c: add a prototype of rb_thread_stop_timer_thread() (in thread.c).
* thread.c: remove raw_gets() function (unused) and fix some format
mismatch (format mismatchs have remained yet. this is todo).
* thread.c (rb_thread_wait_fd_rw): fix typo on label name.
* thread_pthread.ci: comment out codes with USE_THREAD_CACHE.
* vm.c (rb_svar, rb_backref_get, rb_backref_get,
rb_lastline_get, rb_lastline_set) : moved from yarvcore.c.
* vm.c (yarv_init_redefined_flag): add a prototype and rename
yarv_opt_method_table to vm_opt_method_table.
* vm.c (rb_thread_eval): moved from yarvcore.c.
* yarvcore.c: remove unused global variables and fix to use nsdr().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11652 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 20:25:05 -05:00
|
|
|
ruby_debug_value(10, CPDEBUG, header, value))
|
2006-12-31 10:02:22 -05:00
|
|
|
|
|
|
|
#define debug_nodeprint(node) \
|
* parse.y, node.h, compile.c: change node tree structure. a purpose
of this change is to unify argument structure of method and block.
this change prohibits duplicate block parameter name.
new argument infromation:
NODE_ARGS [m: int, o: NODE_OPT_ARG, ->]
NODE_ARGS_AUX [r: ID, b: ID, ->]
NODE_ARGS_AUX [Pst: id, Plen: int, init: NODE*]
optarg information:
NODE_OPT_ARGS [idx, expr, ->]
* vm_macro.def: ditto.
* gc.c: ditto.
* iseq.c: ditto.
* compile.h: fix debug function name.
* test/ripper/test_scanner_events.rb: |_,_,foo| -> |_1,_2,foo|
* test/ruby/test_lambda.rb: disalbe test temporarily.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11840 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-23 21:07:05 -05:00
|
|
|
ruby_debug_indent(-1, CPDEBUG, gl_node_level*2); \
|
* this commit is a result of refactoring. only renaming functions,
moving definitions place, add/remove prototypes, deleting
unused variables and removing yarv.h.
This commit doesn't change any behavior of ruby/vm.
* yarv.h, common.mk: remove yarv.h (contents are moved to yarvcore.h).
* error.c, eval_intern.h: include yarvcore.h instead yarv.h
* rename some functions:
* debug.[ch]: debug_*() -> ruby_debug_*()
* iseq.c: iseq_*() -> rb_iseq_*(), ruby_iseq_disasm()
* iseq.c: node_name() -> ruby_node_name()
* vm.c: yarv_check_redefinition_opt_method() ->
rb_vm_check_redefinition_opt_method()
* some refactoring with checking -Wall.
* array.c: remove rb_ary_ptr() (unused) and remove unused
local variables.
* object.c: add a prototype of rb_mod_module_exec().
* eval_intern.h (ruby_cref): set it inline.
* eval_load.c (rb_load), yarvcore.c: yarv_load() -> rb_load_internal().
* parse.y: add a prototype of rb_parse_in_eval() (in eval.c).
* process.c: add a prototype of rb_thread_stop_timer_thread() (in thread.c).
* thread.c: remove raw_gets() function (unused) and fix some format
mismatch (format mismatchs have remained yet. this is todo).
* thread.c (rb_thread_wait_fd_rw): fix typo on label name.
* thread_pthread.ci: comment out codes with USE_THREAD_CACHE.
* vm.c (rb_svar, rb_backref_get, rb_backref_get,
rb_lastline_get, rb_lastline_set) : moved from yarvcore.c.
* vm.c (yarv_init_redefined_flag): add a prototype and rename
yarv_opt_method_table to vm_opt_method_table.
* vm.c (rb_thread_eval): moved from yarvcore.c.
* yarvcore.c: remove unused global variables and fix to use nsdr().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11652 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 20:25:05 -05:00
|
|
|
printf("node: %s (%d)\n", ruby_node_name(nd_type(node)), nd_line(node)); \
|
2006-12-31 10:02:22 -05:00
|
|
|
gl_node_level ++;
|
|
|
|
|
|
|
|
#define debug_nodeprint_close() gl_node_level --;
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
static inline ID
|
|
|
|
r_id(ID id)
|
|
|
|
{
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline VALUE
|
|
|
|
r_value(VALUE value)
|
|
|
|
{
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define debugi(header, id) r_id(id)
|
|
|
|
#define debugp(header, value) r_value(value)
|
|
|
|
#define debugp_verbose(header, value) r_value(value)
|
|
|
|
#define debugp_verbose_node(header, value) r_value(value)
|
|
|
|
#define debugp_param(header, value) r_value(value)
|
|
|
|
#define debug_nodeprint(node)
|
|
|
|
#define debug_nodeprint_close()
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if CPDEBUG > 1
|
* parse.y, node.h, compile.c: change node tree structure. a purpose
of this change is to unify argument structure of method and block.
this change prohibits duplicate block parameter name.
new argument infromation:
NODE_ARGS [m: int, o: NODE_OPT_ARG, ->]
NODE_ARGS_AUX [r: ID, b: ID, ->]
NODE_ARGS_AUX [Pst: id, Plen: int, init: NODE*]
optarg information:
NODE_OPT_ARGS [idx, expr, ->]
* vm_macro.def: ditto.
* gc.c: ditto.
* iseq.c: ditto.
* compile.h: fix debug function name.
* test/ripper/test_scanner_events.rb: |_,_,foo| -> |_1,_2,foo|
* test/ruby/test_lambda.rb: disalbe test temporarily.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11840 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-23 21:07:05 -05:00
|
|
|
#define debugs ruby_debug_indent(-1, CPDEBUG, gl_node_level*2), printf
|
|
|
|
#define debug_compile(msg, v) (ruby_debug_indent(-1, CPDEBUG, gl_node_level*2), printf("%s", msg), (v))
|
2006-12-31 10:02:22 -05:00
|
|
|
#else
|
|
|
|
#define debugs if(0)printf
|
|
|
|
#define debug_compile(msg, v) (v)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/* create new label */
|
|
|
|
#define NEW_LABEL(l) new_label_body(iseq, l)
|
|
|
|
|
|
|
|
#define iseq_filename(iseq) \
|
* blockinlining.c, compile.c, compile.h, error.c, eval.c,
eval_intern.h, eval_jump.h, eval_load.c, eval_method.h,
eval_safe.h, gc.c, insnhelper.h, insns.def, iseq.c, proc.c,
process.c, signal.c, thread.c, thread_pthread.ci, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, vm_macro.def,
yarv.h, yarvcore.h, yarvcore.c: change type and macro names:
* yarv_*_t -> rb_*_t
* yarv_*_struct -> rb_*_struct
* yarv_tag -> rb_vm_tag
* YARV_* -> RUBY_VM_*
* proc.c, vm.c: move functions about env object creation
from proc.c to vm.c.
* proc.c, yarvcore.c: fix rb_cVM initialization place.
* inits.c: change Init_ISeq() order (after Init_VM).
* ruby.h, proc.c: change declaration place of rb_cEnv
from proc.c to ruby.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-06 14:00:03 -05:00
|
|
|
(((rb_iseq_t*)DATA_PTR(iseq))->file_name)
|
2006-12-31 10:02:22 -05:00
|
|
|
|
|
|
|
#define NEW_ISEQVAL(node, name, type) \
|
|
|
|
new_child_iseq(iseq, node, name, 0, type)
|
|
|
|
|
|
|
|
#define NEW_CHILD_ISEQVAL(node, name, type) \
|
|
|
|
new_child_iseq(iseq, node, name, iseq->self, type)
|
|
|
|
|
|
|
|
#define NEW_SPECIAQL_BLOCK_ISEQVAL(iseq, sym) \
|
|
|
|
new_child_iseq(iseq, iseq->node, iseq->name, iseq->parent_iseq, iseq->type, sym)
|
|
|
|
|
|
|
|
/* add instructions */
|
|
|
|
#define ADD_SEQ(seq1, seq2) \
|
|
|
|
APPEND_LIST(seq1, seq2)
|
|
|
|
|
|
|
|
/* add an instruction */
|
|
|
|
#define ADD_INSN(seq, line, insn) \
|
|
|
|
ADD_ELEM(seq, (LINK_ELEMENT *) new_insn_body(iseq, line, BIN(insn), 0))
|
|
|
|
|
|
|
|
/* add an instruction with label operand */
|
|
|
|
#define ADD_INSNL(seq, line, insn, label) \
|
|
|
|
ADD_ELEM(seq, (LINK_ELEMENT *) \
|
|
|
|
new_insn_body(iseq, line, BIN(insn), 1, (VALUE)label))
|
|
|
|
|
|
|
|
/* add an instruction with some operands (1, 2, 3, 5) */
|
|
|
|
#define ADD_INSN1(seq, line, insn, op1) \
|
|
|
|
ADD_ELEM(seq, (LINK_ELEMENT *) \
|
|
|
|
new_insn_body(iseq, line, BIN(insn), 1, (VALUE)op1))
|
|
|
|
|
|
|
|
#define ADD_INSN2(seq, line, insn, op1, op2) \
|
|
|
|
ADD_ELEM(seq, (LINK_ELEMENT *) \
|
|
|
|
new_insn_body(iseq, line, BIN(insn), 2, (VALUE)op1, (VALUE)op2))
|
|
|
|
|
|
|
|
#define ADD_INSN3(seq, line, insn, op1, op2, op3) \
|
|
|
|
ADD_ELEM(seq, (LINK_ELEMENT *) \
|
|
|
|
new_insn_body(iseq, line, BIN(insn), 3, (VALUE)op1, (VALUE)op2, (VALUE)op3))
|
|
|
|
|
|
|
|
/* Specific Insn factory */
|
|
|
|
#define ADD_SEND(seq, line, id, argc) \
|
|
|
|
ADD_SEND_R(seq, line, id, argc, (VALUE)Qfalse, (VALUE)INT2FIX(0))
|
|
|
|
|
2007-01-05 07:00:08 -05:00
|
|
|
#define ADD_CALL_RECEIVER(seq, line) \
|
|
|
|
ADD_INSN(seq, line, putnil)
|
|
|
|
|
2006-12-31 10:02:22 -05:00
|
|
|
#define ADD_CALL(seq, line, id, argc) \
|
|
|
|
ADD_SEND_R(seq, line, id, argc, (VALUE)Qfalse, (VALUE)INT2FIX(VM_CALL_FCALL_BIT))
|
|
|
|
|
2007-01-05 07:00:08 -05:00
|
|
|
#define ADD_CALL_WITH_BLOCK(seq, line, id, argc, block) \
|
|
|
|
ADD_SEND_R(seq, line, id, argc, block, (VALUE)INT2FIX(VM_CALL_FCALL_BIT))
|
|
|
|
|
2006-12-31 10:02:22 -05:00
|
|
|
#define ADD_SEND_R(seq, line, id, argc, block, flag) \
|
|
|
|
ADD_ELEM(seq, (LINK_ELEMENT *) \
|
|
|
|
new_insn_send(iseq, line, \
|
|
|
|
(VALUE)id, (VALUE)argc, (VALUE)block, (VALUE)flag))
|
|
|
|
|
|
|
|
/* add label */
|
|
|
|
#define ADD_LABEL(seq, label) \
|
|
|
|
ADD_ELEM(seq, (LINK_ELEMENT *)label)
|
|
|
|
|
|
|
|
#define ADD_CATCH_ENTRY(type, ls, le, iseqv, lc) \
|
|
|
|
(tmp = rb_ary_new(), \
|
|
|
|
rb_ary_push(tmp, type), \
|
|
|
|
rb_ary_push(tmp, (VALUE) ls | 1), \
|
|
|
|
rb_ary_push(tmp, (VALUE) le | 1), \
|
|
|
|
rb_ary_push(tmp, iseqv), \
|
|
|
|
rb_ary_push(tmp, (VALUE) lc | 1), \
|
|
|
|
rb_ary_push(iseq->compile_data->catch_table_ary, tmp))
|
|
|
|
|
|
|
|
/* compile node */
|
|
|
|
#define COMPILE(anchor, desc, node) \
|
|
|
|
(debug_compile("== " desc "\n", \
|
|
|
|
iseq_compile_each(iseq, anchor, node, 0)))
|
|
|
|
|
|
|
|
/* compile node, this node's value will be poped */
|
|
|
|
#define COMPILE_POPED(anchor, desc, node) \
|
|
|
|
(debug_compile("== " desc "\n", \
|
|
|
|
iseq_compile_each(iseq, anchor, node, 1)))
|
|
|
|
|
|
|
|
/* compile node, which is poped when 'poped' is true */
|
|
|
|
#define COMPILE_(anchor, desc, node, poped) \
|
|
|
|
(debug_compile("== " desc "\n", \
|
|
|
|
iseq_compile_each(iseq, anchor, node, poped)))
|
|
|
|
|
|
|
|
#define OPERAND_AT(insn, idx) \
|
|
|
|
(((INSN*)(insn))->operands[idx])
|
|
|
|
|
|
|
|
#define INSN_OF(insn) \
|
|
|
|
(((INSN*)(insn))->insn_id)
|
|
|
|
|
|
|
|
/* error */
|
|
|
|
#define COMPILE_ERROR(strs) \
|
|
|
|
{ \
|
|
|
|
VALUE tmp = GET_THREAD()->errinfo; \
|
|
|
|
if(CPDEBUG)rb_bug strs; \
|
|
|
|
GET_THREAD()->errinfo = iseq->compile_data->err_info; \
|
|
|
|
rb_compile_error strs; \
|
|
|
|
iseq->compile_data->err_info = GET_THREAD()->errinfo; \
|
|
|
|
GET_THREAD()->errinfo = tmp; \
|
|
|
|
ret = 0; \
|
|
|
|
break; \
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#define COMPILE_OK 1
|
|
|
|
#define COMPILE_NG 0
|
|
|
|
|
|
|
|
#define DECL_ANCHOR(name) \
|
|
|
|
LINK_ANCHOR name##_body__ = {{0,}, &name##_body__.anchor}; \
|
|
|
|
LINK_ANCHOR *name = & name##_body__
|
|
|
|
|
* call_cfunc.ci, compile.c, compile.h, debug.h, eval.c,
eval_error.h, eval_jump.h, eval_load.c, eval_thread.c, gc.c,
insnhelper.h, insns.def, iseq.c, main.c, numeric.c, parse.y,
range.c, regenc.h, ruby.h, signal.c, thread.c, thread_win32.ci,
vm.c, vm.h, vm_dump.c, vm_evalbody.ci, yarvcore.c, yarvcore.h:
fixed indents and non-C90 comments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-02 11:26:04 -05:00
|
|
|
#endif /* _COMPILER_H_INCLUDED_ */
|