зеркало из https://github.com/github/ruby.git
Macros can't be expressions, so make a function
Macros can't be expressions, that is a GNU extension (I didn't know that). This commit converts the macro to a function so that everything will compile correctly on non-GNU compatible compilers.
This commit is contained in:
Родитель
139510238b
Коммит
91ee9584f9
8
node.h
8
node.h
|
@ -281,15 +281,11 @@ typedef struct RNode {
|
|||
#define nd_apinfo u3.apinfo
|
||||
|
||||
#define NEW_NODE(t,a0,a1,a2,loc) rb_node_newnode((t),(VALUE)(a0),(VALUE)(a1),(VALUE)(a2),loc)
|
||||
#define NEW_NODE_WITH_LOCALS(t,a1,a2,loc) node_newnode_with_locals(p, (t),(VALUE)(a1),(VALUE)(a2),loc)
|
||||
|
||||
#define NEW_DEFN(i,a,d,loc) NEW_NODE(NODE_DEFN,0,i,NEW_SCOPE(a,d,loc),loc)
|
||||
#define NEW_DEFS(r,i,a,d,loc) NEW_NODE(NODE_DEFS,r,i,NEW_SCOPE(a,d,loc),loc)
|
||||
#define NEW_SCOPE(a,b,loc) ({ \
|
||||
VALUE tbl = 0; \
|
||||
NODE * _n = NEW_NODE(NODE_SCOPE,local_tbl(p, &tbl),b,a,loc); \
|
||||
tbl && RB_OBJ_WRITTEN(p->ast, Qnil, tbl); \
|
||||
_n; \
|
||||
})
|
||||
#define NEW_SCOPE(a,b,loc) NEW_NODE_WITH_LOCALS(NODE_SCOPE,b,a,loc)
|
||||
#define NEW_BLOCK(a,loc) NEW_NODE(NODE_BLOCK,a,0,0,loc)
|
||||
#define NEW_IF(c,t,e,loc) NEW_NODE(NODE_IF,c,t,e,loc)
|
||||
#define NEW_UNLESS(c,t,e,loc) NEW_NODE(NODE_UNLESS,c,t,e,loc)
|
||||
|
|
16
parse.y
16
parse.y
|
@ -347,6 +347,8 @@ add_mark_object(struct parser_params *p, VALUE obj)
|
|||
}
|
||||
return obj;
|
||||
}
|
||||
#else
|
||||
static NODE* node_newnode_with_locals(struct parser_params *, enum node_type, VALUE, VALUE, const rb_code_location_t*);
|
||||
#endif
|
||||
|
||||
static NODE* node_newnode(struct parser_params *, enum node_type, VALUE, VALUE, VALUE, const rb_code_location_t*);
|
||||
|
@ -11660,6 +11662,20 @@ local_tbl(struct parser_params *p, VALUE *tmp)
|
|||
|
||||
return buf;
|
||||
}
|
||||
|
||||
static NODE*
|
||||
node_newnode_with_locals(struct parser_params *p, enum node_type type, VALUE a1, VALUE a2, const rb_code_location_t *loc)
|
||||
{
|
||||
ID *a0;
|
||||
NODE *n;
|
||||
VALUE tbl = 0;
|
||||
|
||||
a0 = local_tbl(p, &tbl);
|
||||
n = NEW_NODE(type, a0, a1, a2, loc);
|
||||
tbl && RB_OBJ_WRITTEN(p->ast, Qnil, tbl);
|
||||
return n;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static void
|
||||
|
|
Загрузка…
Ссылка в новой задаче