summaryrefslogtreecommitdiff
path: root/node.h
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-01-20 04:59:39 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-01-20 04:59:39 +0000
commit62e648e148b3cb9f96dcce808c55c02b7ccb4486 (patch)
tree9708892ece92e860d81559ab55e6b1f9400d7ffc /node.h
parentaeb049c573be4dc24dd20650f40e4777e0f698cf (diff)
ruby 1.3 cycle
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/RUBY@372 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'node.h')
-rw-r--r--node.h231
1 files changed, 130 insertions, 101 deletions
diff --git a/node.h b/node.h
index cdb354c..c1923fb 100644
--- a/node.h
+++ b/node.h
@@ -6,7 +6,7 @@
$Date$
created at: Fri May 28 15:14:02 JST 1993
- Copyright (C) 1993-1996 Yukihiro Matsumoto
+ Copyright (C) 1993-1998 Yukihiro Matsumoto
************************************************/
@@ -41,11 +41,14 @@ enum node_type {
NODE_MASGN,
NODE_LASGN,
NODE_DASGN,
+ NODE_DASGN_PUSH,
NODE_GASGN,
NODE_IASGN,
NODE_CASGN,
NODE_OP_ASGN1,
NODE_OP_ASGN2,
+ NODE_OP_ASGN_AND,
+ NODE_OP_ASGN_OR,
NODE_CALL,
NODE_FCALL,
NODE_VCALL,
@@ -63,8 +66,6 @@ enum node_type {
NODE_CVAR,
NODE_NTH_REF,
NODE_BACK_REF,
- NODE_MATCH_REF,
- NODE_LASTLINE,
NODE_MATCH,
NODE_MATCH2,
NODE_MATCH3,
@@ -77,6 +78,10 @@ enum node_type {
NODE_DREGX,
NODE_DREGX_ONCE,
NODE_ARGS,
+ NODE_ARGSCAT,
+ NODE_RESTARGS,
+ NODE_BLOCK_ARG,
+ NODE_BLOCK_PASS,
NODE_DEFN,
NODE_DEFS,
NODE_ALIAS,
@@ -86,6 +91,7 @@ enum node_type {
NODE_MODULE,
NODE_SCLASS,
NODE_COLON2,
+ NODE_COLON3,
NODE_CNAME,
NODE_CREF,
NODE_DOT2,
@@ -98,13 +104,15 @@ enum node_type {
NODE_TRUE,
NODE_FALSE,
NODE_DEFINED,
- NODE_TAG,
NODE_NEWLINE,
NODE_POSTEXE,
+#ifdef C_ALLOCA
+ NODE_ALLOCA,
+#endif
};
typedef struct RNode {
- UINT flags;
+ unsigned long flags;
char *nd_file;
union {
struct RNode *node;
@@ -131,13 +139,15 @@ typedef struct RNode {
#define RNODE(obj) (R_CAST(RNode)(obj))
-#define nd_type(n) (((RNODE(n))->flags>>FL_USHIFT)&0x7f)
+#define nd_type(n) (((RNODE(n))->flags>>FL_USHIFT)&0xff)
#define nd_set_type(n,t) \
RNODE(n)->flags=((RNODE(n)->flags&~FL_UMASK)|(((t)<<FL_USHIFT)&FL_UMASK))
-#define nd_line(n) (((RNODE(n))->flags>>18)&0x3fff)
+#define NODE_LSHIFT (FL_USHIFT+8)
+#define NODE_LMASK ((1<<(sizeof(NODE*)*CHAR_BIT-NODE_LSHIFT))-1)
+#define nd_line(n) (((RNODE(n))->flags>>NODE_LSHIFT)&NODE_LMASK)
#define nd_set_line(n,l) \
- RNODE(n)->flags=((RNODE(n)->flags&~(-1<<18))|(((l)&0x7fff)<<18))
+ RNODE(n)->flags=((RNODE(n)->flags&~(-1<<NODE_LSHIFT))|(((l)&NODE_LMASK)<<NODE_LSHIFT))
#define nd_head u1.node
#define nd_alen u2.argc
@@ -185,8 +195,8 @@ typedef struct RNode {
#define nd_noex u1.id
#define nd_defn u3.node
+#define nd_old u1.id
#define nd_new u2.id
-#define nd_old u3.id
#define nd_cfnc u1.cfunc
#define nd_argc u2.argc
@@ -200,114 +210,133 @@ typedef struct RNode {
#define nd_beg u1.node
#define nd_end u2.node
#define nd_state u3.state
-#define nd_rval u3.value
+#define nd_rval u2.value
#define nd_nth u2.argc
#define nd_tag u1.id
-#define nd_tlev u3.cnt
#define nd_tval u2.value
-#define NEW_METHOD(n,x) node_newnode(NODE_METHOD,x,n,0)
-#define NEW_FBODY(n,i,o) node_newnode(NODE_FBODY,n,i,o)
-#define NEW_DEFN(i,a,d,p) node_newnode(NODE_DEFN,p,i,NEW_RFUNC(a,d))
-#define NEW_DEFS(r,i,a,d) node_newnode(NODE_DEFS,r,i,NEW_RFUNC(a,d))
-#define NEW_CFUNC(f,c) node_newnode(NODE_CFUNC,f,c,0)
+#define NEW_METHOD(n,x) rb_node_newnode(NODE_METHOD,x,n,0)
+#define NEW_FBODY(n,i,o) rb_node_newnode(NODE_FBODY,n,i,o)
+#define NEW_DEFN(i,a,d,p) rb_node_newnode(NODE_DEFN,p,i,NEW_RFUNC(a,d))
+#define NEW_DEFS(r,i,a,d) rb_node_newnode(NODE_DEFS,r,i,NEW_RFUNC(a,d))
+#define NEW_CFUNC(f,c) rb_node_newnode(NODE_CFUNC,f,c,0)
#define NEW_RFUNC(b1,b2) NEW_SCOPE(block_append(b1,b2))
-#define NEW_SCOPE(b) node_newnode(NODE_SCOPE,local_tbl(),(b),cur_cref)
-#define NEW_BLOCK(a) node_newnode(NODE_BLOCK,a,0,0)
-#define NEW_IF(c,t,e) node_newnode(NODE_IF,c,t,e)
-#define NEW_UNLESS(c,t,e) node_newnode(NODE_IF,c,e,t)
-#define NEW_CASE(h,b) node_newnode(NODE_CASE,h,b,0)
-#define NEW_WHEN(c,t,e) node_newnode(NODE_WHEN,c,t,e)
-#define NEW_OPT_N(b) node_newnode(NODE_OPT_N,0,b,0)
-#define NEW_WHILE(c,b,n) node_newnode(NODE_WHILE,c,b,n)
-#define NEW_UNTIL(c,b,n) node_newnode(NODE_UNTIL,c,b,n)
-#define NEW_FOR(v,i,b) node_newnode(NODE_FOR,v,b,i)
-#define NEW_ITER(v,i,b) node_newnode(NODE_ITER,v,b,i)
-#define NEW_BREAK() node_newnode(NODE_BREAK,0,0,0)
-#define NEW_NEXT() node_newnode(NODE_NEXT,0,0,0)
-#define NEW_REDO() node_newnode(NODE_REDO,0,0,0)
-#define NEW_RETRY() node_newnode(NODE_RETRY,0,0,0)
-#define NEW_BEGIN(b) node_newnode(NODE_BEGIN,0,b,0)
-#define NEW_RESCUE(b,res) node_newnode(NODE_RESCUE,b,res,0)
-#define NEW_RESBODY(a,ex,n) node_newnode(NODE_RESBODY,n,ex,a)
-#define NEW_ENSURE(b,en) node_newnode(NODE_ENSURE,b,0,en)
-#define NEW_RET(s) node_newnode(NODE_RETURN,s,0,0)
-#define NEW_YIELD(a) node_newnode(NODE_YIELD,a,0,0)
+#define NEW_SCOPE(b) rb_node_newnode(NODE_SCOPE,local_tbl(),cur_cref,(b))
+#define NEW_BLOCK(a) rb_node_newnode(NODE_BLOCK,a,0,0)
+#ifdef NOBLOCK_RECUR
+#define NEW_IF(c,t,e) block_append(c,rb_node_newnode(NODE_IF,0,t,e))
+#else
+#define NEW_IF(c,t,e) rb_node_newnode(NODE_IF,c,t,e)
+#endif
+#define NEW_UNLESS(c,t,e) NEW_IF(c,e,t)
+#ifdef NOBLOCK_RECUR
+#define NEW_CASE(h,b) block_append(h,rb_node_newnode(NODE_CASE,0,b,0))
+#else
+#define NEW_CASE(h,b) rb_node_newnode(NODE_CASE,h,b,0)
+#endif
+#define NEW_WHEN(c,t,e) rb_node_newnode(NODE_WHEN,c,t,e)
+#define NEW_OPT_N(b) rb_node_newnode(NODE_OPT_N,0,b,0)
+#define NEW_WHILE(c,b,n) rb_node_newnode(NODE_WHILE,c,b,n)
+#define NEW_UNTIL(c,b,n) rb_node_newnode(NODE_UNTIL,c,b,n)
+#define NEW_FOR(v,i,b) rb_node_newnode(NODE_FOR,v,b,i)
+#define NEW_ITER(v,i,b) rb_node_newnode(NODE_ITER,v,b,i)
+#define NEW_BREAK() rb_node_newnode(NODE_BREAK,0,0,0)
+#define NEW_NEXT() rb_node_newnode(NODE_NEXT,0,0,0)
+#define NEW_REDO() rb_node_newnode(NODE_REDO,0,0,0)
+#define NEW_RETRY() rb_node_newnode(NODE_RETRY,0,0,0)
+#define NEW_BEGIN(b) rb_node_newnode(NODE_BEGIN,0,b,0)
+#define NEW_RESCUE(b,res,e) rb_node_newnode(NODE_RESCUE,b,res,e)
+#define NEW_RESBODY(a,ex,n) rb_node_newnode(NODE_RESBODY,n,ex,a)
+#define NEW_ENSURE(b,en) rb_node_newnode(NODE_ENSURE,b,0,en)
+#define NEW_RETURN(s) rb_node_newnode(NODE_RETURN,s,0,0)
+#define NEW_YIELD(a) rb_node_newnode(NODE_YIELD,a,0,0)
#define NEW_LIST(a) NEW_ARRAY(a)
-#define NEW_ARRAY(a) node_newnode(NODE_ARRAY,a,1,0)
-#define NEW_ZARRAY() node_newnode(NODE_ZARRAY,0,0,0)
-#define NEW_HASH(a) node_newnode(NODE_HASH,a,0,0)
-#define NEW_NOT(a) node_newnode(NODE_NOT,0,a,0)
-#define NEW_MASGN(l,r) node_newnode(NODE_MASGN,l,0,r)
-#define NEW_GASGN(v,val) node_newnode(NODE_GASGN,v,val,rb_global_entry(v))
-#define NEW_LASGN(v,val) node_newnode(NODE_LASGN,v,val,local_cnt(v))
-#define NEW_DASGN(v,val) node_newnode(NODE_DASGN,v,val,0);
-#define NEW_IASGN(v,val) node_newnode(NODE_IASGN,v,val,0)
-#define NEW_CASGN(v,val) node_newnode(NODE_CASGN,v,val,0)
-#define NEW_OP_ASGN1(p,id,a) node_newnode(NODE_OP_ASGN1,p,id,a)
-#define NEW_OP_ASGN2(r,i,o,val) node_newnode(NODE_OP_ASGN2,r,val,NEW_OP_ASGN3(i,o))
-#define NEW_OP_ASGN3(i,o) node_newnode(NODE_OP_ASGN2,i,o,0)
-#define NEW_GVAR(v) node_newnode(NODE_GVAR,v,0,rb_global_entry(v))
-#define NEW_LVAR(v) node_newnode(NODE_LVAR,v,0,local_cnt(v))
-#define NEW_DVAR(v) node_newnode(NODE_DVAR,v,0,0);
-#define NEW_IVAR(v) node_newnode(NODE_IVAR,v,0,0)
-#define NEW_CVAR(v) node_newnode(NODE_CVAR,v,0,0)
-#define NEW_NTH_REF(n) node_newnode(NODE_NTH_REF,0,n,local_cnt('~'))
-#define NEW_BACK_REF(n) node_newnode(NODE_BACK_REF,0,n,local_cnt('~'))
-#define NEW_MATCH(c) node_newnode(NODE_MATCH,c,0,0)
-#define NEW_MATCH2(n1,n2) node_newnode(NODE_MATCH2,n1,n2,0)
-#define NEW_MATCH3(r,n2) node_newnode(NODE_MATCH3,r,n2,0)
-#define NEW_LIT(l) node_newnode(NODE_LIT,l,0,0)
-#define NEW_STR(s) node_newnode(NODE_STR,s,0,0)
-#define NEW_DSTR(s) node_newnode(NODE_DSTR,s,0,0)
-#define NEW_XSTR(s) node_newnode(NODE_XSTR,s,0,0)
-#define NEW_DXSTR(s) node_newnode(NODE_DXSTR,s,0,0)
-#define NEW_EVSTR(s,l) node_newnode(NODE_EVSTR,str_new(s,l),0,0)
-#define NEW_CALL(r,m,a) node_newnode(NODE_CALL,r,m,a)
-#define NEW_FCALL(m,a) node_newnode(NODE_FCALL,0,m,a)
-#define NEW_VCALL(m) node_newnode(NODE_VCALL,0,m,0)
-#define NEW_SUPER(a) node_newnode(NODE_SUPER,0,0,a)
-#define NEW_ZSUPER() node_newnode(NODE_ZSUPER,0,0,0)
-#define NEW_ARGS(f,o,r) node_newnode(NODE_ARGS,o,r,f)
-#define NEW_ALIAS(n,o) node_newnode(NODE_ALIAS,0,n,o)
-#define NEW_VALIAS(n,o) node_newnode(NODE_VALIAS,0,n,o)
-#define NEW_UNDEF(i) node_newnode(NODE_UNDEF,0,i,0)
-#define NEW_CLASS(n,b,s) node_newnode(NODE_CLASS,n,NEW_CBODY(b),s)
-#define NEW_SCLASS(r,b) node_newnode(NODE_SCLASS,r,NEW_CBODY(b),0)
-#define NEW_MODULE(n,b) node_newnode(NODE_MODULE,n,NEW_CBODY(b),0)
-#define NEW_COLON2(c,i) node_newnode(NODE_COLON2,c,i,0)
-#define NEW_CREF0() (cur_cref=node_newnode(NODE_CREF,RNODE(the_frame->cbase)->nd_clss,0,0))
-#define NEW_CREF() (cur_cref=node_newnode(NODE_CREF,0,0,cur_cref))
+#define NEW_ARRAY(a) rb_node_newnode(NODE_ARRAY,a,1,0)
+#define NEW_ZARRAY() rb_node_newnode(NODE_ZARRAY,0,0,0)
+#define NEW_HASH(a) rb_node_newnode(NODE_HASH,a,0,0)
+#define NEW_NOT(a) rb_node_newnode(NODE_NOT,0,a,0)
+#define NEW_MASGN(l,r) rb_node_newnode(NODE_MASGN,l,0,r)
+#define NEW_GASGN(v,val) rb_node_newnode(NODE_GASGN,v,val,rb_global_entry(v))
+#define NEW_LASGN(v,val) rb_node_newnode(NODE_LASGN,v,val,local_cnt(v))
+#define NEW_DASGN(v,val) rb_node_newnode(NODE_DASGN,v,val,0);
+#define NEW_DASGN_PUSH(v,val) rb_node_newnode(NODE_DASGN_PUSH,v,val,0);
+#define NEW_IASGN(v,val) rb_node_newnode(NODE_IASGN,v,val,0)
+#define NEW_CASGN(v,val) rb_node_newnode(NODE_CASGN,v,val,0)
+#define NEW_OP_ASGN1(p,id,a) rb_node_newnode(NODE_OP_ASGN1,p,id,a)
+#define NEW_OP_ASGN2(r,i,o,val) rb_node_newnode(NODE_OP_ASGN2,r,val,NEW_OP_ASGN22(i,o))
+#define NEW_OP_ASGN22(i,o) rb_node_newnode(NODE_OP_ASGN2,i,o,rb_id_attrset(i))
+#define NEW_OP_ASGN_OR(i,val) rb_node_newnode(NODE_OP_ASGN_OR,i,val,0)
+#define NEW_OP_ASGN_AND(i,val) rb_node_newnode(NODE_OP_ASGN_AND,i,val,0)
+#define NEW_GVAR(v) rb_node_newnode(NODE_GVAR,v,0,rb_global_entry(v))
+#define NEW_LVAR(v) rb_node_newnode(NODE_LVAR,v,0,local_cnt(v))
+#define NEW_DVAR(v) rb_node_newnode(NODE_DVAR,v,0,0);
+#define NEW_IVAR(v) rb_node_newnode(NODE_IVAR,v,0,0)
+#define NEW_CVAR(v) rb_node_newnode(NODE_CVAR,v,0,0)
+#define NEW_NTH_REF(n) rb_node_newnode(NODE_NTH_REF,0,n,local_cnt('~'))
+#define NEW_BACK_REF(n) rb_node_newnode(NODE_BACK_REF,0,n,local_cnt('~'))
+#define NEW_MATCH(c) rb_node_newnode(NODE_MATCH,c,0,0)
+#define NEW_MATCH2(n1,n2) rb_node_newnode(NODE_MATCH2,n1,n2,0)
+#define NEW_MATCH3(r,n2) rb_node_newnode(NODE_MATCH3,r,n2,0)
+#define NEW_LIT(l) rb_node_newnode(NODE_LIT,l,0,0)
+#define NEW_STR(s) rb_node_newnode(NODE_STR,s,0,0)
+#define NEW_DSTR(s) rb_node_newnode(NODE_DSTR,s,0,0)
+#define NEW_XSTR(s) rb_node_newnode(NODE_XSTR,s,0,0)
+#define NEW_DXSTR(s) rb_node_newnode(NODE_DXSTR,s,0,0)
+#define NEW_EVSTR(s,l) rb_node_newnode(NODE_EVSTR,rb_str_new(s,l),0,0)
+#ifdef NOBLOCK_RECUR_incomplete
+#define NEW_CALL(r,m,a) block_append(r,rb_node_newnode(NODE_CALL,0,m,a))
+#else
+#define NEW_CALL(r,m,a) rb_node_newnode(NODE_CALL,r,m,a)
+#endif
+#define NEW_FCALL(m,a) rb_node_newnode(NODE_FCALL,0,m,a)
+#define NEW_VCALL(m) rb_node_newnode(NODE_VCALL,0,m,0)
+#define NEW_SUPER(a) rb_node_newnode(NODE_SUPER,0,0,a)
+#define NEW_ZSUPER() rb_node_newnode(NODE_ZSUPER,0,0,0)
+#define NEW_ARGS(f,o,r) rb_node_newnode(NODE_ARGS,o,r,f)
+#define NEW_ARGSCAT(a,b) rb_node_newnode(NODE_ARGSCAT,a,b,0)
+#define NEW_RESTARGS(a) rb_node_newnode(NODE_RESTARGS,a,0,0)
+#define NEW_BLOCK_ARG(v) rb_node_newnode(NODE_BLOCK_ARG,v,0,local_cnt(v))
+#define NEW_BLOCK_PASS(b) rb_node_newnode(NODE_BLOCK_PASS,0,b,0)
+#define NEW_ALIAS(n,o) rb_node_newnode(NODE_ALIAS,o,n,0)
+#define NEW_VALIAS(n,o) rb_node_newnode(NODE_VALIAS,o,n,0)
+#define NEW_UNDEF(i) rb_node_newnode(NODE_UNDEF,0,i,0)
+#define NEW_CLASS(n,b,s) rb_node_newnode(NODE_CLASS,n,NEW_CBODY(b),(s))
+#define NEW_SCLASS(r,b) rb_node_newnode(NODE_SCLASS,r,NEW_CBODY(b),0)
+#define NEW_MODULE(n,b) rb_node_newnode(NODE_MODULE,n,NEW_CBODY(b),0)
+#define NEW_COLON2(c,i) rb_node_newnode(NODE_COLON2,c,i,0)
+#define NEW_COLON3(i) rb_node_newnode(NODE_COLON3,0,i,0)
+#define NEW_CREF0() (cur_cref=rb_node_newnode(NODE_CREF,RNODE(ruby_frame->cbase)->nd_clss,0,0))
+#define NEW_CREF() (cur_cref=rb_node_newnode(NODE_CREF,0,0,cur_cref))
#define NEW_CBODY(b) (cur_cref->nd_body=NEW_SCOPE(b),cur_cref)
-#define NEW_DOT2(b,e) node_newnode(NODE_DOT2,b,e,0)
-#define NEW_DOT3(b,e) node_newnode(NODE_DOT3,b,e,0)
-#define NEW_ATTRSET(a) node_newnode(NODE_ATTRSET,a,0,0)
-#define NEW_SELF() node_newnode(NODE_SELF,0,0,0)
-#define NEW_NIL() node_newnode(NODE_NIL,0,0,0)
-#define NEW_TRUE() node_newnode(NODE_TRUE,0,0,0)
-#define NEW_FALSE() node_newnode(NODE_FALSE,0,0,0)
-#define NEW_DEFINED(e) node_newnode(NODE_DEFINED,e,0,0)
-#define NEW_NEWLINE(n) node_newnode(NODE_NEWLINE,0,0,n)
+#define NEW_DOT2(b,e) rb_node_newnode(NODE_DOT2,b,e,0)
+#define NEW_DOT3(b,e) rb_node_newnode(NODE_DOT3,b,e,0)
+#define NEW_ATTRSET(a) rb_node_newnode(NODE_ATTRSET,a,0,0)
+#define NEW_SELF() rb_node_newnode(NODE_SELF,0,0,0)
+#define NEW_NIL() rb_node_newnode(NODE_NIL,0,0,0)
+#define NEW_TRUE() rb_node_newnode(NODE_TRUE,0,0,0)
+#define NEW_FALSE() rb_node_newnode(NODE_FALSE,0,0,0)
+#define NEW_DEFINED(e) rb_node_newnode(NODE_DEFINED,e,0,0)
+#define NEW_NEWLINE(n) rb_node_newnode(NODE_NEWLINE,0,0,n)
#define NEW_PREEXE(b) NEW_SCOPE(b)
-#define NEW_POSTEXE() node_newnode(NODE_POSTEXE,0,0,0)
+#define NEW_POSTEXE() rb_node_newnode(NODE_POSTEXE,0,0,0)
-NODE *node_newnode();
+NODE *rb_node_newnode();
VALUE rb_method_booundp();
-#define NOEX_PUBLIC 0
-#define NOEX_PRIVATE 1
+#define NOEX_PUBLIC 0
+#define NOEX_UNDEF 1
+#define NOEX_CFUNC 1
+#define NOEX_PRIVATE 2
+#define NOEX_PROTECTED 4
-NODE *compile_string _((char *, char *, int));
-NODE *compile_file _((char *, VALUE, int));
+NODE *rb_compile_cstr _((char *, char *, int));
+NODE *rb_compile_string _((char *, VALUE));
+NODE *rb_compile_file _((char *, VALUE, int));
void rb_add_method _((VALUE, ID, NODE *, int));
-void rb_remove_method _((VALUE, ID));
-NODE *node_newnode();
-
-enum node_type nodetype _((NODE *));
-int nodeline _((NODE *));
+NODE *rb_node_newnode();
struct global_entry *rb_global_entry _((ID));
VALUE rb_gvar_get _((struct global_entry *));