From: | kamal <kamalpr@hp.com> |
Newsgroups: | comp.compilers |
Date: | Tue, 18 Nov 2008 20:45:41 -0800 (PST) |
Organization: | Compilers Central |
References: | 08-11-054 |
Keywords: | symbols |
Posted-Date: | 19 Nov 2008 19:51:20 EST |
On Nov 14, 12:40 pm, "Tony" <t...@my.net> wrote:
> In C++, there is many kinds of scope: global, translation unit, function,
> local (between the curly brackets within a function), class and probably
> more. How is the concept of scope implemented by a compiler for a program?
>
> Tony
For static variables.
The same way as for C -a tree of stacks. The scope in which you are
executing shows the node where you are present in the tree, If a
symbol is not found within a node, you look above (in the enclosing
scope) till you hit the root node.
For member functions/variables,
there is something called RTTI (run-time type identification) where
the C++ runtime library resolves scope at runtime and enables you to
call the appropriate member function. The instance of class which is
used to call a member function is represented by an implicit pointer
(this) and that is used to access variables when a member function
accesses them.
Hope this answers your question.
regards
-kamal
.
Return to the
comp.compilers page.
Search the
comp.compilers archives again.