Environment
metaobjects represent bindings between names and
types.
If the name denotes a variable, it is bound to the type of that variable.
Otherwise, if the name denotes a type, it is bound to the type itself.
Programmers can look up names by the following
member functions on Environment
metaobjects:
Dump()
Dump(int i)
Lookup(Ptree* name, bool& is_type_name, TypeInfo& t)
Lookup(Ptree* name, TypeInfo& t)
LookupClassMetaobject(Ptree* class_name)
RecordPointerVariable(char* name, Class* metaobject)
RecordVariable(char* name, Class* metaobject)
bool Lookup(Ptree* name, bool& is_type_name, TypeInfo& t)
This looks up the given name
into the environment and
returns true
if found. The type of name
is returned at t
.
If the name is a type name, is_type_name
is set to true
. If it is a variable name, is_type_name
is set to false
.
bool Lookup(Ptree* name, TypeInfo& t)
This is an alias of Lookup(Ptree*, bool&, TypeInfo&)
described above.
Class* LookupClassMetaobject(Ptree* class_name)
This looks up the given class_name
and returns the Class
metaobject of the type.
If the class_name
is not found, this function returns nil
(class_name
may be a variable name.)
bool RecordVariable(char* name, Class* metaobject)
This records a variable name
in the environment.
The type of that variable is a class type specified
by metaobject
.
bool RecordPointerVariable(char* name, Class* metaobject)
This records a variable name
in the environment.
The type of that variable is a pointer type to the class specified
by metaobject
.
void Dump()
This is for debugging and prints the elements in the inner-most environment on stderr.
void Dump(int i)
This is for debugging and prints the elements
in the i
-th outer environment on stderr. Dump(0)
is equivalent to Dump()
.