Commit 819de6ce authored by Jeremy Hylton's avatar Jeremy Hylton

tabify

Note that ast.c still has a mix of tabs and spaces, because it
attempts to use four-space indents for more of the new code.
parent 18623e25
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -8,7 +8,7 @@
* 2. Builds a symbol table. See symtable.c.
* 3. Generate code for basic blocks. See compiler_mod() in this file.
* 4. Assemble the basic blocks into final code. See assemble() in
* this file.
* this file.
* 5. Optimize the byte code (peephole optimizations). See peephole.c
*
* Note that compiler_mod() suggests module, but the module ast type
......@@ -194,17 +194,17 @@ _Py_Mangle(PyObject *privateobj, PyObject *ident)
}
p = PyString_AsString(privateobj);
nlen = strlen(name);
/* Don't mangle __id__ or names with dots.
/* Don't mangle __id__ or names with dots.
The only time a name with a dot can occur is when
we are compiling an import statement that has a
package name.
The only time a name with a dot can occur is when
we are compiling an import statement that has a
package name.
TODO(jhylton): Decide whether we want to support
mangling of the module name, e.g. __M.X.
*/
TODO(jhylton): Decide whether we want to support
mangling of the module name, e.g. __M.X.
*/
if ((name[nlen-1] == '_' && name[nlen-2] == '_')
|| strchr(name, '.')) {
|| strchr(name, '.')) {
Py_INCREF(ident);
return ident; /* Don't mangle __whatever__ */
}
......@@ -439,7 +439,7 @@ compiler_enter_scope(struct compiler *c, identifier name, void *key,
struct compiler_unit *u;
u = (struct compiler_unit *)PyObject_Malloc(sizeof(
struct compiler_unit));
struct compiler_unit));
if (!u) {
PyErr_NoMemory();
return 0;
......@@ -607,7 +607,7 @@ compiler_next_instr(struct compiler *c, basicblock *b)
assert(b != NULL);
if (b->b_instr == NULL) {
b->b_instr = (struct instr *)PyObject_Malloc(
sizeof(struct instr) * DEFAULT_BLOCK_SIZE);
sizeof(struct instr) * DEFAULT_BLOCK_SIZE);
if (b->b_instr == NULL) {
PyErr_NoMemory();
return -1;
......@@ -627,7 +627,7 @@ compiler_next_instr(struct compiler *c, basicblock *b)
}
b->b_ialloc <<= 1;
tmp = (struct instr *)PyObject_Realloc(
(void *)b->b_instr, newsize);
(void *)b->b_instr, newsize);
if (tmp == NULL) {
PyErr_NoMemory();
return -1;
......@@ -1154,7 +1154,7 @@ compiler_mod(struct compiler *c, mod_ty mod)
case Interactive_kind:
c->c_interactive = 1;
VISIT_SEQ_IN_SCOPE(c, stmt,
mod->v.Interactive.body);
mod->v.Interactive.body);
break;
case Expression_kind:
VISIT_IN_SCOPE(c, expr, mod->v.Expression.body);
......@@ -1538,7 +1538,7 @@ compiler_if(struct compiler *c, stmt_ty s)
compiler_use_next_block(c, next);
ADDOP(c, POP_TOP);
if (s->v.If.orelse)
VISIT_SEQ(c, stmt, s->v.If.orelse);
VISIT_SEQ(c, stmt, s->v.If.orelse);
}
compiler_use_next_block(c, end);
return 1;
......@@ -1786,8 +1786,8 @@ compiler_try_except(struct compiler *c, stmt_ty s)
s->v.TryExcept.handlers, i);
if (!handler->type && i < n-1)
return compiler_error(c, "default 'except:' must be last");
c->u->u_lineno_set = false;
c->u->u_lineno = handler->lineno;
c->u->u_lineno_set = false;
c->u->u_lineno = handler->lineno;
except = compiler_new_block(c);
if (except == NULL)
return 0;
......@@ -2109,7 +2109,7 @@ compiler_visit_stmt(struct compiler *c, stmt_ty s)
case Pass_kind:
break;
case Break_kind:
if (!compiler_in_loop(c))
if (!compiler_in_loop(c))
return compiler_error(c, "'break' outside loop");
ADDOP(c, BREAK_LOOP);
break;
......@@ -2439,20 +2439,20 @@ compiler_compare(struct compiler *c, expr_ty e)
if (cleanup == NULL)
return 0;
VISIT(c, expr,
(expr_ty)asdl_seq_GET(e->v.Compare.comparators, 0));
(expr_ty)asdl_seq_GET(e->v.Compare.comparators, 0));
}
for (i = 1; i < n; i++) {
ADDOP(c, DUP_TOP);
ADDOP(c, ROT_THREE);
ADDOP_I(c, COMPARE_OP,
cmpop((cmpop_ty)(asdl_seq_GET(
e->v.Compare.ops, i - 1))));
e->v.Compare.ops, i - 1))));
ADDOP_JREL(c, JUMP_IF_FALSE, cleanup);
NEXT_BLOCK(c);
ADDOP(c, POP_TOP);
if (i < (n - 1))
VISIT(c, expr,
(expr_ty)asdl_seq_GET(e->v.Compare.comparators, i));
(expr_ty)asdl_seq_GET(e->v.Compare.comparators, i));
}
VISIT(c, expr, (expr_ty)asdl_seq_GET(e->v.Compare.comparators, n - 1));
ADDOP_I(c, COMPARE_OP,
......@@ -2736,7 +2736,7 @@ expr_constant(expr_ty e)
/* __debug__ is not assignable, so we can optimize
* it away in if and while statements */
if (strcmp(PyString_AS_STRING(e->v.Name.id),
"__debug__") == 0)
"__debug__") == 0)
return ! Py_OptimizeFlag;
/* fall through */
default:
......@@ -2883,8 +2883,8 @@ compiler_visit_expr(struct compiler *c, expr_ty e)
int i, n;
/* If expr e has a different line number than the last expr/stmt,
set a new line number for the next instruction.
*/
set a new line number for the next instruction.
*/
if (e->lineno > c->u->u_lineno) {
c->u->u_lineno = e->lineno;
c->u->u_lineno_set = false;
......@@ -2914,10 +2914,10 @@ compiler_visit_expr(struct compiler *c, expr_ty e)
for (i = 0; i < n; i++) {
ADDOP(c, DUP_TOP);
VISIT(c, expr,
(expr_ty)asdl_seq_GET(e->v.Dict.values, i));
(expr_ty)asdl_seq_GET(e->v.Dict.values, i));
ADDOP(c, ROT_TWO);
VISIT(c, expr,
(expr_ty)asdl_seq_GET(e->v.Dict.keys, i));
(expr_ty)asdl_seq_GET(e->v.Dict.keys, i));
ADDOP(c, STORE_SUBSCR);
}
break;
......@@ -3089,13 +3089,13 @@ compiler_pop_fblock(struct compiler *c, enum fblocktype t, basicblock *b)
static int
compiler_in_loop(struct compiler *c) {
int i;
struct compiler_unit *u = c->u;
for (i = 0; i < u->u_nfblocks; ++i) {
if (u->u_fblock[i].fb_type == LOOP)
return 1;
}
return 0;
int i;
struct compiler_unit *u = c->u;
for (i = 0; i < u->u_nfblocks; ++i) {
if (u->u_fblock[i].fb_type == LOOP)
return 1;
}
return 0;
}
/* Raises a SyntaxError and returns 0.
If something goes wrong, a different exception may be raised.
......@@ -3290,7 +3290,7 @@ compiler_visit_slice(struct compiler *c, slice_ty s, expr_context_ty ctx)
int i, n = asdl_seq_LEN(s->v.ExtSlice.dims);
for (i = 0; i < n; i++) {
slice_ty sub = (slice_ty)asdl_seq_GET(
s->v.ExtSlice.dims, i);
s->v.ExtSlice.dims, i);
if (!compiler_visit_nested_slice(c, sub, ctx))
return 0;
}
......@@ -3488,7 +3488,7 @@ the line # increment in each pair generated must be 0 until the remaining addr
increment is < 256. So, in the example above, assemble_lnotab (it used
to be called com_set_lineno) should not (as was actually done until 2.2)
expand 300, 300 to 255, 255, 45, 45,
but to 255, 0, 45, 255, 0, 45.
but to 255, 0, 45, 255, 0, 45.
*/
static int
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment