[Python-checkins] python/dist/src/Python newcompile.c,1.1.2.28,1.1.2.29

tim_one@users.sourceforge.net tim_one@users.sourceforge.net
2003年3月25日 08:27:01 -0800


Update of /cvsroot/python/python/dist/src/Python
In directory sc8-pr-cvs1:/tmp/cvs-serv19075/Python
Modified Files:
 Tag: ast-branch
	newcompile.c 
Log Message:
Trimmed trailing whitespace.
Index: newcompile.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/Attic/newcompile.c,v
retrieving revision 1.1.2.28
retrieving revision 1.1.2.29
diff -C2 -d -r1.1.2.28 -r1.1.2.29
*** newcompile.c	25 Mar 2003 16:17:04 -0000	1.1.2.28
--- newcompile.c	25 Mar 2003 16:26:54 -0000	1.1.2.29
***************
*** 312,320 ****
 	else
 		c->u = NULL;
! 	
 	return 1; /* XXX void? */
 }
 
! /* Allocate a new block and return its index in c_blocks. 
 Returns -1 on error.
 */
--- 312,320 ----
 	else
 		c->u = NULL;
! 
 	return 1; /* XXX void? */
 }
 
! /* Allocate a new block and return its index in c_blocks.
 Returns -1 on error.
 */
***************
*** 329,333 ****
 	u = c->u;
 	if (u->u_nblocks == u->u_nalloc) {
! 		int newsize = ((u->u_nalloc + u->u_nalloc) 
 			 * sizeof(struct basicblock *));
 		u->u_blocks = (struct basicblock **)PyObject_Realloc(
--- 329,333 ----
 	u = c->u;
 	if (u->u_nblocks == u->u_nalloc) {
! 		int newsize = ((u->u_nalloc + u->u_nalloc)
 			 * sizeof(struct basicblock *));
 		u->u_blocks = (struct basicblock **)PyObject_Realloc(
***************
*** 407,411 ****
 		oldsize = sizeof(struct basicblock);
 		if (b->b_ialloc > DEFAULT_BLOCK_SIZE)
! 			oldsize += ((b->b_ialloc - DEFAULT_BLOCK_SIZE) 
 				 * sizeof(struct instr));
 		newsize = oldsize + b->b_ialloc * sizeof(struct instr);
--- 407,411 ----
 		oldsize = sizeof(struct basicblock);
 		if (b->b_ialloc > DEFAULT_BLOCK_SIZE)
! 			oldsize += ((b->b_ialloc - DEFAULT_BLOCK_SIZE)
 				 * sizeof(struct instr));
 		newsize = oldsize + b->b_ialloc * sizeof(struct instr);
***************
*** 450,454 ****
 
 static int
! compiler_addop_o(struct compiler *c, int opcode, PyObject *dict, 
 		 PyObject *o)
 {
--- 450,454 ----
 
 static int
! compiler_addop_o(struct compiler *c, int opcode, PyObject *dict,
 		 PyObject *o)
 {
***************
*** 468,472 ****
 		Py_DECREF(v);
 	}
! 	else 
 		arg = PyInt_AsLong(v);
 	return compiler_addop_i(c, opcode, arg);
--- 468,472 ----
 		Py_DECREF(v);
 	}
! 	else
 		arg = PyInt_AsLong(v);
 	return compiler_addop_i(c, opcode, arg);
***************
*** 516,520 ****
 from the current block to the new block.
 */
! 
 
 #define NEW_BLOCK(C) { \
--- 516,520 ----
 from the current block to the new block.
 */
! 
 
 #define NEW_BLOCK(C) { \
***************
*** 554,558 ****
 
 /* VISIT and VISIT_SEQ takes an ASDL type as their second argument. They use
! the ASDL name to synthesize the name of the C type and the visit function. 
 */
 
--- 554,558 ----
 
 /* VISIT and VISIT_SEQ takes an ASDL type as their second argument. They use
! the ASDL name to synthesize the name of the C type and the visit function.
 */
 
***************
*** 561,565 ****
 		return 0; \
 }
! 						 
 #define VISIT_SEQ(C, TYPE, SEQ) { \
 	int i; \
--- 561,565 ----
 		return 0; \
 }
! 
 #define VISIT_SEQ(C, TYPE, SEQ) { \
 	int i; \
***************
*** 612,616 ****
 	assert(s->kind == FunctionDef_kind);
 
! 	fprintf(stderr, "function %s\n", 
 		PyString_AS_STRING(s->v.FunctionDef.name));
 
--- 612,616 ----
 	assert(s->kind == FunctionDef_kind);
 
! 	fprintf(stderr, "function %s\n",
 		PyString_AS_STRING(s->v.FunctionDef.name));
 
***************
*** 631,635 ****
 	if (!compiler_nameop(c, s->v.FunctionDef.name, Store))
 		return 0;
! 		
 	return 1;
 }
--- 631,635 ----
 	if (!compiler_nameop(c, s->v.FunctionDef.name, Store))
 		return 0;
! 
 	return 1;
 }
***************
*** 676,680 ****
 {
 	int end, next, elif = 1;
! 	
 	assert(s->kind == If_kind);
 	end = compiler_new_block(c);
--- 676,680 ----
 {
 	int end, next, elif = 1;
! 
 	assert(s->kind == If_kind);
 	end = compiler_new_block(c);
***************
*** 764,768 ****
 
 	/* XXX should the two POP instructions be in a separate block
! 	 if there is no else clause ? 
 	*/
 	if (orelse == -1)
--- 764,768 ----
 
 	/* XXX should the two POP instructions be in a separate block
! 	 if there is no else clause ?
 	*/
 	if (orelse == -1)
***************
*** 776,780 ****
 		VISIT_SEQ(c, stmt, s->v.While.orelse);
 	compiler_use_block(c, end);
! 	
 	return 1;
 }
--- 776,780 ----
 		VISIT_SEQ(c, stmt, s->v.While.orelse);
 	compiler_use_block(c, end);
! 
 	return 1;
 }
***************
*** 807,811 ****
 		break;
 	}
! 	
 	return 1;
 }
--- 807,811 ----
 		break;
 	}
! 
 	return 1;
 }
***************
*** 873,879 ****
 		VISIT(c, expr, s->v.Assign.value);
 		for (i = 0; i < n; i++) {
! 			if (i < n - 1) 
 				ADDOP(c, DUP_TOP);
! 			VISIT(c, expr, 
 			 (expr_ty)asdl_seq_GET(s->v.Assign.targets, i));
 		}
--- 873,879 ----
 		VISIT(c, expr, s->v.Assign.value);
 		for (i = 0; i < n; i++) {
! 			if (i < n - 1)
 				ADDOP(c, DUP_TOP);
! 			VISIT(c, expr,
 			 (expr_ty)asdl_seq_GET(s->v.Assign.targets, i));
 		}
***************
*** 976,980 ****
 }
 
! static int 
 binop(struct compiler *c, operator_ty op)
 {
--- 976,980 ----
 }
 
! static int
 binop(struct compiler *c, operator_ty op)
 {
***************
*** 984,988 ****
 	case Sub:
 		return BINARY_SUBTRACT;
! 	case Mult: 
 		return BINARY_MULTIPLY;
 	case Div:
--- 984,988 ----
 	case Sub:
 		return BINARY_SUBTRACT;
! 	case Mult:
 		return BINARY_MULTIPLY;
 	case Div:
***************
*** 995,999 ****
 	case Pow:
 		return BINARY_POWER;
! 	case LShift: 
 		return BINARY_LSHIFT;
 	case RShift:
--- 995,999 ----
 	case Pow:
 		return BINARY_POWER;
! 	case LShift:
 		return BINARY_LSHIFT;
 	case RShift:
***************
*** 1001,1005 ****
 	case BitOr:
 		return BINARY_OR;
! 	case BitXor: 
 		return BINARY_XOR;
 	case BitAnd:
--- 1001,1005 ----
 	case BitOr:
 		return BINARY_OR;
! 	case BitXor:
 		return BINARY_XOR;
 	case BitAnd:
***************
*** 1011,1015 ****
 }
 
! static int 
 inplace_binop(struct compiler *c, operator_ty op)
 {
--- 1011,1015 ----
 }
 
! static int
 inplace_binop(struct compiler *c, operator_ty op)
 {
***************
*** 1019,1023 ****
 	case Sub:
 		return INPLACE_SUBTRACT;
! 	case Mult: 
 		return INPLACE_MULTIPLY;
 	case Div:
--- 1019,1023 ----
 	case Sub:
 		return INPLACE_SUBTRACT;
! 	case Mult:
 		return INPLACE_MULTIPLY;
 	case Div:
***************
*** 1030,1034 ****
 	case Pow:
 		return INPLACE_POWER;
! 	case LShift: 
 		return INPLACE_LSHIFT;
 	case RShift:
--- 1030,1034 ----
 	case Pow:
 		return INPLACE_POWER;
! 	case LShift:
 		return INPLACE_LSHIFT;
 	case RShift:
***************
*** 1036,1040 ****
 	case BitOr:
 		return INPLACE_OR;
! 	case BitXor: 
 		return INPLACE_XOR;
 	case BitAnd:
--- 1036,1040 ----
 	case BitOr:
 		return INPLACE_OR;
! 	case BitXor:
 		return INPLACE_XOR;
 	case BitAnd:
***************
*** 1129,1133 ****
 		break;
 	}
! 	
 	assert(op);
 	ADDOP_O(c, op, name, names);
--- 1129,1133 ----
 		break;
 	}
! 
 	assert(op);
 	ADDOP_O(c, op, name, names);
***************
*** 1181,1190 ****
 		ADDOP(c, ROT_THREE);
 		/* XXX We're casting a void* to an int in the next stmt -- bad */
! 		ADDOP_I(c, COMPARE_OP, 
 			(cmpop_ty)asdl_seq_GET(e->v.Compare.ops, i - 1));
 		ADDOP_JREL(c, JUMP_IF_FALSE, cleanup);
 		NEXT_BLOCK(c);
 		ADDOP(c, POP_TOP);
! 	} 
 	VISIT(c, expr, asdl_seq_GET(e->v.Compare.comparators, n - 1));
 	ADDOP_I(c, COMPARE_OP,
--- 1181,1190 ----
 		ADDOP(c, ROT_THREE);
 		/* XXX We're casting a void* to an int in the next stmt -- bad */
! 		ADDOP_I(c, COMPARE_OP,
 			(cmpop_ty)asdl_seq_GET(e->v.Compare.ops, i - 1));
 		ADDOP_JREL(c, JUMP_IF_FALSE, cleanup);
 		NEXT_BLOCK(c);
 		ADDOP(c, POP_TOP);
! 	}
 	VISIT(c, expr, asdl_seq_GET(e->v.Compare.comparators, n - 1));
 	ADDOP_I(c, COMPARE_OP,
***************
*** 1199,1207 ****
 	}
 	return 1;
! }	
 
 
! 	
! static int 
 compiler_visit_expr(struct compiler *c, expr_ty e)
 {
--- 1199,1207 ----
 	}
 	return 1;
! }
 
 
! 
! static int
 compiler_visit_expr(struct compiler *c, expr_ty e)
 {
***************
*** 1209,1213 ****
 
 	switch (e->kind) {
! case BoolOp_kind: 
 		return compiler_boolop(c, e);
 		break;
--- 1209,1213 ----
 
 	switch (e->kind) {
! case BoolOp_kind:
 		return compiler_boolop(c, e);
 		break;
***************
*** 1253,1257 ****
 		ADDOP(c, UNARY_CONVERT);
 		break;
! case Num_kind: 
 		ADDOP_O(c, LOAD_CONST, e->v.Num.n, consts);
 		break;
--- 1253,1257 ----
 		ADDOP(c, UNARY_CONVERT);
 		break;
! case Num_kind:
 		ADDOP_O(c, LOAD_CONST, e->v.Num.n, consts);
 		break;
***************
*** 1287,1291 ****
 		VISIT(c, slice, e->v.Subscript.slice);
 		break;
! case Name_kind: 
 		return compiler_name(c, e);
 		break;
--- 1287,1291 ----
 		VISIT(c, slice, e->v.Subscript.slice);
 		break;
! case Name_kind:
 		return compiler_name(c, e);
 		break;
***************
*** 1303,1307 ****
 }
 
! static int 
 compiler_augassign(struct compiler *c, stmt_ty s)
 {
--- 1303,1307 ----
 }
 
! static int
 compiler_augassign(struct compiler *c, stmt_ty s)
 {
***************
*** 1337,1341 ****
 }
 
! static int 
 compiler_push_fblock(struct compiler *c, enum fblocktype t, int b)
 {
--- 1337,1341 ----
 }
 
! static int
 compiler_push_fblock(struct compiler *c, enum fblocktype t, int b)
 {
***************
*** 1374,1378 ****
 		loc = Py_None;
 	}
! 	u = Py_BuildValue("(ziOO)", c->c_filename, c->u->u_lineno, 
 			 Py_None, loc);
 	if (!u)
--- 1374,1378 ----
 		loc = Py_None;
 	}
! 	u = Py_BuildValue("(ziOO)", c->c_filename, c->u->u_lineno,
 			 Py_None, loc);
 	if (!u)
***************
*** 1497,1503 ****
 	}
 	code = PyString_AS_STRING(a->a_bytecode) + a->a_offset;
! 	fprintf(stderr, 
 		"emit %3d %-15s %5d\toffset = %2d\tsize = %d\text = %d\n",
! 		i->i_opcode, opnames[i->i_opcode], 
 		i->i_oparg, a->a_offset, size, ext);
 	a->a_offset += size;
--- 1497,1503 ----
 	}
 	code = PyString_AS_STRING(a->a_bytecode) + a->a_offset;
! 	fprintf(stderr,
 		"emit %3d %-15s %5d\toffset = %2d\tsize = %d\text = %d\n",
! 		i->i_opcode, opnames[i->i_opcode],
 		i->i_oparg, a->a_offset, size, ext);
 	a->a_offset += size;
***************
*** 1555,1559 ****
 		}
 	}
! 	
 	return 1;
 }
--- 1555,1559 ----
 		}
 	}
! 
 	return 1;
 }
***************
*** 1601,1605 ****
 	if (!filename)
 		goto error;
! 	
 	nlocals = PyList_GET_SIZE(c->u->u_varnames);
 	co = PyCode_New(c->u->u_argcount, nlocals, stackdepth(c), 0,
--- 1601,1605 ----
 	if (!filename)
 		goto error;
! 
 	nlocals = PyList_GET_SIZE(c->u->u_varnames);
 	co = PyCode_New(c->u->u_argcount, nlocals, stackdepth(c), 0,
***************
*** 1607,1611 ****
 			nil, nil,
 			filename, c->u->u_name,
! 			0, 
 			filename); /* XXX lnotab */
 error:
--- 1607,1611 ----
 			nil, nil,
 			filename, c->u->u_name,
! 			0,
 			filename); /* XXX lnotab */
 error:
***************
*** 1616,1620 ****
 	Py_XDECREF(name);
 	return co;
! 			
 }
 
--- 1616,1620 ----
 	Py_XDECREF(name);
 	return co;
! 
 }
 
***************
*** 1626,1630 ****
 	PyCodeObject *co = NULL;
 
! 	/* Make sure every block that falls off the end returns None. 
 	 XXX NEXT_BLOCK() isn't quite right, because if the last
 	 block ends with a jump or return b_next shouldn't set.
--- 1626,1630 ----
 	PyCodeObject *co = NULL;
 
! 	/* Make sure every block that falls off the end returns None.
 	 XXX NEXT_BLOCK() isn't quite right, because if the last
 	 block ends with a jump or return b_next shouldn't set.

AltStyle によって変換されたページ (->オリジナル) /