10-01: Static vs. Dynamic Typing
- The dynamic type of an object is the class C that is used in the “new C” expression that created it;
- The static type of an expression captures all dynamic types the expression could have;
- Soundness theorem: for all expressions E: dynamic_type(E) = static_type(E).
11-03: Activation Records
The information needed to manage one procedure activation is called an activation record (AR) or frame.
11-06: Stack Machines
- Only storage is a stack;
- An instruction
- Pops n operands from the stack;
- Computes the operation F using the operands;
- Pushes the result r on the stack.
- An n-register stack machine:
- Conceptually, keep the top n locations of the pure stack machine’s stack in registers.
- Consider a 1-register stack machine:
- The register is called the accumulator.
- Algorithm:
- Consider an expression :
- Note are subexpressions.
- For each :
- Compute ;
- Push result on the stack.
- Pop n - 1 values from the stack, compute op;
- Store result in the accumulator.
- Consider an expression :