IUCompilerCourse / Essentials-of-Compilation

A book about compiling Racket and Python to x86-64 assembly
1.28k stars 140 forks source link

Chapter 9 / Python: any_tuple_load #119

Open proglang opened 2 years ago

proglang commented 2 years ago

The translation of any_tuple_load at the end of section 9.5 is weird.

jsiek commented 2 years ago

The index argument of any_tuple_load is required (statically) to be an integer. So no ValueOf's are needed. I've updated the type checker to make this clear.

jsiek commented 2 years ago

Regarding any_len, why not untagged? Because it's difficult to give a type to the result of untagging the tuple. I use to do that, but it was a pain.

Why return an untagged integer? Because when we use any_len inside of the translation of any_tuple_load in the reveal_casts pass, we want the integer for purposes of doing the bounds check.

jsiek commented 2 years ago

Regarding any_tuple_load translating to any_tuple_load... the later should be renamed to unsafe_any_tuple_load.

jsiek commented 2 years ago

What was the inconsistency regarding the typing of any_tuple_load?

jsiek commented 2 years ago

I see that the cast insertion for subscript was broken in the book, and too limited in the implementation. I've fixed that now. Sorry for these bugs!