This page is an accumulation of (we hope) helpful notes, hints, etc., that might be useful to you in doing Project #3. Please look also at the notes from Project #2, which include some comments about general software engineering that apply to this project as well.
Technically, you should compute f(E1,E2) as if it were
tmp1 = E1 tmp2 = E2 f(tmp1,tmp2)That is, arguments (and operands) must be evaluated left to right. This is inconvenient when using a stack machine or of using the strategy of simply pushing function arguments as you compute them if you follow the convention of pushing the first argument last so that it is at the top of the stack. So we'll just allow you to evaluate operands and function arguments in any order, for convenience.
As for any object, the value of a function (as opposed to the value of a call on that function) points to an object that starts with a pointer to a type object for that function object. It can be a pain constructing these type objects, so for this semester, I'll let you take a shortcut. Specifically, I won't create error tests like this one:
f = 3 def f (): ... or x::(int)->int = f x::(int)->int = fso that you can simply fudge and not check the assignment. Likewise, you can fudge on the type pointer you put into the value f that you assign to x: simply use the same type object for all functions, never mind that it is wrong:
.long Py_type # A function type has type 'type', like all types .long 1 # sig_size of 1 (means no parameters) .long 0 # Does not have a starred parameter .long Py_any # Returns type any.
To assemble a 32-bit quantity (an integer or pointer), be sure to use
.long Nand not .word, which creates a 16-bit quantity. Page was last modified on Thu Apr 28 15:39:39 2011.