Computer Laboratory

Detailed Description

A description of TESLA instrumentation to perform.

Definition at line 55 of file Manifest.h.

#include "Manifest.h"

Public Member Functions

 Manifest (const Manifest &)
 
 ~Manifest ()
 
llvm::ArrayRef< const Usage * > RootAutomata () const
 Top-level automata (named explicitly in code). More...
 
const AutomataMapAllAutomata () const
 All automata in the manifest file. More...
 
const AutomatonFindAutomaton (const Identifier &) const
 Find the tesla::Automaton named by an tesla::Identifier. More...
 
const AutomatonFindAutomaton (const Location &) const
 Find the tesla::Automaton defined at a tesla::Location. More...
 

Static Public Member Functions

static Manifestload (llvm::raw_ostream &Err, Automaton::Type=Automaton::Deterministic, llvm::StringRef Path=defaultLocation())
 Load a tesla::Manifest from a named file. More...
 
static llvm::StringRef defaultLocation ()
 The default location to look for a TESLA manifest. More...
 

Constructor & Destructor Documentation

tesla::Manifest::Manifest ( const Manifest )
tesla::Manifest::~Manifest ( )

Definition at line 65 of file Manifest.cpp.

65  {
66  for (auto i : Automata)
67  delete i.second;
68 }

Member Function Documentation

const AutomataMap& tesla::Manifest::AllAutomata ( ) const
inline

All automata in the manifest file.

Definition at line 64 of file Manifest.h.

Referenced by main().

64 { return Descriptions; }

+ Here is the caller graph for this function:

StringRef tesla::Manifest::defaultLocation ( )
static

The default location to look for a TESLA manifest.

This could be specified by a command-line option.

Definition at line 153 of file Manifest.cpp.

References tesla::ManifestName().

153 { return ManifestName; }

+ Here is the call graph for this function:

const Automaton * tesla::Manifest::FindAutomaton ( const Identifier ID) const

Find the tesla::Automaton named by an tesla::Identifier.

Definition at line 70 of file Manifest.cpp.

References tesla::panic(), and tesla::ShortName().

Referenced by main().

70  {
71  auto i = Automata.find(ID);
72  if (i == Automata.end())
73  panic("TESLA manifest does not contain assertion " + ShortName(ID));
74 
75  return i->second;
76 }

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const Automaton * tesla::Manifest::FindAutomaton ( const Location Loc) const

Find the tesla::Automaton defined at a tesla::Location.

Definition at line 78 of file Manifest.cpp.

78  {
79  Identifier ID;
80  *ID.mutable_location() = Loc;
81 
82  return FindAutomaton(ID);
83 }
Manifest * tesla::Manifest::load ( llvm::raw_ostream &  Err,
Automaton::Type  = Automaton::Deterministic,
llvm::StringRef  Path = defaultLocation() 
)
static

Load a tesla::Manifest from a named file.

Definition at line 87 of file Manifest.cpp.

Referenced by main().

87  {
88  llvm::SourceMgr SM;
89  OwningPtr<MemoryBuffer> Buffer;
90 
91  error_code Error = MemoryBuffer::getFile(Path, Buffer);
92  if (Error != 0) {
93  ErrorStream
94  << "Failed to open TESLA analysis file '" << Path << "': "
95  << Error.message() << "\n"
96  ;
97 
98  return NULL;
99  }
100 
101  OwningPtr<ManifestFile> Protobuf(new ManifestFile);
102  if (!::google::protobuf::TextFormat::ParseFromString(Buffer->getBuffer(),
103  Protobuf.get())) {
104  ErrorStream << "Error parsing TESLA manifest '" << Path << "'\n";
105  return NULL;
106  }
107 
108  AutomataMap Descriptions;
109  map<Identifier,const Automaton*> Automata;
110 
111  // Note the top-level automata that are explicitly named as roots.
112  ArrayRef<const Usage*> Roots(Protobuf->root().data(), Protobuf->root_size());
113  map<Identifier,const Usage*> Uses;
114  for (auto *U : Roots)
115  Uses[U->identifier()] = U;
116 
117  for (auto& A : Protobuf->automaton())
118  Descriptions[A.identifier()] = &A;
119 
120  int id = 0;
121  for (auto i : Descriptions) {
122  const Identifier& ID = i.first;
123  const AutomatonDescription *Descrip = i.second;
124 
125  OwningPtr<NFA> N(NFA::Parse(Descrip, Uses[ID], id++));
126  if (!N) {
127  for (auto i : Automata) delete i.second;
128  for (auto i : Descriptions) delete i.second;
129  return NULL;
130  }
131 
132  OwningPtr<Automaton> Result;
133 
134  if (T == Automaton::Unlinked)
135  Result.reset(N.take());
136 
137  else {
138  N.reset(N->Link(Descriptions));
139 
140  if (T == Automaton::Linked)
141  Result.reset(N.take());
142 
143  else
144  Result.reset(DFA::Convert(N.get()));
145  }
146 
147  Automata[ID] = Result.take();
148  }
149 
150  return new Manifest(Protobuf, Descriptions, Automata, Roots);
151 }

+ Here is the caller graph for this function:

llvm::ArrayRef<const Usage*> tesla::Manifest::RootAutomata ( ) const
inline

Top-level automata (named explicitly in code).

Definition at line 61 of file Manifest.h.

61 { return Roots; }

The documentation for this class was generated from the following files: