December 2009
Intermediate to advanced
380 pages
9h 2m
English
struct scopes behave just like local scopes from a scope tree construction point of view. They are just another node in the scope tree. That means we’ll have StructSymbol nodes as well as LocalScope, MethodSymbol, and GlobalScope nodes. The scope tree for the following sample program appears in Figure 16, Scope tree for nested data aggregates:
| symtab/aggr/t.cymbol | |
| ① | // start of global scope // |
| ② | struct A { |
| | int x; |
| ③ | struct B { int y; }; |
| | B b; |
| ④ | struct C { int z; }; |
| | C c; |
| | }; |
| | A a; |
| | |
| ⑤ | void f() |
| ⑥ | { |
| ⑦ | struct D { |
| | int i; |
| | }; |
| | D d; |
| | d.i = a.b.y; |
| | } |

Read now
Unlock full access