[Python-checkins] python/dist/src/Python newcompile.c,1.1.2.7,1.1.2.8
jhylton@users.sourceforge.net
jhylton@users.sourceforge.net
Mon, 30 Sep 2002 13:47:25 -0700
Update of /cvsroot/python/python/dist/src/Python
In directory usw-pr-cvs1:/tmp/cvs-serv11676/Python
Modified Files:
Tag: ast-branch
newcompile.c
Log Message:
Generates executable code for some simple statements.
This checkin includes many disparate changes necessary to get code
generation working at all.
The primary changes are:
- addition of basic assembler to generate bytecode from
basicblocks
- Explicitly mark instructions that contain jumps, using
ADDOP_JREL() and ADDOP_JABS().
- Change ADDOP_O() to store an integer in the instr immediately
rather than deferring this until a later phase. ADDOP_O()
takes an extra argument, the name of the dict.
Extend struct compiler with metadata and const / varname dicts needed
to generate code objects.
Use NEXT_BLOCK() in a few tested cases to generate correct control
flow.
Index: newcompile.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/Attic/newcompile.c,v
retrieving revision 1.1.2.7
retrieving revision 1.1.2.8
diff -C2 -d -r1.1.2.7 -r1.1.2.8
*** newcompile.c 27 Sep 2002 23:17:05 -0000 1.1.2.7
--- newcompile.c 30 Sep 2002 20:47:23 -0000 1.1.2.8
***************
*** 33,36 ****
--- 33,43 ----
/* info that changes for each code block */
PySTEntryObject *c_ste;
+
+ PyObject *c_name;
+ PyObject *c_consts;
+ PyObject *c_names;
+ PyObject *c_varnames;
+
+ int c_argcount;
[...1186 lines suppressed...]
!
! /* Emit code in reverse postorder from dfs. */
! for (i = a.a_nblocks - 1; i >= 0; i--) {
! struct basicblock *b = c->c_blocks[a.a_postorder[i]];
! fprintf(stderr, "block %d(%d): used=%d alloc=%d\n",
! i, a.a_postorder[i], b->b_iused, b->b_ialloc);
! for (j = 0; j < b->b_iused; j++) {
! if (!assemble_emit(&a, &b->b_instr[j]))
! goto error;
! }
! }
!
! if (_PyString_Resize(&a.a_bytecode, a.a_offset) < 0)
! goto error;
!
! co = makecode(c, &a);
! error:
! assemble_free(&a);
! return co;
}