[Python-checkins] python/dist/src/Python newcompile.c, 1.1.2.99,
1.1.2.100
jhylton at users.sourceforge.net
jhylton at users.sourceforge.net
Fri Apr 23 23:54:05 EDT 2004
Update of /cvsroot/python/python/dist/src/Python
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16140
Modified Files:
Tag: ast-branch
newcompile.c
Log Message:
Generate correct co_firstlineno attribute; fixes test_profile.
Modify compiler_enter_scope() to accept the first lineno as an
argument, fetched from the statement ast or from the current unit's
lineno in the case of lambda. module is hard-coded to start with 1.
Index: newcompile.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/Attic/newcompile.c,v
retrieving revision 1.1.2.99
retrieving revision 1.1.2.100
diff -C2 -d -r1.1.2.99 -r1.1.2.100
*** newcompile.c 24 Apr 2004 03:01:54 -0000 1.1.2.99
--- newcompile.c 24 Apr 2004 03:54:02 -0000 1.1.2.100
***************
*** 129,132 ****
--- 129,133 ----
struct fblockinfo u_fblock[CO_MAXBLOCKS];
+ int u_firstlineno; /* the first lineno of the block */
int u_lineno; /* the lineno for the current stmt */
bool u_lineno_set; /* boolean to indicate whether instr
***************
*** 157,164 ****
int a_lineno; /* last lineno of emitted instruction */
int a_lineno_off; /* bytecode offset of last lineno */
- int a_firstlineno; /* first line number in code */
};
! static int compiler_enter_scope(struct compiler *, identifier, void *);
static void compiler_free(struct compiler *);
static int compiler_new_block(struct compiler *);
--- 158,164 ----
int a_lineno; /* last lineno of emitted instruction */
int a_lineno_off; /* bytecode offset of last lineno */
};
! static int compiler_enter_scope(struct compiler *, identifier, void *, int);
static void compiler_free(struct compiler *);
static int compiler_new_block(struct compiler *);
***************
*** 419,423 ****
static int
! compiler_enter_scope(struct compiler *c, identifier name, void *key)
{
struct compiler_unit *u;
--- 419,424 ----
static int
! compiler_enter_scope(struct compiler *c, identifier name, void *key,
! int lineno)
{
struct compiler_unit *u;
***************
*** 444,447 ****
--- 445,449 ----
u->u_tmpname = 0;
u->u_nfblocks = 0;
+ u->u_firstlineno = lineno;
u->u_lineno = 0;
u->u_lineno_set = false;
***************
*** 1117,1121 ****
return NULL;
}
! if (!compiler_enter_scope(c, module, mod))
return NULL;
switch (mod->kind) {
--- 1119,1123 ----
return NULL;
}
! if (!compiler_enter_scope(c, module, mod, 1))
return NULL;
switch (mod->kind) {
***************
*** 1242,1246 ****
if (args->defaults)
VISIT_SEQ(c, expr, args->defaults);
! if (!compiler_enter_scope(c, s->v.FunctionDef.name, (void *)s))
return 0;
--- 1244,1249 ----
if (args->defaults)
VISIT_SEQ(c, expr, args->defaults);
! if (!compiler_enter_scope(c, s->v.FunctionDef.name, (void *)s,
! s->lineno))
return 0;
***************
*** 1301,1305 ****
VISIT_SEQ(c, expr, s->v.ClassDef.bases);
ADDOP_I(c, BUILD_TUPLE, n);
! if (!compiler_enter_scope(c, s->v.ClassDef.name, (void *)s))
return 0;
c->u->u_private = s->v.ClassDef.name;
--- 1304,1309 ----
VISIT_SEQ(c, expr, s->v.ClassDef.bases);
ADDOP_I(c, BUILD_TUPLE, n);
! if (!compiler_enter_scope(c, s->v.ClassDef.name, (void *)s,
! s->lineno))
return 0;
c->u->u_private = s->v.ClassDef.name;
***************
*** 1351,1355 ****
if (args->defaults)
VISIT_SEQ(c, expr, args->defaults);
! if (!compiler_enter_scope(c, name, (void *)e))
return 0;
c->u->u_argcount = asdl_seq_LEN(args->args);
--- 1355,1359 ----
if (args->defaults)
VISIT_SEQ(c, expr, args->defaults);
! if (!compiler_enter_scope(c, name, (void *)e, c->u->u_lineno))
return 0;
c->u->u_argcount = asdl_seq_LEN(args->args);
***************
*** 3246,3250 ****
freevars, cellvars,
filename, c->u->u_name,
! a->a_firstlineno,
a->a_lnotab);
error:
--- 3250,3254 ----
freevars, cellvars,
filename, c->u->u_name,
! c->u->u_firstlineno,
a->a_lnotab);
error:
***************
*** 3283,3287 ****
goto error;
- a.a_firstlineno = -1;
/* Emit code in reverse postorder from dfs. */
for (i = a.a_nblocks - 1; i >= 0; i--) {
--- 3287,3290 ----
***************
*** 3291,3302 ****
i, a.a_postorder[i], b->b_iused, b->b_ialloc,
b->b_next);
! for (j = 0; j < b->b_iused; j++) {
! if (a.a_firstlineno < 0) {
! a.a_firstlineno = b->b_instr[0].i_lineno;
! a.a_lineno = a.a_firstlineno;
! }
if (!assemble_emit(&a, &b->b_instr[j]))
goto error;
- }
}
fprintf(stderr, "\n");
--- 3294,3300 ----
i, a.a_postorder[i], b->b_iused, b->b_ialloc,
b->b_next);
! for (j = 0; j < b->b_iused; j++)
if (!assemble_emit(&a, &b->b_instr[j]))
goto error;
}
fprintf(stderr, "\n");
More information about the Python-checkins
mailing list