[Python-checkins] python/dist/src/Python newcompile.c, 1.1.2.53, 1.1.2.54

jhylton at users.sourceforge.net jhylton at users.sourceforge.net
Mon Aug 25 19:21:15 EDT 2003


Update of /cvsroot/python/python/dist/src/Python
In directory sc8-pr-cvs1:/tmp/cvs-serv10183

Modified Files:
      Tag: ast-branch
	newcompile.c 
Log Message:
Handle lineno offsets greater than 255.


Index: newcompile.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/Attic/newcompile.c,v
retrieving revision 1.1.2.53
retrieving revision 1.1.2.54
diff -C2 -d -r1.1.2.53 -r1.1.2.54
*** newcompile.c	28 Apr 2003 16:35:40 -0000	1.1.2.53
--- newcompile.c	26 Aug 2003 01:21:13 -0000	1.1.2.54
***************
*** 2159,2164 ****
  		return 1;
  
- 	/* XXX Need logic for line number gaps greater than 255. */
- 	assert(d_lineno < 256);
  	if (d_bytecode > 255) {
  		int i, nbytes, ncodes = d_bytecode / 255;
--- 2159,2162 ----
***************
*** 2181,2195 ****
  		a->a_lnotab_off += ncodes * 2;
  	}
! 	else {
  		len = PyString_GET_SIZE(a->a_lnotab);
  		if (a->a_lnotab_off + 2 >= len) {
  			if (_PyString_Resize(&a->a_lnotab, len * 2) < 0)
  				return 0;
! 	    }
  		lnotab = PyString_AS_STRING(a->a_lnotab) + a->a_lnotab_off;
  		a->a_lnotab_off += 2;
  	}
- 	*lnotab++ = d_bytecode;
- 	*lnotab++ = d_lineno;
  	a->a_lineno = i->i_lineno;
  	return 1;
--- 2179,2218 ----
  		a->a_lnotab_off += ncodes * 2;
  	}
! 	assert(d_bytecode < 255);
! 	if (d_lineno > 255) {
! 		int i, nbytes, ncodes = d_lineno / 255;
! 		nbytes = a->a_lnotab_off + 2 * ncodes;
! 		len = PyString_GET_SIZE(a->a_lnotab);
! 		if (nbytes >= len) {
! 			if (len * 2 < nbytes)
! 				len = nbytes;
! 			else
! 				len *= 2;
! 			if (_PyString_Resize(&a->a_lnotab, len) < 0)
! 				return 0;
! 		}
! 		lnotab = PyString_AS_STRING(a->a_lnotab) + a->a_lnotab_off;
! 		*lnotab++ = 255;
! 		*lnotab++ = d_bytecode;
! 		d_bytecode = 0;
! 		for (i = 1; i < ncodes; i++) {
! 			*lnotab++ = 255;
! 			*lnotab++ = 0;
! 		}
! 		d_lineno -= ncodes * 255;
! 		a->a_lnotab_off += ncodes * 2;
! 	}
! 
! 	if (d_bytecode)	{
  		len = PyString_GET_SIZE(a->a_lnotab);
  		if (a->a_lnotab_off + 2 >= len) {
  			if (_PyString_Resize(&a->a_lnotab, len * 2) < 0)
  				return 0;
! 		}
  		lnotab = PyString_AS_STRING(a->a_lnotab) + a->a_lnotab_off;
  		a->a_lnotab_off += 2;
+ 		*lnotab++ = d_bytecode;
+ 		*lnotab++ = d_lineno;
  	}
  	a->a_lineno = i->i_lineno;
  	return 1;





More information about the Python-checkins mailing list