Changes between Version 2 and Version 3 of Scopes


Ignore:
Timestamp:
04/20/11 08:28:30 (15 years ago)
Author:
Stephen Siegel
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Scopes

    v2 v3  
    44This will require changes to front, model, dynamic, state layers.
    55
    6 == Changed to model layer ==
     6Scopes form a tree.
     7
     8== model layer ==
     9
     10A local variable will now have associated to it an instance of ScopeIF:
    711
    812ScopeIF:
     
    1519 * ScopeIF newScope(ScopeIF parentScope);
    1620 * LocationIF newLocation(ScopeIF scope, ...);
    17  * methods to create locations need to specify scope instead of function
     21 * all methods to create locations need to specify scope instead of function
    1822
    1923FunctionIF:
    20  * /* creating a function creates one scope automatically: */
     24 * creating a function creates one scope automatically: the outer-most local scope
    2125 * ScopeIF outerScope();
     26
     27
     28== front layer ==
     29
     30In generating model, you need to keep track of which scope you are in.
     31Use a stack.
     32When you enter a block, push.  When you exit a block pop.
     33
     34== state layer ==
     35
     36The state of a Frame on the call stack now changes.
     37In place of list of local variables, there is stack of scopes: each entry gives the state of that scope.
     38The state of the scope gives the list of variable values in that scope.
     39
     40== transitions ==
     41
     42when moving from location to another, look at scope.  If it changes, you need to pop up the tree, and push down the tree,
     43to get to the new scope.   When you push, you need to initialize the new local variables correctly.
     44
     45Find out in C what happens when you jump into the middle of a block: how are variables initialized?