summaryrefslogtreecommitdiff
path: root/node.h
diff options
context:
space:
mode:
Diffstat (limited to 'node.h')
-rw-r--r--node.h161
1 files changed, 84 insertions, 77 deletions
diff --git a/node.h b/node.h
index d6f5c21..382a50c 100644
--- a/node.h
+++ b/node.h
@@ -22,7 +22,6 @@ enum node_type {
NODE_SCOPE,
NODE_BLOCK,
NODE_IF,
- NODE_UNLESS,
NODE_CASE,
NODE_WHEN,
NODE_OPT_N,
@@ -47,6 +46,7 @@ enum node_type {
NODE_OP_ASGN2,
NODE_CALL,
NODE_FCALL,
+ NODE_VCALL,
NODE_SUPER,
NODE_ZSUPER,
NODE_ARRAY,
@@ -59,7 +59,6 @@ enum node_type {
NODE_GVAR,
NODE_IVAR,
NODE_CVAR,
- NODE_CONST,
NODE_NTH_REF,
NODE_BACK_REF,
NODE_MATCH_REF,
@@ -77,9 +76,11 @@ enum node_type {
NODE_DEFN,
NODE_DEFS,
NODE_ALIAS,
+ NODE_VALIAS,
NODE_UNDEF,
NODE_CLASS,
NODE_MODULE,
+ NODE_SCLASS,
NODE_COLON2,
NODE_CNAME,
NODE_CREF,
@@ -92,6 +93,7 @@ enum node_type {
NODE_NIL,
NODE_DEFINED,
NODE_TAG,
+ NODE_NEWLINE,
};
typedef struct RNode {
@@ -122,13 +124,13 @@ typedef struct RNode {
#define RNODE(obj) (R_CAST(RNode)(obj))
-#define nd_type(n) (((RNODE(n))->flags>>10)&0x7f)
+#define nd_type(n) (((RNODE(n))->flags>>FL_USHIFT)&0x7f)
#define nd_set_type(n,t) \
- RNODE(n)->flags=(RNODE(n)->flags&~FL_UMASK|(((t)<<10)&FL_UMASK))
+ RNODE(n)->flags=((RNODE(n)->flags&~FL_UMASK)|(((t)<<FL_USHIFT)&FL_UMASK))
-#define nd_line(n) (((RNODE(n))->flags>>17)&0x7fff)
+#define nd_line(n) (((RNODE(n))->flags>>18)&0x3fff)
#define nd_set_line(n,l) \
- RNODE(n)->flags=(RNODE(n)->flags&~(-1<<17)|(((l)&0x7fff)<<17))
+ RNODE(n)->flags=((RNODE(n)->flags&~(-1<<18))|(((l)&0x7fff)<<18))
#define nd_head u1.node
#define nd_alen u2.argc
@@ -199,79 +201,84 @@ typedef struct RNode {
#define nd_tlev u3.cnt
#define nd_tval u2.value
-#define NEW_METHOD(n,x) newnode(NODE_METHOD,x,n,0)
-#define NEW_FBODY(n,i,o) newnode(NODE_FBODY,n,i,o)
-#define NEW_DEFN(i,a,d,p) newnode(NODE_DEFN,p,i,NEW_RFUNC(a,d))
-#define NEW_DEFS(r,i,a,d) newnode(NODE_DEFS,r,i,NEW_RFUNC(a,d))
-#define NEW_CFUNC(f,c) newnode(NODE_CFUNC,f,c,0)
+#define nd_file file
+
+#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_RFUNC(b1,b2) NEW_SCOPE(block_append(b1,b2))
-#define NEW_SCOPE(b) newnode(NODE_SCOPE,local_tbl(),(b),cur_cref)
-#define NEW_BLOCK(a) newnode(NODE_BLOCK,a,1,0)
-#define NEW_IF(c,t,e) newnode(NODE_IF,c,t,e)
-#define NEW_UNLESS(c,t,e) newnode(NODE_UNLESS,c,t,e)
-#define NEW_EXNOT(c) newnode(NODE_EXNOT,c,0,0)
-#define NEW_CASE(h,b) newnode(NODE_CASE,h,b,0)
-#define NEW_WHEN(c,t,e) newnode(NODE_WHEN,c,t,e)
-#define NEW_OPT_N(b) newnode(NODE_OPT_N,0,b,0)
-#define NEW_WHILE(c,b,n) newnode(NODE_WHILE,c,b,n)
-#define NEW_UNTIL(c,b,n) newnode(NODE_UNTIL,c,b,n)
-#define NEW_FOR(v,i,b) newnode(NODE_FOR,v,b,i)
-#define NEW_ITER(v,i,b) newnode(NODE_ITER,v,b,i)
-#define NEW_BEGIN(b) newnode(NODE_BEGIN,0,b,0)
-#define NEW_RESCUE(b,res) newnode(NODE_RESCUE,b,res,0)
-#define NEW_RESBODY(a,ex,n) newnode(NODE_RESBODY,n,ex,a)
-#define NEW_ENSURE(b,en) newnode(NODE_ENSURE,b,0,en)
-#define NEW_RET(s) newnode(NODE_RETURN,s,0,0)
-#define NEW_YIELD(a) newnode(NODE_YIELD,a,0,0)
-#define NEW_LIST(a) NEW_ARRAY(a)
-#define NEW_ARRAY(a) newnode(NODE_ARRAY,a,1,0)
-#define NEW_ZARRAY() newnode(NODE_ZARRAY,0,0,0)
-#define NEW_HASH(a) newnode(NODE_HASH,a,0,0)
-#define NEW_NOT(a) newnode(NODE_NOT,0,a,0)
-#define NEW_MASGN(l,r) newnode(NODE_MASGN,l,0,r)
-#define NEW_GASGN(v,val) newnode(NODE_GASGN,v,val,rb_global_entry(v))
-#define NEW_LASGN(v,val) newnode(NODE_LASGN,v,val,local_cnt(v))
-#define NEW_DASGN(v,val) newnode(NODE_DASGN,v,val,0);
-#define NEW_IASGN(v,val) newnode(NODE_IASGN,v,val,0)
-#define NEW_CASGN(v,val) newnode(NODE_CASGN,v,val,0)
-#define NEW_OP_ASGN1(p,id,a) newnode(NODE_OP_ASGN1,p,id,a)
-#define NEW_OP_ASGN2(r,i,o,val) newnode(NODE_OP_ASGN2,r,val,NEW_OP_ASGN3(i,o))
-#define NEW_OP_ASGN3(i,o) newnode(NODE_OP_ASGN2,i,o,0)
-#define NEW_GVAR(v) newnode(NODE_GVAR,v,0,rb_global_entry(v))
-#define NEW_LVAR(v) newnode(NODE_LVAR,v,0,local_cnt(v))
-#define NEW_DVAR(v) newnode(NODE_DVAR,v,0,0);
-#define NEW_IVAR(v) newnode(NODE_IVAR,v,0,0)
-#define NEW_CVAR(v) newnode(NODE_CVAR,v,0,0)
-#define NEW_NTH_REF(n) newnode(NODE_NTH_REF,0,n,local_cnt('~'))
-#define NEW_BACK_REF(n) newnode(NODE_BACK_REF,0,n,local_cnt('~'))
-#define NEW_MATCH(c) newnode(NODE_MATCH,c,0,0)
-#define NEW_LIT(l) newnode(NODE_LIT,l,0,0)
-#define NEW_STR(s) newnode(NODE_STR,s,0,0)
-#define NEW_DSTR(s) newnode(NODE_DSTR,s,0,0)
-#define NEW_XSTR(s) newnode(NODE_XSTR,s,0,0)
-#define NEW_DXSTR(s) newnode(NODE_DXSTR,s,0,0)
-#define NEW_EVSTR(s,l) newnode(NODE_EVSTR,str_new(s,l),0,0)
-#define NEW_CALL(r,m,a) newnode(NODE_CALL,r,m,a)
-#define NEW_FCALL(m,a) newnode(NODE_FCALL,0,m,a)
-#define NEW_SUPER(a) newnode(NODE_SUPER,0,0,a)
-#define NEW_ZSUPER() newnode(NODE_ZSUPER,0,0,0)
-#define NEW_ARGS(f,o,r) newnode(NODE_ARGS,o,r,f)
-#define NEW_ALIAS(n,o) newnode(NODE_ALIAS,0,n,o)
-#define NEW_UNDEF(i) newnode(NODE_UNDEF,0,i,0)
-#define NEW_CLASS(n,b,s) newnode(NODE_CLASS,n,NEW_CBODY(b),s)
-#define NEW_MODULE(n,b) newnode(NODE_MODULE,n,NEW_CBODY(b),0)
-#define NEW_COLON2(c,i) newnode(NODE_COLON2,c,i,0)
-#define NEW_CREF0() (cur_cref=newnode(NODE_CREF,RNODE(the_frame->cbase)->nd_clss,0,0))
-#define NEW_CREF() (cur_cref=newnode(NODE_CREF,0,0,cur_cref))
+#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_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_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_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_CBODY(b) (cur_cref->nd_body=NEW_SCOPE(b),cur_cref)
-#define NEW_DOT2(b,e) newnode(NODE_DOT2,b,e,0)
-#define NEW_DOT3(b,e) newnode(NODE_DOT3,b,e,0)
-#define NEW_ATTRSET(a) newnode(NODE_ATTRSET,a,0,0)
-#define NEW_SELF() newnode(NODE_SELF,0,0,0)
-#define NEW_NIL() newnode(NODE_NIL,0,0,0)
-#define NEW_DEFINED(e) newnode(NODE_DEFINED,e,0,0)
-
-NODE *newnode();
+#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_DEFINED(e) node_newnode(NODE_DEFINED,e,0,0)
+#define NEW_NEWLINE(n) node_newnode(NODE_NEWLINE,0,0,n)
+
+NODE *node_newnode();
VALUE rb_method_booundp();
#define NOEX_PUBLIC 0