Skip to content

About

Support for for students (Python)

Resources

Stars

76 stars

Watchers

8 watching

Forks

Latest commit

 

History

159 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

python-student-support-code

Support code for students (Python version).

The runtime.c file needs to be compiled by doing the following

   gcc -c -g -std=c99 runtime.c

This will produce a file named runtime.o. The -g flag is to tell the compiler to produce debug information that you may need to use the gdb (or lldb) debugger.

On a Mac with an M1 (ARM) processor, use the -arch x86_64 flag to compile the runtime:

   gcc -c -g -std=c99 -arch x86_64 runtime.c

Interpreting x86

The x86 interpreter interp_x86, defined in the interp_x86 directory, runs the x86 programs produced by every chapter's compiler, both the final x86 and the x86-like languages produced by the select instructions, assign homes and patch instructions passes. Add it to your interp_dict for those passes:

from eval_x86 import interp_x86

interp_dict = {
    ...
    'select_instructions': interp_x86,
    'assign_homes': interp_x86,
    'patch_instructions': interp_x86,
}

Starting from the chapter on tuples, interp_x86 needs to know how many variables each program or function spills to the root stack:

  • Up to Ltup, set the field num_root_spills of the X86Program to the number of tuple variables that have been spilled into the root stack.
  • Beginning with Lfun, set the field num_root_spills of every FunctionDef in the same way.

The interpreter's collect only enlarges the heap and never copies, so it won't reveal mistakes in how your compiler uses the root stack. The tests that run your compiled program with runtime.c will.

About

Support for for students (Python)

Resources

Stars

76 stars

Watchers

8 watching

Forks

Releases

Packages

Contributors

Languages