Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
LinkdefReader.h
Go to the documentation of this file.
1 // @(#)root/core/utils:$Id: LinkdefReader.h 28529 2009-05-11 16:43:35Z pcanal $
2 // Author: Velislava Spasova September 2010
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2011, Rene Brun, Fons Rademakers and al. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef R__LINKDEFREADER_H
13 #define R__LINKDEFREADER_H
14 
15 //////////////////////////////////////////////////////////////////////////
16 // //
17 // LinkdefReader //
18 // //
19 // Linkdef.h parsing class //
20 // //
21 //////////////////////////////////////////////////////////////////////////
22 
23 #include <fstream>
24 #include <vector>
25 #include <string>
26 #include <map>
27 #include "llvm/ADT/StringRef.h"
28 
29 #include "TClingUtils.h"
30 
31 namespace cling {
32  class Interpreter;
33 }
34 
35 class SelectionRules;
36 class PragmaCreateCollector;
37 class PragmaLinkCollector;
38 class LinkdefReaderPragmaHandler;
39 class PragmaExtraInclude;
40 
41 class LinkdefReader {
42 
43 public:
44  LinkdefReader(cling::Interpreter &interp,
45  ROOT::TMetaUtils::RConstructorTypes &IOConstructorTypes);
46 
47  bool LoadIncludes(std::string &extraInclude);
48  bool Parse(SelectionRules &sr, llvm::StringRef code, const std::vector<std::string> &parserArgs, const char *llvmdir);
49 
50 
51 private:
52 
53  friend class PragmaCreateCollector;
54  friend class PragmaLinkCollector;
55  friend class LinkdefReaderPragmaHandler;
56  friend class PragmaExtraInclude;
57 
58  long fLine; // lines count - for error messages
59  long fCount; // Number of rules created so far.
60  SelectionRules *fSelectionRules; // set of rules being filleed.
61  std::string fIncludes; // Extra set of file to be included by the intepreter.
62  ROOT::TMetaUtils::RConstructorTypes *fIOConstructorTypesPtr; // List of values of #pragma ioctortype
63  cling::Interpreter &fInterp; // Our interpreter
64 
65  enum EPragmaNames { // the processed pragma attributes
66  kAll,
67  kNestedclasses,
68  kDefinedIn,
69  kGlobal,
70  kFunction,
71  kEnum,
72  kClass,
73  kTypeDef,
74  kNamespace,
75  kUnion,
76  kStruct,
77  kOperators,
78  kIOCtorType,
79  kIgnore,
80  kUnknown
81  };
82 
83  enum ECppNames { // the processes pre-processor directives
84  kPragma,
85  kIfdef,
86  kEndif,
87  kIf,
88  kElse,
89  kUnrecognized
90  };
91 
92  // used to create string to tag kind association to use in switch constructions
93  static std::map<std::string, EPragmaNames> fgMapPragmaNames;
94  static std::map<std::string, ECppNames> fgMapCppNames;
95 
96  static void PopulatePragmaMap();
97  static void PopulateCppMap();
98 
99  struct Options;
100 
101  bool AddInclude(const std::string& include);
102  bool AddRule(const std::string& ruletype,
103  const std::string& identifier,
104  bool linkOn,
105  bool requestOnlyTClass,
106  Options *option = 0);
107 
108  bool ProcessFunctionPrototype(std::string &proto, bool &name); // transforms the function prototypes to a more unified form
109  bool ProcessOperators(std::string &pattern); // transforms the operators statement to the suitable function pattern
110 
111  bool IsPatternRule(const std::string &rule_token); // is it name or pattern
112 };
113 
114 #endif
115