[Synopsis-changes] Synopsis/Synopsis/include/Synopsis/AST ASTKit.hh,NONE,1.1 Declared.hh,NONE,1.1 Type.hh,NONE,1.1 TypeKit.hh,NONE,1.1 Visitor.hh,NONE,1.1 AST.hh,1.2,1.3 Declaration.hh,1.2,1.3 SourceFile.hh,1.3,1.4
Stefan Seefeld stefan at synopsis.fresco.orgSun Jan 25 21:21:56 UTC 2004
- Previous message: [Synopsis-changes] Synopsis/Synopsis/include/Synopsis Kit.hh,NONE,1.1 TypedList.hh,NONE,1.1
- Next message: [Synopsis-changes] Synopsis/Synopsis/tests/Cxx-API/Synopsis/AST/scripts SourceFile.py,NONE,1.1
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Update of /cvs/synopsis/Synopsis/include/Synopsis/AST
In directory frida:/tmp/cvs-serv20957/include/Synopsis/AST
Modified Files:
AST.hh Declaration.hh SourceFile.hh
Added Files:
ASTKit.hh Declared.hh Type.hh TypeKit.hh Visitor.hh
Log Message:
more work on C++ API
--- NEW FILE: ASTKit.hh ---
// $Id: ASTKit.hh,v 1.1 2004/01/25 21:21:54 stefan Exp $
//
// Copyright (C) 2004 Stefan Seefeld
// All rights reserved.
// Licensed to the public under the terms of the GNU LGPL (>= 2),
// see the file COPYING for details.
//
#ifndef _Synopsis_AST_ASTKit_hh
#define _Synopsis_AST_ASTKit_hh
#include <Synopsis/Kit.hh>
#include <Synopsis/AST/AST.hh>
#include <Synopsis/AST/SourceFile.hh>
#include <Synopsis/AST/Declaration.hh>
namespace Synopsis
{
namespace AST
{
// basically a factory for all AST types
class ASTKit : public Kit
{
public:
ASTKit() : Kit("Synopsis.AST") {}
AST create_ast() { return create<AST>("AST");}
Declaration create_declaration(const SourceFile &sf, long line, const std::string &lang,
const char *type, const ScopedName &name)
{ return create<Declaration>("Declaration", Tuple(sf, line, lang, type, name));}
Builtin create_builtin(const SourceFile &file, int line, const std::string &lang,
const std::string &type, const ScopedName &name)
{ return create<Builtin>("Builtin", Tuple(file, line, lang, type, name));}
Include create_include(const SourceFile &sf, bool is_macro, bool is_next)
{ return create<Include>("Include", Tuple(sf, is_macro, is_next));}
Macro create_macro(SourceFile &sf, long line, const std::string &lang,
const ScopedName &name, const List ¶meters,
const std::string &text)
{ return create<Macro>("Macro", Tuple(sf, line, lang, "macro",
name, parameters, text));}
Forward create_forward(const SourceFile &file, int line, const std::string &lang,
const std::string &type, const ScopedName &name)
{ return create<Forward>("Forward", Tuple(file, line, lang, type, name));}
MacroCall create_macro_call(const std::string &name, int start, int end, int diff)
{ return create<MacroCall>("MacroCall", Tuple(name, start, end, diff));}
Scope create_scope(const SourceFile &file, int line, const std::string &lang,
const std::string &type, const ScopedName &name)
{ return create<Scope>("Scope", Tuple(file, line, lang, type, name));}
Synopsis::AST::Module
create_module(const SourceFile &file, int line, const std::string &lang,
const std::string &type, const ScopedName &name)
{ return create<Synopsis::AST::Module>("Module", Tuple(file, line, lang, type, name));}
Inheritance create_inheritance(const Type &parent,
const List &attributes)
{ return create<Inheritance>("Inheritance", Tuple(parent, attributes));}
Class create_class(const SourceFile &file, int line, const std::string &lang,
const std::string &type, const ScopedName &name)
{ return create<Class>("Class", Tuple(file, line, lang, type, name));}
Typedef create_typedef(const SourceFile &file, int line, const std::string &lang,
const std::string &type, const ScopedName &name,
const Type &alias, bool constr)
{ return create<Typedef>("Typedef", Tuple(file, line, lang, type, name, alias, constr));}
Enumerator create_enumerator(const SourceFile &file, int line,
const std::string &type, const ScopedName &name,
const std::string &value)
{ return create<Enumerator>("Enumerator", Tuple(file, line, type, name, value));}
Enum create_enum(const SourceFile &file, int line,
const std::string &type, const ScopedName &name)
{ return create<Enum>("Enum", Tuple(file, line, type, name));}
Variable create_variable(const SourceFile &file, int line,
const std::string &type, const ScopedName &name,
const Type &vtype, bool constr)
{ return create<Variable>("Variable", Tuple(file, line, type, name, vtype, constr));}
Const create_const(const SourceFile &file, int line,
const std::string &type, const ScopedName &name,
const Type &ctype, const std::string &value)
{ return create<Const>("Const", Tuple(file, line, type, name, ctype, value));}
Parameter create_parameter(const Modifiers &pre, const Type &type, const Modifiers &post,
const std::string &name, const std::string &value)
{ return create<Parameter>("Parameter", Tuple(pre, type, post, name, value));}
Function create_function(const SourceFile &file, int line,
const std::string &type, const ScopedName &name,
const Modifiers &pre, const Type &ret,
const std::string &realname)
{ return create<Function>("Function", Tuple(file, line, type, name,
pre, ret, realname));}
SourceFile create_source_file(const std::string &name,
const std::string &longname,
const std::string &lang)
{ return create<SourceFile>("SourceFile", Tuple(name, longname, lang));}
};
}
}
#endif
--- NEW FILE: Declared.hh ---
// $Id: Declared.hh,v 1.1 2004/01/25 21:21:54 stefan Exp $
//
// Copyright (C) 2004 Stefan Seefeld
// All rights reserved.
// Licensed to the public under the terms of the GNU LGPL (>= 2),
// see the file COPYING for details.
//
#ifndef _Synopsis_AST_Declared_hh
#define _Synopsis_AST_Declared_hh
#include <Synopsis/AST/Type.hh>
#include <Synopsis/AST/Declaration.hh>
namespace Synopsis
{
namespace AST
{
class Declared : public Named
{
public:
Declared() {}
Declared(const Object &o, bool check = true)
: Named(o, false) { if (check) assert_type("Declared");}
Declaration declaration() const { return attr("declaration")();}
};
//. 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
{
public:
typedef TypedList<Parameter> Parameters;
Template() {}
Template(const Object &o, bool check = true)
: Declared(o, false) { if (check) assert_type("Template");}
Parameters parameters() { return narrow<Parameters>(attr("parameters")());}
// specializations() ???
};
class Parametrized : public Type
{
public:
Parametrized() {}
Parametrized(const Object &o, bool check = true)
: Type(o, false) { if (check) assert_type("Parametrized");}
Template _template() const { return narrow<Template>(attr("template")());}
TypeList parameters() const { return narrow<TypeList>(attr("parameters")());}
};
}
}
#endif
--- NEW FILE: Type.hh ---
// $Id: Type.hh,v 1.1 2004/01/25 21:21:54 stefan Exp $
//
// Copyright (C) 2004 Stefan Seefeld
// All rights reserved.
// Licensed to the public under the terms of the GNU LGPL (>= 2),
// see the file COPYING for details.
//
#ifndef _Synopsis_AST_Type_hh
#define _Synopsis_AST_Type_hh
#include <Synopsis/Object.hh>
#include <Synopsis/TypedList.hh>
namespace Synopsis
{
namespace AST
{
typedef TypedList<std::string> ScopedName;
typedef TypedList<std::string> Modifiers;
class Type : public Object
{
public:
Type() {}
Type(const Object &o, bool check = true)
: Object(o) { if (check) assert_type("Type");}
std::string language() const { return narrow<std::string>(attr("language")());}
void assert_type(const char *type) { Object::assert_type("Synopsis.Type", type);}
};
typedef TypedList<Type> TypeList;
class Named : public Type
{
public:
Named() {}
Named(const Object &o, bool check = true)
: Type(o, false) { if (check) assert_type("Named");}
ScopedName name() const { return attr("name")();}
};
class Base : public Named
{
public:
Base() {}
Base(const Object &o, bool check = true)
: Named(o, false) { if (check) assert_type("Base");}
};
class Dependent : public Named
{
public:
Dependent() {}
Dependent(const Object &o, bool check = true)
: Named(o, false) { if (check) assert_type("Dependent");}
};
class Unknown : public Named
{
public:
Unknown() {}
Unknown(const Object &o, bool check = true)
: Named(o, false) { if (check) assert_type("Unknown");}
};
class Modifier : public Type
{
public:
Modifier() {}
Modifier(const Object &o, bool check = true)
: Type(o, false) { if (check) assert_type("Modifier");}
Modifiers pre() const { return narrow<Modifiers>(attr("premod")());}
Modifiers post() const { return narrow<Modifiers>(attr("postmod")());}
};
class Array : public Type
{
public:
typedef TypedList<size_t> Sizes;
Array() {}
Array(const Object &o, bool check = true)
: Type(o, false) { if (check) assert_type("Array");}
Sizes sizes() const { return narrow<Sizes>(attr("sizes")());}
};
class FunctionPtr : public Type
{
public:
FunctionPtr() {}
FunctionPtr(const Object &o, bool check = true)
: Type(o, false) { if (check) assert_type("Function");}
Type return_type() const { return narrow<Type>(attr("returnType")());}
Modifiers pre() const { return narrow<Modifiers>(attr("premod")());}
TypeList parameters() const { return narrow<TypeList>(attr("parameters")());}
};
}
}
#endif
--- NEW FILE: TypeKit.hh ---
// $Id: TypeKit.hh,v 1.1 2004/01/25 21:21:54 stefan Exp $
//
// Copyright (C) 2004 Stefan Seefeld
// All rights reserved.
// Licensed to the public under the terms of the GNU LGPL (>= 2),
// see the file COPYING for details.
//
#ifndef _Synopsis_AST_TypeKit_hh
#define _Synopsis_AST_TypeKit_hh
#include <Synopsis/Kit.hh>
#include <Synopsis/AST/Type.hh>
#include <Synopsis/AST/Declared.hh>
namespace Synopsis
{
namespace AST
{
// basically a factory for all Type types
class TypeKit : public Kit
{
public:
TypeKit() : Kit("Synopsis.Type") {}
Type create_type(const std::string &lang)
{ return create<Type>("Type", Tuple(lang));}
Named create_named(const std::string &lang, const ScopedName &sn)
{ return create<Named>("Named", Tuple(lang, sn));}
Base create_base(const std::string &lang, const ScopedName &sn)
{ return create<Base>("Base", Tuple(lang, sn));}
Dependent create_dependent(const std::string &lang, const ScopedName &sn)
{ return create<Dependent>("Dependent", Tuple(lang, sn));}
Unknown create_unknown(const std::string &lang, const ScopedName &sn)
{ return create<Unknown>("Unknown", Tuple(lang, sn));}
Declared create_declared(const std::string &lang, const ScopedName &sn,
const Declaration &decl)
{ return create<Declared>("Declared", Tuple(lang, sn, decl));}
Template create_template(const std::string &lang, const ScopedName &sn,
const Declaration &decl, const List ¶ms)
{ return create<Template>("Template", Tuple(lang, sn, decl, params));}
Modifier create_modifier(const std::string &lang, const Type &alias,
const std::string &pre, const std::string &post)
{ return create<Modifier>("Modifier", Tuple(lang, alias, pre, post));}
Array create_array(const std::string &lang, const Type &alias,
const TypedList<size_t> &sizes)
{ return create<Array>("Array", Tuple(lang, alias, sizes));}
Parametrized create_parametrized(const std::string &lang, const Template &t,
const List ¶ms)
{ return create<Parametrized>("Parametrized", Tuple(lang, t, params));}
FunctionPtr create_function_ptr(const std::string &lang, const Type &retn,
const Modifiers &pre, const TypeList ¶ms)
{ return create<FunctionPtr>("Function", Tuple(lang, retn, pre, params));}
};
}
}
#endif
--- NEW FILE: Visitor.hh ---
// $Id: Visitor.hh,v 1.1 2004/01/25 21:21:54 stefan Exp $
//
// Copyright (C) 2004 Stefan Seefeld
// All rights reserved.
// Licensed to the public under the terms of the GNU LGPL (>= 2),
// see the file COPYING for details.
//
#ifndef _Synopsis_AST_Visitor_hh
#define _Synopsis_AST_Visitor_hh
#include <Synopsis/AST/Declaration.hh>
namespace Synopsis
{
namespace AST
{
class Declaration;
class Builtin;
class Macro;
class Scope;
class Module;
class Class;
class Inheritance;
class Forward;
class Typedef;
class Variable;
class Const;
class Enumerator;
class Enum;
class Parameter;
class Function;
//. The Visitor for the AST hierarchy. This class is just an interface
//. really. It is abstract, and you must reimplement any methods you want.
//. The default implementations of the methods call the visit methods for
//. the subclasses of the visited type, eg visit_namespace calls visit_scope
//. which calls visit_declaration.
class Visitor
{
public:
// Abstract destructor makes the class abstract
virtual ~Visitor() = 0;
virtual void visit_declaration(Declaration*);
virtual void visit_builtin(Builtin*);
virtual void visit_macro(Macro*);
virtual void visit_scope(Scope*);
virtual void visit_module(Module*);
virtual void visit_class(Class*);
virtual void visit_inheritance(Inheritance*);
virtual void visit_forward(Forward*);
virtual void visit_typedef(Typedef*);
virtual void visit_variable(Variable*);
virtual void visit_const(Const*);
virtual void visit_enum(Enum*);
virtual void visit_enumerator(Enumerator*);
virtual void visit_parameter(Parameter*);
virtual void visit_function(Function*);
// virtual void visit_operation(Operation*);
};
}
}
#endif
Index: AST.hh
===================================================================
RCS file: /cvs/synopsis/Synopsis/include/Synopsis/AST/AST.hh,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -p -d -r1.2 -r1.3
--- AST.hh 11 Jan 2004 19:46:29 -0000 1.2
+++ AST.hh 25 Jan 2004 21:21:54 -0000 1.3
@@ -10,13 +10,12 @@
#define _Synopsis_AST_AST_hh
#include <Synopsis/Object.hh>
-#include <Synopsis/Callable.hh>
-#include <Synopsis/Dict.hh>
-#include <Synopsis/Tuple.hh>
#include <Synopsis/AST/Declaration.hh>
namespace Synopsis
{
+namespace AST
+{
class AST : public Object
{
@@ -24,11 +23,12 @@ public:
AST() {}
AST(const Object &o) throw(TypeError) : Object(o) { assert_type();}
- Dict files() { return Dict(Callable(attr("files")).call());}
- List declarations() { return List(Callable(attr("declarations")).call());}
+ Dict files() { return Dict(attr("files")());}
+ List declarations() { return List(attr("declarations")());}
void assert_type() throw(TypeError) { Object::assert_type("Synopsis.AST", "AST");}
};
}
+}
#endif
Index: Declaration.hh
===================================================================
RCS file: /cvs/synopsis/Synopsis/include/Synopsis/AST/Declaration.hh,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -p -d -r1.2 -r1.3
--- Declaration.hh 11 Jan 2004 19:46:29 -0000 1.2
+++ Declaration.hh 25 Jan 2004 21:21:54 -0000 1.3
@@ -10,33 +10,294 @@
#define _Synopsis_AST_Declaration_hh
#include <Synopsis/Object.hh>
+#include <Synopsis/AST/Visitor.hh>
#include <Synopsis/AST/SourceFile.hh>
+#include <Synopsis/AST/Type.hh>
namespace Synopsis
{
+namespace AST
+{
+
+enum Access
+{
+ DEFAULT = 0,
+ PUBLIC = 1,
+ PROTECTED = 2,
+ PRIVATE = 3
+};
class Declaration : public Object
{
public:
- Declaration(const Object &o) : Object(o) { assert_type();}
- SourceFile file() { return narrow<SourceFile>(Callable(attr("file")).call());}
- int line() { return narrow<int>(Callable(attr("line")).call());}
- bool language() { return narrow<const char *>(Callable(attr("language")).call());}
- const char *type() { return narrow<const char *>(Callable(attr("type")).call());}
- const char *name() { return narrow<const char *>(Callable(attr("name")).call());}
- List comments() { return List(Callable(attr("comments")).call());}
- void assert_type() throw(TypeError)
- { Object::assert_type("Synopsis.AST", "Declaration");}
+ Declaration() {}
+ Declaration(const Object &o, bool check = true)
+ : Object(o) { if (check) assert_type("Declaration");}
+
+ SourceFile file() const { return narrow<SourceFile>(attr("file")());}
+ long line() const { return narrow<long>(attr("line")());}
+ std::string language() const { return narrow<std::string>(attr("language")());}
+ std::string type() const { return narrow<std::string>(attr("type")());}
+ ScopedName name() const { return attr("name")();}
+ List comments() { return attr("comments")();}
+
+ virtual void accept(Visitor *v) { v->visit_declaration(this);}
+
+ void assert_type(const char *type) { Object::assert_type("Synopsis.AST", type);}
+};
+
+//. A Builtin is a node to be used internally.
+//. Right now it's being used to capture comments
+//. at the end of a scope.
+class Builtin : public Declaration
+{
+public:
+ Builtin() {}
+ Builtin(const Object &o, bool check = true)
+ : Declaration(o, false) { if (check) assert_type("Builtin");}
+
+ virtual void accept(Visitor *v) { v->visit_builtin(this);}
};
class Macro : public Declaration
{
public:
- Macro(const Object &o) : Declaration(o) {}
- List parameters() { return List(Callable(attr("parameters")).call());}
- const char *text() { return narrow<const char *>(Callable(attr("text")).call());}
+ Macro() {}
+ Macro(const Object &o, bool check = true)
+ : Declaration(o, false) { if (check) assert_type("Macro");}
+
+ List parameters() { return attr("parameters")();}
+ std::string text() { return narrow<std::string>(attr("text")());}
+
+ virtual void accept(Visitor *v) { v->visit_macro(this);}
};
+//. Forward declaration. Currently this has no extra attributes.
+class Forward : public Declaration
+{
+public:
+ Forward() {}
+ Forward(const Object &o, bool check = true)
+ : Declaration(o, false) { if (check) assert_type("Forward");}
+
+// //. Returns the Template object if this is a template
+// Template template_type() {}
+
+// //. Sets the Template object for this class. NULL means not a template
+// void set_template_type(Types::Template* type);
+
+ virtual void accept(Visitor *v) { v->visit_forward(this);}
+};
+
+//. Base class for scopes with contained declarations. Each scope has its
+//. own Dictionary of names so far accumulated for this scope. Each scope
+//. also as a complete vector of scopes where name lookup is to proceed if
+//. unsuccessful in this scope. Name lookup is not recursive.
+class Scope : public Declaration
+{
+public:
+ Scope() {}
+ Scope(const Object &o, bool check = true)
+ : Declaration(o, false) { if (check) assert_type("Scope");}
+
+ List declarations() const { return attr("declarations")();}
+
+ virtual void accept(Visitor *v) { v->visit_scope(this);}
+};
+
+//. Module class
+class Module : public Scope
+{
+public:
+ Module() {}
+ Module(const Object &o, bool check = true)
+ : Scope(o, false) { if (check) assert_type("Module");}
+
+ virtual void accept(Visitor *v) { v->visit_module(this);}
+};
+
+//. Inheritance class. This class encapsulates the information about an
+//. inheritance, namely its accessability. Note that classes inherit from
+//. types, not class declarations. As such it's possible to inherit from a
+//. parameterized type, or a declared typedef or class/struct.
+class Inheritance : public Object
+{
+public:
+ Inheritance() {}
+ Inheritance(const Object &o, bool check = true)
+ : Object(o) { if (check) assert_type("Synopsis.AST", "Inheritance");}
+
+ //. Returns the Class object this inheritance refers to. The method
+ //. returns a Type since typedefs to classes are preserved to
+ //. enhance readability of the generated docs. Note that the parent
+ //. may also be a non-declaration type, such as vector<int>
+ Type parent() const { return attr("parent")();}
+
+ //. Returns the attributes of this inheritance
+ List attributes() const { return attr("attributes")();}
+
+ void accept(Visitor *v) { v->visit_inheritance(this);}
+};
+
+//. Class class
+class Class : public Scope
+{
+public:
+ Class() {}
+ Class(const Object &o, bool check = true)
+ : Scope(o, false) { if (check) assert_type("Class");}
+
+ //. Constant version of parents()
+ List parents() const { return attr("parents")();}
+
+// //. Returns the Template object if this is a template
+// Template template_type() { return attr("template_type")();}
+
+// //. Sets the Template object for this class. NULL means not a template
+// void set_template_type(Types::Template* type)
+// {
+// m_template = type;
+// }
+
+ virtual void accept(Visitor *v) { v->visit_class(this);}
+};
+
+//. Typedef declaration
+class Typedef : public Declaration
+{
+public:
+ Typedef() {}
+ Typedef(const Object &o, bool check = true)
+ : Declaration(o, false) { if (check) assert_type("Typedef");}
+
+ //. Returns the Type object this typedef aliases
+ Type alias() const { return attr("alias")();}
+ //. Returns true if the Type object was constructed inside the typedef
+ bool constructed() const { return narrow<bool>(attr("constr")());}
+
+ virtual void accept(Visitor *v) { v->visit_typedef(this);}
+};
+
+//. Enumerator declaration. This is a name with a value in the containing
+//. scope. Enumerators only appear inside Enums via their enumerators()
+//. attribute.
+class Enumerator : public Declaration
+{
+public:
+ Enumerator() {}
+ Enumerator(const Object &o, bool check = true)
+ : Declaration(o, false) { if (check) assert_type("Enumerator");}
+
+ //. Returns the value of this enumerator
+ std::string value() const { return narrow<std::string>(attr("value")());}
+
+ virtual void accept(Visitor *v) { v->visit_enumerator(this);}
+};
+
+//. Enum declaration. An enum contains multiple enumerators.
+class Enum : public Declaration
+{
+public:
+ Enum() {}
+ Enum(const Object &o, bool check = true)
+ : Declaration(o, false) { if (check) assert_type("Enum");}
+
+ //. Returns the vector of Enumerators
+ List enumerators() { return attr("enumerators")();}
+
+ virtual void accept(Visitor *v) { v->visit_enum(this);}
+};
+
+//. Variable declaration
+class Variable : public Declaration
+{
+public:
+ Variable() {}
+ Variable(const Object &o, bool check = true)
+ : Declaration(o, false) { if (check) assert_type("Variable");}
+
+ //. Returns the Type object of this variable
+ Type vtype() const { return attr("vtype")();}
+ //. Returns true if the Type object was constructed inside the variable
+ bool constructed() const { return attr("constr")();}
+ //. Returns the array sizes vector
+ List sizes() const { return attr("sizes")();}
+
+ virtual void accept(Visitor *v) { v->visit_variable(this);}
+};
+
+//. A const is a name with a value and declared type.
+class Const : public Declaration
+{
+public:
+ Const() {}
+ Const(const Object &o, bool check = true)
+ : Declaration(o, false) { if (check) assert_type("Const");}
+
+ //. Returns the Type object of this const
+ Type ctype() const { return attr("ctype")();}
+ //. Returns the value of this enumerator
+ std::string value() const { return narrow<std::string>(attr("value")());}
+
+ virtual void accept(Visitor *v) { v->visit_const(this);}
+};
+
+class Parameter : public Object
+{
+public:
+ Parameter() {}
+ Parameter(const Object &o, bool check = true)
+ : Object(o) { if (check) assert_type("Synopsis.AST", "Parameter");}
+
+ Modifiers premodifiers() const { return narrow<Modifiers>(attr("premodifiers")());}
+ Modifiers postmodifiers() const { return narrow<Modifiers>(attr("postmodifiers")());}
+ Type type() const { return narrow<Type>(attr("type")());}
+ std::string name() const { return narrow<std::string>(attr("identifier")());}
+ std::string value() const { return narrow<std::string>(attr("value")());}
+
+ virtual void accept(Visitor *v) { v->visit_parameter(this);}
+};
+
+//. Function encapsulates a function declaration. Note that names may be
+//. stored in mangled form, and formatters should use real_name() 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:
+ Function() {}
+ Function(const Object &o, bool check = true)
+ : Declaration(o, false) { if (check) assert_type("Function");}
+
+// //. The type of premodifiers
+// typedef std::vector<std::string> Mods;
+
+ //. Returns the return Type
+ Type return_type() { return attr("returnType")();}
+
+ //. Returns the real name of this function
+ ScopedName real_name() { return attr("realname")();}
+
+ //. Returns the vector of parameters
+ // Parameter::vector& parameters()
+
+ //. 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;
+// }
+
+ //. Accept the given visitor
+ virtual void accept(Visitor *v) { v->visit_function(this);}
+};
+
+}
}
#endif
Index: SourceFile.hh
===================================================================
RCS file: /cvs/synopsis/Synopsis/include/Synopsis/AST/SourceFile.hh,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -p -d -r1.3 -r1.4
--- SourceFile.hh 13 Jan 2004 07:42:09 -0000 1.3
+++ SourceFile.hh 25 Jan 2004 21:21:54 -0000 1.4
@@ -10,32 +10,32 @@
#define _Synopsis_AST_SourceFile_hh
#include <Synopsis/Object.hh>
-#include <Synopsis/Tuple.hh>
-#include <Synopsis/Callable.hh>
namespace Synopsis
{
+namespace AST
+{
class SourceFile : public Object
{
public:
SourceFile() {}
SourceFile(const Object &o) : Object(o) {}
- std::string name() { return narrow<std::string>(Callable(attr("filename")).call());}
- std::string long_name() { return narrow<std::string>(Callable(attr("full_filename")).call());}
- bool is_main() { return narrow<bool>(Callable(attr("is_main")).call());}
- void is_main(bool flag) { Callable c(attr("set_is_main")); c.call(Tuple(flag));}
- List includes() { return List(Callable(attr("includes")).call());}
- Dict macro_calls() { return Dict(Callable(attr("macro_calls")).call());}
+ std::string name() const { return narrow<std::string>(attr("filename")());}
+ std::string long_name() const { return narrow<std::string>(attr("full_filename")());}
+ bool is_main() const { return narrow<bool>(attr("is_main")());}
+ void is_main(bool flag) { attr("set_is_main")(Tuple(flag));}
+ List includes() { return attr("includes")();}
+ Dict macro_calls() { return attr("macro_calls")();}
};
class Include : public Object
{
public:
Include(const Object &o) throw(TypeError) : Object(o) { assert_type();}
- SourceFile target() const { return narrow<SourceFile>(Callable(attr("target")).call());}
- bool is_macro() const { return narrow<bool>(Callable(attr("is_macro")).call());}
- bool is_next() const { return narrow<bool>(Callable(attr("is_next")).call());}
+ SourceFile target() const { return narrow<SourceFile>(attr("target")());}
+ bool is_macro() const { return narrow<bool>(attr("is_macro")());}
+ bool is_next() const { return narrow<bool>(attr("is_next")());}
void assert_type() throw(TypeError) { Object::assert_type("Synopsis.AST", "Include");}
};
@@ -51,5 +51,6 @@ public:
};
}
+}
#endif
- Previous message: [Synopsis-changes] Synopsis/Synopsis/include/Synopsis Kit.hh,NONE,1.1 TypedList.hh,NONE,1.1
- Next message: [Synopsis-changes] Synopsis/Synopsis/tests/Cxx-API/Synopsis/AST/scripts SourceFile.py,NONE,1.1
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Synopsis-changes mailing list