symbol table
play

Symbol Table 0 ref := EnterId(Stacktop) ref Id size Id age - PowerPoint PPT Presentation

Symbol Table 0 ref := EnterId(Stacktop) ref Id size Id age Id Max Id next 1 Symbol Table 0 ref := EnterId(Stacktop) ref Id size Id age Id Max Id next HASH(size) 2 Symbol Table size 4 ref := EnterId(Stacktop) (0,4),


  1. Symbol Table 0 ref := EnterId(Stacktop) ref Id size Id age Id Max Id next 1

  2. Symbol Table 0 ref := EnterId(Stacktop) ref Id size Id age Id Max Id next HASH(size) 2

  3. Symbol Table size 4 ref := EnterId(Stacktop) (0,4), 1, ... ref Id size Id age Id Max Id next HASH(size) 3

  4. Symbol Table size 4 ref := EnterId(Stacktop) ref^.namekind := variable ref^.address := ... (0,4), 1, ... variable ... ... ref Id size Id age Id Max Id next HASH(size) 4

  5. Symbol Table size 4 ref := EnterId(Stacktop-1) (0,4), 1, ... variable ... ref Id size Id age Id Max Id next HASH(age) 5

  6. Symbol Table sizeage 7 ref := EnterId(Stacktop-1) (0,4), 1, ... variable ... ref Id size Id age Id Max (4,3), 1, ... Id next HASH(age) 6

  7. Symbol Table sizeage 7 ref := EnterId(Stacktop-1) ref^.namekind := variable ref^.address := ... (0,4), 1, ... variable ... ... ref Id size Id age Id Max (4,3), 1, ... variable ... Id next HASH(age) 7

  8. Symbol Table sizeage 7 ref := EnterId(Stacktop-2) (0,4), 1, ... variable ... ref Id size Id age Id Max (4,3), 1, ... variable ... Id next HASH(Max) 8

  9. Symbol Table sizeageMax 10 ref := EnterId(Stacktop-2) ref^.namekind := constant ref^.value := ... (7,3), 1, ... (0,4), 1, ... constant ... variable ... ref Id size Id age Id Max (4,3), 1, ... variable ... Id next HASH(Max) 9

  10. EnterId Notes: Later entries are ahead of earlier entries. The symbol table is “Stack-like” EnterId is like push. Later removals will be pops. EnterId fills in some fields. The caller fills in rest. ALL other fixed fields & All fields for this variant. The caller **ALWAYS** fills in the tag field, namekind. The name itself is stored indirectly in a “spelling table.” 10

  11. Symbol Table sizeageMax 10 ref := LookupID(stacktop) (7,3), 1, ... (0,4), 1, ... constant ... variable ... ref Id size Id next Id Max (4,3), 1, ... variable ... Id age 11

  12. Symbol Table sizeageMax 10 ref := LookupID(stacktop) miss (7,3), 1, ... (0,4), 1, ... constant ... variable ... search ref Id size Id next Id Max (4,3), 1, ... variable ... Id age HASH(size) 12

  13. Symbol Table sizeageMax 10 ref := LookupID(stacktop) hit (7,3), 1, ... (0,4), 1, ... constant ... variable ... search ref Id size Id next Id Max (4,3), 1, ... variable ... Id age HASH(size) 13

  14. Symbol Table sizeageMax 10 ref := LookupID(stacktop) (7,3), 1, ... (0,4), 1, ... constant ... variable ... ref Id size Id next Id Max (4,3), 1, ... variable ... Id age HASH(size) 14

  15. Symbol Table sizeageMax 10 ref := LookupID(stacktop-1) (7,3), 1, ... (0,4), 1, ... constant ... variable ... ref Id size miss Id next Id Max (4,3), 1, ... variable ... Id age search HASH(next) 15

  16. Symbol Table sizeageMax 10 ref := LookupID(stacktop-1) (7,3), 1, ... (0,4), 1, ... constant ... variable ... ref NIL Id size Id next Id Max (4,3), 1, ... variable ... Id age search HASH(next) 16

  17. LookupId Notes: The caller gets back a pointer if the name is stored. Otherwise NIL. The pointer gives access to all stored data. 17

Recommend


More recommend