aboutsummaryrefslogtreecommitdiffstats
path: root/method.h
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-07-15 14:59:41 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-07-15 14:59:41 +0000
commitc330876d7c5065f89234becc5125426d0d136bdc (patch)
treed7a65121d7250d0137a2c75d7b7d454737815e7d /method.h
parentd3cbda6e8dc5732f64b06cacb4c137f01ebe0461 (diff)
downloadruby-c330876d7c5065f89234becc5125426d0d136bdc.tar.gz
* method.h, vm_core.h: add rb_method_entry_t. Remove nodes around
method management. This change affect some VM control stack structure. * vm.c, vm_insnhelper.c, vm_method.c, vm_eval.c: ditto. and make some refactoring. * insns.def, class.c, eval.c, proc.c, vm_dump.c : ditto. * vm_core.h, compile.c (iseq_specialized_instruction): remove VM_CALL_SEND_BIT. use another optimization tech for Kernel#send. * node.h: remove unused node types. * ext/objspace/objspace.c (count_nodes): ditto. * gc.c: add mark/free functions for method entry. * include/ruby/intern.h: remove decl of rb_define_notimplement_method_id(). nobody can use it because noex is not opend. * iseq.c (iseq_mark): fix to check ic_method is available. * iseq.c (rb_iseq_disasm): fix to use rb_method_get_iseq(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24128 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'method.h')
-rw-r--r--method.h78
1 files changed, 78 insertions, 0 deletions
diff --git a/method.h b/method.h
new file mode 100644
index 0000000000..ff8ad910a4
--- /dev/null
+++ b/method.h
@@ -0,0 +1,78 @@
+/**********************************************************************
+
+ method.h -
+
+ $Author: ko1 $
+ created at: Wed Jul 15 20:02:33 2009
+
+ Copyright (C) 2009 Koichi Sasada
+
+**********************************************************************/
+#ifndef METHOD_H
+#define METHOD_H
+
+typedef enum {
+ NOEX_PUBLIC = 0x00,
+ NOEX_NOSUPER = 0x01,
+ NOEX_PRIVATE = 0x02,
+ NOEX_PROTECTED = 0x04,
+ NOEX_MASK = 0x06,
+ NOEX_BASIC = 0x08,
+ NOEX_UNDEF = NOEX_NOSUPER,
+ NOEX_MODFUNC = 0x12,
+ NOEX_SUPER = 0x20,
+ NOEX_VCALL = 0x40,
+} rb_method_flag_t;
+
+#define NOEX_SAFE(n) ((int)((n) >> 8) & 0x0F)
+#define NOEX_WITH(n, s) ((s << 8) | (n) | (ruby_running ? 0 : NOEX_BASIC))
+#define NOEX_WITH_SAFE(n) NOEX_WITH(n, rb_safe_level())
+
+/* method data type */
+
+typedef enum {
+ VM_METHOD_TYPE_ISEQ,
+ VM_METHOD_TYPE_CFUNC,
+ VM_METHOD_TYPE_ATTRSET,
+ VM_METHOD_TYPE_IVAR,
+ VM_METHOD_TYPE_BMETHOD,
+ VM_METHOD_TYPE_ZSUPER,
+ VM_METHOD_TYPE_UNDEF,
+ VM_METHOD_TYPE_NOTIMPLEMENTED,
+ VM_METHOD_TYPE_OPTIMIZED, /* Kernel#send, Proc#call, etc */
+} rb_method_type_t;
+
+typedef struct rb_method_cfunc_struct {
+ VALUE (*func)(ANYARGS);
+ int argc;
+} rb_method_cfunc_t;
+
+typedef struct rb_iseq_struct rb_iseq_t;
+
+typedef struct rb_method_entry_struct {
+ rb_method_flag_t flag;
+ rb_method_type_t type; /* method type */
+ ID called_id;
+ ID original_id;
+ VALUE klass; /* should be mark */
+ union {
+ rb_iseq_t *iseq; /* should be mark */
+ rb_method_cfunc_t cfunc;
+ ID attr_id;
+ VALUE proc;
+ enum method_optimized_type {
+ OPTIMIZED_METHOD_TYPE_SEND,
+ OPTIMIZED_METHOD_TYPE_CALL,
+ } optimize_type;
+ } body;
+ int alias_count;
+} rb_method_entry_t;
+
+void rb_add_method_cfunc(VALUE klass, ID mid, VALUE (*func)(ANYARGS), int argc, rb_method_flag_t noex);
+rb_method_entry_t *rb_add_method(VALUE klass, ID mid, rb_method_type_t type, void *option, rb_method_flag_t noex);
+void rb_add_method_me(VALUE klass, ID mid, const rb_method_entry_t *, rb_method_flag_t noex);
+rb_method_entry_t *rb_method_entry(VALUE klass, ID id);
+int rb_method_entry_arity(const rb_method_entry_t *me);
+void rb_gc_mark_method_entry(const rb_method_entry_t *me);
+
+#endif /* METHOD_H */