summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2016-02-27 01:19:22 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2016-02-27 01:19:22 (GMT)
commitfc6f2efd13a6b667e48cdf1f5cf68d34fcb0fa74 (patch)
tree333eb8cb55f641a694d9a58a758277dbb4c0bd6b /Python
parent3902d62c4e9810f1386090dd60b38f5aa6e99512 (diff)
downloadcpython-fc6f2efd13a6b667e48cdf1f5cf68d34fcb0fa74.zip
cpython-fc6f2efd13a6b667e48cdf1f5cf68d34fcb0fa74.tar.gz
cpython-fc6f2efd13a6b667e48cdf1f5cf68d34fcb0fa74.tar.bz2
compile.c: inline compiler_use_new_block()
* Inline compiler_use_new_block() function into its only callee, compiler_enter_scope() * Remove unused NEW_BLOCK() macro
Diffstat (limited to 'Python')
-rw-r--r--Python/compile.c35
1 files changed, 9 insertions, 26 deletions
diff --git a/Python/compile.c b/Python/compile.c
index ca1d865..568bdfe 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -171,7 +171,6 @@ static int compiler_addop(struct compiler *, int);
static int compiler_addop_o(struct compiler *, int, PyObject *, PyObject *);
static int compiler_addop_i(struct compiler *, int, Py_ssize_t);
static int compiler_addop_j(struct compiler *, int, basicblock *, int);
-static basicblock *compiler_use_new_block(struct compiler *);
static int compiler_error(struct compiler *, const char *);
static int compiler_nameop(struct compiler *, identifier, expr_context_ty);
@@ -523,6 +522,7 @@ compiler_enter_scope(struct compiler *c, identifier name,
int scope_type, void *key, int lineno)
{
struct compiler_unit *u;
+ basicblock *block;
u = (struct compiler_unit *)PyObject_Malloc(sizeof(
struct compiler_unit));
@@ -620,8 +620,11 @@ compiler_enter_scope(struct compiler *c, identifier name,
c->u = u;
c->c_nestlevel++;
- if (compiler_use_new_block(c) == NULL)
+
+ block = compiler_new_block(c);
+ if (block == NULL)
return 0;
+ c->u->u_curblock = block;
if (u->u_scope_type != COMPILER_SCOPE_MODULE) {
if (!compiler_set_qualname(c))
@@ -756,16 +759,6 @@ compiler_new_block(struct compiler *c)
}
static basicblock *
-compiler_use_new_block(struct compiler *c)
-{
- basicblock *block = compiler_new_block(c);
- if (block == NULL)
- return NULL;
- c->u->u_curblock = block;
- return block;
-}
-
-static basicblock *
compiler_next_block(struct compiler *c)
{
basicblock *block = compiler_new_block(c);
@@ -1208,22 +1201,12 @@ compiler_addop_j(struct compiler *c, int opcode, basicblock *b, int absolute)
return 1;
}
-/* The distinction between NEW_BLOCK and NEXT_BLOCK is subtle. (I'd
- like to find better names.) NEW_BLOCK() creates a new block and sets
- it as the current block. NEXT_BLOCK() also creates an implicit jump
- from the current block to the new block.
-*/
+/* NEXT_BLOCK() creates an implicit jump from the current block
+ to the new block.
-/* The returns inside these macros make it impossible to decref objects
- created in the local function. Local objects should use the arena.
+ The returns inside this macro make it impossible to decref objects
+ created in the local function. Local objects should use the arena.
*/
-
-
-#define NEW_BLOCK(C) { \
- if (compiler_use_new_block((C)) == NULL) \
- return 0; \
-}
-
#define NEXT_BLOCK(C) { \
if (compiler_next_block((C)) == NULL) \
return 0; \