Synopsis - Cross-Reference

File: /Synopsis/Parsers/C/ASGTranslator.hh
 1//
 2// Copyright (C) 2005 Stefan Seefeld
 3// All rights reserved.
 4// Licensed to the public under the terms of the GNU LGPL (>= 2),
 5// see the file COPYING for details.
 6//
 7
 8#ifndef ASGTranslator_hh_
 9#define ASGTranslator_hh_
10
11#include <Synopsis/ASG/ASGKit.hh>
12#include <Synopsis/PTree.hh>
13#include <Synopsis/Buffer.hh>
14#include <stack>
15
16using namespace Synopsis;
17
18class ASGTranslator : private PTree::Visitor
19{
20public:
21  ASGTranslator(std::string const &filename,
22		std::string const &base_path, bool primary_file_only,
23		IR a, bool v, bool d);
24
25  void translate(PTree::Node *, Buffer &);
26
27private:
28  typedef std::stack<ASG::Scope> ScopeStack;
29
30  virtual void visit(PTree::List *);
31  virtual void visit(PTree::Declarator *);
32  virtual void visit(PTree::Declaration *);
33  virtual void visit(PTree::FunctionDefinition *);
34  virtual void visit(PTree::ClassSpec *);
35  virtual void visit(PTree::EnumSpec *);
36  virtual void visit(PTree::Typedef *);
37
38  void translate_parameters(PTree::Node *,
39			    ASG::TypeIdList, ASG::Function::Parameters &);
40
41  void add_comments(ASG::Declaration, PTree::Node *);
42  //. Update positional information for the given
43  //. node. This will reset 'my_lineno' and may change
44  //. 'my_file'.
45  //. Return whether or not the node should be translated,
46  //. according to the current file and the 'primary_file_only' flag.
47  bool update_position(PTree::Node *);
48
49  //. look up and return the named type. If this is a derived type,
50  //. it may create a modifier and return that.
51  ASG::TypeId lookup(PTree::Encoding const &name);
52  ASG::TypeId lookup_function_types(PTree::Encoding const &name, ASG::TypeIdList &);
53
54
55  void declare(ASG::Declaration);
56  ASG::TypeId declare_type(ScopedName name, ASG::Declaration declaration);
57  ASG::TypeId declare_type(ScopedName name);
58
59  PTree::Encoding::iterator decode_type(PTree::Encoding::iterator, ASG::TypeId &);
60  PTree::Encoding::iterator decode_func_ptr(PTree::Encoding::iterator,
61					    ASG::TypeId &type,
62					    ASG::Modifiers &postmod);
63  PTree::Encoding::iterator decode_name(PTree::Encoding::iterator,
64					std::string &name);
65
66
67  Python::Object      qname_;
68  ASG::ASGKit         asg_kit_;
69  SourceFileKit       sf_kit_;
70  Python::List        declarations_;
71  Python::Dict        types_;
72  Python::Dict        files_;
73  SourceFile          file_;
74  std::string         raw_filename_;
75  std::string         base_path_;
76  bool                primary_file_only_;
77  unsigned long       lineno_;
78  ScopeStack          scope_;
79  bool                verbose_;
80  bool                debug_;
81  Buffer             *buffer_;
82  PTree::Declaration *declaration_;
83  //. True if we have just seen a class-specifier or enum-specifier
84  //. inside a decl-specifier-seq.
85  bool                defines_class_or_enum_;
86  PTree::Encoding     name_;
87};
88
89#endif
90