Computer Laboratory

Detailed Description

A state in a TESLA DFA.

Definition at line 50 of file State.h.

#include "State.h"

Classes

class  Builder
 

Public Member Functions

 ~State ()
 
void AddTransition (llvm::OwningPtr< Transition > &)
 
size_t ID () const
 
std::string Name (bool QuoteNonNumeric=true) const
 
bool IsStartState () const
 
bool IsAcceptingState () const
 
void UpdateReferences (const Transition &)
 
const ReferenceVector References () const
 
uint32_t Mask () const
 
std::string String () const
 
std::string Dot () const
 
Transition *const * begin () const
 
Transition *const * end () const
 

Static Public Member Functions

static Builder NewBuilder (StateVector &S)
 

Friends

class internal::DFABuilder
 

Constructor & Destructor Documentation

tesla::State::~State ( )

Definition at line 59 of file State.cpp.

59  {
60  for (Transition *T : Transitions) delete T;
61 }

Member Function Documentation

void tesla::State::AddTransition ( llvm::OwningPtr< Transition > &  )

Definition at line 63 of file State.cpp.

Referenced by tesla::Transition::Register().

64 {
65  Transitions.push_back(T.take());
66 }

+ Here is the caller graph for this function:

Transition* const* tesla::State::begin ( ) const
inline

Definition at line 93 of file State.h.

Referenced by tesla::internal::DFABuilder::ConstructDFA().

93 { return Transitions.begin(); }

+ Here is the caller graph for this function:

string tesla::State::Dot ( ) const

Definition at line 153 of file State.cpp.

References tesla::InstanceName().

153  {
154  assert(VariableReferences);
155  string NameExtra = name.empty() ? "" : ("\\n\\\"" + name + "\\\"");
156 
157  return (
158  Twine(ID())
159  + " [ label = \""
160  + "state " + Twine(ID())
161  + NameExtra
162  + "\\n" + InstanceName(Refs, false) + "\""
163  + (IsAcceptingState() ? ", shape = doublecircle" : "")
164  + " ];"
165  ).str();
166 }

+ Here is the call graph for this function:

Transition* const* tesla::State::end ( ) const
inline

Definition at line 94 of file State.h.

Referenced by tesla::internal::DFABuilder::ConstructDFA().

94 { return Transitions.end(); }

+ Here is the caller graph for this function:

size_t tesla::State::ID ( ) const
inline

Definition at line 82 of file State.h.

Referenced by tesla::internal::DFABuilder::ConstructDFA(), and tesla::Transition::Register().

82 { return id; }

+ Here is the caller graph for this function:

bool tesla::State::IsAcceptingState ( ) const
inline

Definition at line 85 of file State.h.

85 { return accept; }
bool tesla::State::IsStartState ( ) const
inline

Definition at line 84 of file State.h.

84 { return start; }
uint32_t tesla::State::Mask ( ) const

Definition at line 113 of file State.cpp.

113  {
114  uint32_t Mask = 0;
115  ReferenceVector Refs = References();
116 
117  for (size_t i = 0; i < Refs.size(); i++) {
118  if (Refs[i] && Refs[i]->type() == Argument::Variable)
119  Mask |= (1 << i);
120  }
121 
122 
123  return Mask;
124 }
string tesla::State::Name ( bool  QuoteNonNumeric = true) const

Definition at line 126 of file State.cpp.

126  {
127  std::stringstream ss;
128  if (name.empty()) {
129  ss << ID();
130  } else {
131  auto Quote = (QuoteNonNumeric ? "'" : "");
132  ss << Quote << name << Quote;
133  }
134 
135  return ss.str();
136 }
static Builder tesla::State::NewBuilder ( StateVector S)
inlinestatic

Definition at line 76 of file State.h.

Referenced by tesla::internal::NFAParser::Parse().

76 { return Builder(S); }

+ Here is the caller graph for this function:

const ReferenceVector tesla::State::References ( ) const
inline

Definition at line 88 of file State.h.

88 { return Refs; }
string tesla::State::String ( ) const

Definition at line 139 of file State.cpp.

References tesla::InstanceName(), and tesla::Transition::String().

139  {
140  assert(VariableReferences);
141 
142  std::stringstream ss;
143  ss << "state " << Name(true) << " " << InstanceName(Refs, true) << ":";
144 
145  for (const auto& I : Transitions) {
146  const Transition& T = *I;
147  ss << " " << T.String();
148  }
149 
150  return ss.str();
151 }

+ Here is the call graph for this function:

void tesla::State::UpdateReferences ( const Transition T)

Definition at line 68 of file State.cpp.

References tesla::Transition::InScope(), and tesla::Transition::ReferencesThusFar().

Referenced by tesla::Transition::Register().

69 {
70  if (VariableReferences && !T.InScope())
71  return;
72 
73  OwningArrayPtr<const Argument*> Args;
74  ReferenceVector NewRefs;
75  T.ReferencesThusFar(Args, NewRefs);
76 
77  assert(!VariableReferences
78  || (NewRefs.size() == 0)
79  || (Refs.size() == NewRefs.size()));
80  const size_t Len = NewRefs.size();
81  assert(Len < 8 * sizeof(Mask()));
82 
83  if (!VariableReferences) {
84  // If we don't have any bound variables, just copy NewRefs.
85  VariableReferences.reset(new const Argument*[Len]);
86  memcpy(VariableReferences.get(), NewRefs.data(), Len * sizeof(Refs[0]));
87 
88  Refs = MutableReferenceVector(VariableReferences.get(), Len);
89  return;
90  }
91 
92 #ifndef NDEBUG
93  if (T.InScope()) {
94  for (auto *Arg : NewRefs) {
95  if (Arg == NULL)
96  continue;
97 
98  assert(Arg->type() == Argument::Variable);
99  assert(((size_t) Arg->index()) <= Len);
100  }
101 
102  uint32_t NewMask = 0;
103  for (size_t i = 0; i < Len; i++) {
104  if ((NewRefs[i] != NULL) && (NewRefs[i]->type() == Argument::Constant))
105  NewMask |= (1 << i);
106  }
107 
108  assert((Mask() & NewMask) == NewMask);
109  }
110 #endif
111 }

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Friends And Related Function Documentation

friend class internal::DFABuilder
friend

Definition at line 51 of file State.h.


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