[Synopsis-cvs] CVS: Synopsis/Synopsis/Parser/C++/syn ast.cc,1.13 ast.hh,1.15 builder.cc,1.34 builder.hh,1.27 decoder.cc,1.16 dumper.cc,1.17 linkstore.cc,1.12 swalker-syntax.cc,1.16 swalker.cc,1.58 swalker.hh,1.25 synopsis.cc,1.41 synopsis.hh,1.28 type.cc,1.11 type.hh,1.12
Stephen Davies chalky at users.sourceforge.netSun Oct 20 08:39:03 UTC 2002
- Previous message: [Synopsis-cvs] CVS: Synopsis/demo/Boost Makefile,1.3
- Next message: [Synopsis-cvs] CVS: Synopsis/Synopsis/Formatter ASCII.py,1.29 Dot.py,1.28
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Update of /cvsroot/synopsis/Synopsis/Synopsis/Parser/C++/syn
In directory usw-pr-cvs1:/tmp/cvs-serv12770/Synopsis/Parser/C++/syn
Modified Files:
ast.cc ast.hh builder.cc builder.hh decoder.cc dumper.cc
linkstore.cc swalker-syntax.cc swalker.cc swalker.hh
synopsis.cc synopsis.hh type.cc type.hh
Log Message:
Much improved template support, including Function Templates.
Index: ast.hh
===================================================================
RCS file: /cvsroot/synopsis/Synopsis/Synopsis/Parser/C++/syn/ast.hh,v
retrieving revision 1.13
retrieving revision 1.15
diff -C2 -d -r1.13 -r1.15
*** ast.hh 25 Jan 2002 14:24:33 -0000 1.13
--- ast.hh 20 Oct 2002 15:38:09 -0000 1.15
***************
*** 58,63 ****
};
! //. Encapsulation of one Comment, which may span multiple lines
! class Comment
{
public:
--- 58,68 ----
};
! //. Encapsulation of one Comment, which may span multiple lines.
! //. Each comment encapsulates one /* */ block or a block of // comments on
! //. adjacent lines. If extract_tails is set, then comments will be added
! //. even when they are not adjacent to a declaration - these comments will be
! //. marked as "suspect". Most of these will be discarded by the Linker, unless
! //. they have appropriate markings such as "//.< comment for previous decl"
! class Comment : public cleanup
{
public:
***************
*** 66,70 ****
//. Constructor
! Comment(const std::string& file, int line, const std::string& text);
//
--- 71,75 ----
//. Constructor
! Comment(const std::string& file, int line, const std::string& text, bool suspect=false);
//
***************
*** 84,87 ****
--- 89,98 ----
text() const { return m_text; }
+ //. Sets whether this comment is suspicious
+ void set_suspect(bool suspect) { m_suspect = suspect; }
+
+ //. Returns whether this comment is suspicious
+ bool is_suspect() const { return m_suspect; }
+
private:
//. The filename
***************
*** 91,94 ****
--- 102,108 ----
//. The text
std::string m_text;
+ //. True if this comment is probably not needed. The exception is comments
+ //. which will be used as "tails", eg: //.< comment for previous decl
+ bool m_suspect;
}; // class Comment
***************
*** 100,104 ****
//. to work however, you must be careful to use the same strings for
//. constructing the names from, for example from a dictionary.
! class Declaration
{
public:
--- 114,118 ----
//. to work however, you must be careful to use the same strings for
//. constructing the names from, for example from a dictionary.
! class Declaration : public cleanup
{
public:
***************
*** 358,361 ****
--- 372,378 ----
Typedef(const std::string& file, int line, const std::string& type, const ScopedName& name, Types::Type* alias, bool constr);
+ //. Destructor
+ ~Typedef();
+
//. Accepts the given AST::Visitor
virtual void
***************
*** 392,395 ****
--- 409,415 ----
Variable(const std::string& file, int line, const std::string& type, const ScopedName& name, Types::Type* vtype, bool constr);
+ //. Destructor
+ ~Variable();
+
//. Accepts the given AST::Visitor
virtual void
***************
*** 496,499 ****
--- 516,520 ----
//. Returns the Type object of this const
+
Types::Type*
ctype() { return m_ctype; }
***************
*** 513,517 ****
//. Parameter encapsulates one parameter to a function
! class Parameter {
public:
//. The type of modifiers such as 'in', 'out'
--- 534,539 ----
//. Parameter encapsulates one parameter to a function
! class Parameter : public cleanup
! {
public:
//. The type of modifiers such as 'in', 'out'
***************
*** 524,527 ****
--- 546,552 ----
Parameter(const Mods& pre, Types::Type* type, const Mods& post, const std::string& name, const std::string& value);
+ //. Destructor
+ ~Parameter();
+
//. Accept the given AST::Visitor. Note this is not derived from
//. Declaration so it is not a virtual method.
***************
*** 569,623 ****
//. Function encapsulates a function declaration. Note that names may be
//. stored in mangled form, and formatters should use realname() to get
! //. the unmangled version.
class Function : public Declaration
{
public:
! //. The type of premodifiers
! typedef std::vector<std::string> Mods;
! //. A vector of Function objects
! typedef std::vector<Function*> vector;
! //. Constructor
! Function(
! const std::string& file, int line, const std::string& type, const ScopedName& name,
! const Mods& premod, Types::Type* ret, const std::string& realname
! );
! //. Destructor. Recursively destroys parameters
! ~Function();
! //. Accept the given visitor
! virtual void
! accept(Visitor*);
! //
! // Attribute Methods
! //
! //. Returns the premodifier vector
! Mods&
! premodifier() { return m_pre; }
! //. Returns the return Type
! Types::Type*
! return_type() { return m_ret; }
! //. Returns the real name of this function
! const std::string&
! realname() const { return m_realname; }
! //. Returns the vector of parameters
! Parameter::vector&
! parameters() { return m_params; }
private:
! //. The premodifier vector
! Mods m_pre;
! //. The return type
! Types::Type* m_ret;
! //. The real (unmangled) name
! std::string m_realname;
! //. The vector of parameters
! Parameter::vector m_params;
}; // class Function
--- 594,659 ----
//. Function encapsulates a function declaration. Note that names may be
//. stored in mangled form, and formatters should use realname() to get
! //. the unmangled version. If this is a function template, use the
! //. template_type() method to get at the template type
class Function : public Declaration
{
public:
! //. The type of premodifiers
! typedef std::vector<std::string> Mods;
! //. A vector of Function objects
! typedef std::vector<Function*> vector;
! //. Constructor
! Function(
! const std::string& file, int line, const std::string& type, const ScopedName& name,
! const Mods& premod, Types::Type* ret, const std::string& realname
! );
! //. Destructor. Recursively destroys parameters
! ~Function();
! //. Accept the given visitor
! virtual void
! accept(Visitor*);
! //
! // Attribute Methods
! //
! //. Returns the premodifier vector
! Mods&
! premodifier() { return m_pre; }
! //. Returns the return Type
! Types::Type*
! return_type() { return m_ret; }
! //. Returns the real name of this function
! const std::string&
! realname() const { return m_realname; }
! //. Returns the vector of parameters
! Parameter::vector&
! parameters() { return m_params; }
!
! //. Returns the Template object if this is a template
! Types::Template*
! template_type() { return m_template; }
!
! //. Sets the Template object for this class. NULL means not a template
! void
! set_template_type(Types::Template* type) { m_template = type; }
private:
! //. The premodifier vector
! Mods m_pre;
! //. The return type
! Types::Type* m_ret;
! //. The real (unmangled) name
! std::string m_realname;
! //. The vector of parameters
! Parameter::vector m_params;
! //. The Template Type for this class if it's a template
! Types::Template* m_template;
}; // class Function
Index: dumper.cc
===================================================================
RCS file: /cvsroot/synopsis/Synopsis/Synopsis/Parser/C++/syn/dumper.cc,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** dumper.cc 7 Mar 2002 04:43:54 -0000 1.16
--- dumper.cc 20 Oct 2002 15:38:10 -0000 1.17
***************
*** 113,117 ****
void TypeFormatter::visit_func_ptr(Types::FuncPtr* type)
{
! std::string str = "(*)(";
if (type->parameters().size()) {
str += format(type->parameters().front());
--- 113,117 ----
void TypeFormatter::visit_func_ptr(Types::FuncPtr* type)
{
! std::string str = format(type->returnType()) + "(";
if (type->parameters().size()) {
str += format(type->parameters().front());
***************
*** 244,254 ****
std::cout << m_indent_string << "template<";
std::vector<std::string> names;
! Types::Type::vector::iterator iter = templ->parameters().begin();
while (iter != templ->parameters().end())
! names.push_back(format(*iter++));
std::cout << join(names, ", ") << ">" << std::endl;
m_scope.pop_back();
! }
! std::cout << m_indent_string << clas->type() << " " << clas->name();
if (clas->parents().size()) {
std::cout << ": ";
--- 244,258 ----
std::cout << m_indent_string << "template<";
std::vector<std::string> names;
! AST::Parameter::vector::iterator iter = templ->parameters().begin();
while (iter != templ->parameters().end())
! names.push_back(formatParam(*iter++));
std::cout << join(names, ", ") << ">" << std::endl;
m_scope.pop_back();
! if (clas->type().substr(0, 9) == "template ")
! std::cout << m_indent_string << (clas->type().c_str()+9) << " " << clas->name();
! else
! std::cout << m_indent_string << clas->type() << " " << clas->name();
! } else
! std::cout << m_indent_string << clas->type() << " " << clas->name();
if (clas->parents().size()) {
std::cout << ": ";
***************
*** 286,289 ****
--- 290,304 ----
visit(oper->comments());
std::cout << m_indent_string;
+ if (oper->template_type()) {
+ m_scope.push_back(oper->name().back());
+ Types::Template* templ = oper->template_type();
+ std::cout << m_indent_string << "template<";
+ std::vector<std::string> names;
+ AST::Parameter::vector::iterator iter = templ->parameters().begin();
+ while (iter != templ->parameters().end())
+ names.push_back(formatParam(*iter++));
+ std::cout << join(names, ", ") << ">" << std::endl;
+ m_scope.pop_back();
+ }
if (!isStructor(oper) && oper->return_type()) std::cout << format(oper->return_type()) + " ";
std::cout << oper->realname() << "(";
Index: type.hh
===================================================================
RCS file: /cvsroot/synopsis/Synopsis/Synopsis/Parser/C++/syn/type.hh,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** type.hh 11 Oct 2002 05:58:21 -0000 1.11
--- type.hh 20 Oct 2002 15:38:10 -0000 1.12
***************
*** 14,18 ****
// Forward declare AST::Declaration
namespace AST
! { class Declaration; }
//. The Type hierarchy
--- 14,18 ----
// Forward declare AST::Declaration
namespace AST
! { class Declaration; class Parameter; }
//. The Type hierarchy
***************
*** 108,112 ****
! //. Template parameter dependant types have a possibly scoped name, but no
//. known type. Member types of template-parameters will be scoped, eg:
//.
--- 108,112 ----
! //. Template parameter dependent types have a possibly scoped name, but no
//. known type. Member types of template-parameters will be scoped, eg:
//.
***************
*** 114,122 ****
//.
//. Here T::B is a depandant type, and so is T.
! class Dependant : public Named
{
public:
//. Constructor
! Dependant(const ScopedName& name);
//. Accept the given visitor
virtual void
--- 114,122 ----
//.
//. Here T::B is a depandant type, and so is T.
! class Dependent : public Named
{
public:
//. Constructor
! Dependent(const ScopedName& name);
//. Accept the given visitor
virtual void
***************
*** 155,161 ****
//. Template types are declared template types. They have a name, a
! //. declaration (which is an AST::Class) and a vector of Types used to
! //. declare this template. Currently these must be Base types, but a
! //. future version may implement a special type for this purpose.
class Template : public Declared
{
--- 155,162 ----
//. Template types are declared template types. They have a name, a
! //. declaration (which is an AST::Class) and a vector of parameters
! //. declare this template. Each parameter (using AST::Parameter) should be
! //. either the correct type for non-type parameters, or a Dependent for type
! //. parameters. In either case, there may be default values.
class Template : public Declared
{
***************
*** 164,169 ****
typedef std::vector<Types::Template*> vector;
//. Constructor
! Template(const ScopedName& name , AST::Declaration* decl, const Type::vector& params);
//. Accept the given visitor
--- 165,173 ----
typedef std::vector<Types::Template*> vector;
+ //. A vector of Parameter objects
+ typedef std::vector<AST::Parameter*> param_vector;
+
//. Constructor
! Template(const ScopedName& name , AST::Declaration* decl, const param_vector& params);
//. Accept the given visitor
***************
*** 176,184 ****
//. Constant version of parameters()
! const Type::vector&
parameters() const { return m_params; }
//. Returns the vector of parameter Types
! Type::vector&
parameters() { return m_params; }
--- 180,188 ----
//. Constant version of parameters()
! const param_vector&
parameters() const { return m_params; }
//. Returns the vector of parameter Types
! param_vector&
parameters() { return m_params; }
***************
*** 194,198 ****
private:
//. The parameters
! Type::vector m_params;
//. The vector of specializations for this template
--- 198,202 ----
private:
//. The parameters
! param_vector m_params;
//. The vector of specializations for this template
***************
*** 366,370 ****
virtual void visit_named(Named*);
virtual void visit_base(Base*);
! virtual void visit_dependant(Dependant*);
virtual void visit_declared(Declared*);
virtual void visit_template_type(Template*);
--- 370,374 ----
virtual void visit_named(Named*);
virtual void visit_base(Base*);
! virtual void visit_dependent(Dependent*);
virtual void visit_declared(Declared*);
virtual void visit_template_type(Template*);
- Previous message: [Synopsis-cvs] CVS: Synopsis/demo/Boost Makefile,1.3
- Next message: [Synopsis-cvs] CVS: Synopsis/Synopsis/Formatter ASCII.py,1.29 Dot.py,1.28
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Synopsis-changes mailing list