Ptree* Comments()
This returns a list of comments preceding the class declaration.
If no comments are given, this function returns nil
.
The compiler recognizes a comment string as a single token.
The comment string includes "//"
or "/* */"
.
The returned value is a list of
Ptree
objects each of which represents a single
comment string (token).
Note: To use this function, run the compiler with the
-C
option.
Ptree* Comments()
This returns a list of comments preceding the member declaration.
If no comments are given, this function returns nil
.
The compiler recognizes a comment string as a single token.
The comment string includes "//"
or "/* */"
.
The returned value is a list of
Ptree
objects each of which represents a single
comment string (token).
Note: To use this function, run the compiler with the
-C
option.
TemplateClass
metaobjects represent template classes.
It is a subclass of Class
.
The metaclass for any template class must be TemplateClass
or its subclass.
Ptree* TemplateDefinition()
This returns the whole definition of the template.
Ptree* TemplateArguments()
This returns template arguments.
Ptree* TranslateInstantiation(Environment* env, Ptree* spec)
This translates a template instantiation. An example of template instantiation is:
template class Foo<int>;
Here, Foo
is a template class.
--- Defualt implementation by Template
This returns spec
.
Class
metaobjects can be used for translating
C functions.
If the compiler encounters a C function declaration, it
calls TranslateMemberFunction()
on the Class
metaobject for C functions.
The Member
metaobject representing the C
function is passed to that member function as an argument.
All C functions are handled by a single Class
metaobject.
If the compiler encounters a C function call, then it
calls TranslateFunctionCall()
on the Class
metaobject for C functions.
To translate C functions, first define the class for the metaobject handling C functions. Then, call this member function:
static void Class::SetMetaclassForFunctions(char* name)
This registers the name
of
the metaclass for C functions. The compiler creates an instance of
this metaclass for handling C functions. The metaclass must be a
subclass of Class
.
This member function must be called just after the compiler has
started. For more information about when it should be called, see the
description of Class::ChangeDefaultMetaclass()
.
TypeInfo
metaobjects represent types.
bool NthTemplateArgument(int nth, TypeInfo& t)
If the type is TemplateType
, this returns
the n-th
(>= 0) template argument
in t
.
If the type is not TemplateType
or
the n-th
template argument does not exist,
this function returns false
.
The example program shown below prints the name and
all the arguments of the given template type.
Suppose that a variable tinfo
is
a TypeInfo
metaobject representing
a template type:
TypeInfo t; tinfo.FullTypeName()->Display(); int i = 0; while (tinfo.NthTemplateArgument(i++, t)) t.FullTypeName()->Display();
Environment
metaobjects represent bindings
between names and types.
Ptree* GetLineNumber(Ptree* expr, int& number)
Returns the name of the file including the source text represented by
expr
.
The line number of that text is stored in number
.
Ptree* IsNamespace()
If this environment represents a name space, then this member function
returns the name of that name space.
Otherwise, it returns nil
.
Shigeru Chiba
Copyright © 2000-2001 Shigeru Chiba. All rights reserved.