diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-03-08 21:22:43 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-03-08 21:22:43 +0000 |
commit | 8dced4d2c0f284bd17a3cb4a4fbed6d459cc71e0 (patch) | |
tree | 3d7836fd4b98251ca69231fd5a0f8088563e7022 /internal.h | |
parent | 2324c14d00c301467ac9a3a5fc95d812109e116f (diff) | |
download | ruby-8dced4d2c0f284bd17a3cb4a4fbed6d459cc71e0.tar.gz |
* internal.h: define rb_cref_t and change to use it.
rb_cref_t is data type of CREF. Now, the body is still NODE.
It is easy to understand what is CREF and what is pure NODE.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49897 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'internal.h')
-rw-r--r-- | internal.h | 99 |
1 files changed, 89 insertions, 10 deletions
diff --git a/internal.h b/internal.h index 016d4d4fcf..b146b46d30 100644 --- a/internal.h +++ b/internal.h @@ -506,16 +506,95 @@ RCLASS_SET_SUPER(VALUE klass, VALUE super) } /* CREF */ -#define CREF_CLASS(cref) ((cref)->nd_clss_) -#define CREF_NEXT(cref) ((cref)->nd_next) -#define CREF_VISI(cref) ((cref)->nd_visi_) -#define CREF_VISI_SET(cref, v) ((cref)->nd_visi_ = (v)) -#define CREF_REFINEMENTS(cref) ((cref)->nd_refinements_) -#define CREF_PUSHED_BY_EVAL(cref) ((cref)->flags & NODE_FL_CREF_PUSHED_BY_EVAL_) -#define CREF_PUSHED_BY_EVAL_SET(cref) ((cref)->flags |= NODE_FL_CREF_PUSHED_BY_EVAL_) -#define CREF_OMOD_SHARED(cref) ((cref)->flags & NODE_FL_CREF_OMOD_SHARED_) -#define CREF_OMOD_SHARED_SET(cref) ((cref)->flags |= NODE_FL_CREF_OMOD_SHARED_) -#define CREF_OMOD_SHARED_UNSET(cref) ((cref)->flags &= ~NODE_FL_CREF_OMOD_SHARED_) + +typedef struct rb_cref_struct { + VALUE flags; + VALUE refinements; + VALUE klass; + VALUE visi; + struct rb_cref_struct *next; +} rb_cref_t; + +#define NODE_FL_CREF_PUSHED_BY_EVAL_ (((VALUE)1)<<15) +#define NODE_FL_CREF_OMOD_SHARED_ (((VALUE)1)<<16) + +static inline VALUE +CREF_CLASS(const rb_cref_t *cref) +{ + return cref->klass; +} + +static inline void +CREF_CLASS_SET(rb_cref_t *cref, VALUE klass) +{ + RB_OBJ_WRITE(cref, &cref->klass, klass); +} + +static inline rb_cref_t * +CREF_NEXT(const rb_cref_t *cref) +{ + return cref->next; +} + +static inline void +CREF_NEXT_SET(rb_cref_t *cref, const rb_cref_t *next_cref) +{ + RB_OBJ_WRITE(cref, &cref->next, next_cref); +} + +static inline long +CREF_VISI(const rb_cref_t *cref) +{ + return (long)cref->visi; +} + +static inline void +CREF_VISI_SET(rb_cref_t *cref, long v) +{ + cref->visi = v; +} + +static inline VALUE +CREF_REFINEMENTS(const rb_cref_t *cref) +{ + return cref->refinements; +} + +static inline void +CREF_REFINEMENTS_SET(rb_cref_t *cref, VALUE refs) +{ + RB_OBJ_WRITE(cref, &cref->refinements, refs); +} + +static inline int +CREF_PUSHED_BY_EVAL(const rb_cref_t *cref) +{ + return cref->flags & NODE_FL_CREF_PUSHED_BY_EVAL_; +} + +static inline void +CREF_PUSHED_BY_EVAL_SET(rb_cref_t *cref) +{ + cref->flags |= NODE_FL_CREF_PUSHED_BY_EVAL_; +} + +static inline int +CREF_OMOD_SHARED(const rb_cref_t *cref) +{ + return cref->flags & NODE_FL_CREF_OMOD_SHARED_; +} + +static inline void +CREF_OMOD_SHARED_SET(rb_cref_t *cref) +{ + cref->flags |= NODE_FL_CREF_OMOD_SHARED_; +} + +static inline void +CREF_OMOD_SHARED_UNSET(rb_cref_t *cref) +{ + cref->flags &= ~NODE_FL_CREF_OMOD_SHARED_; +} struct vtm; /* defined by timev.h */ |