Go to the documentation of this file.
56 dag_(&dag), rootNode_(root), currentOperation_(NULL),
57 operation_(operation) {
96 for (
int i = 1; i < node->
leafCount(); i++) {
113 node = &node->
leaf(1);
119 for (
int i = 1; i < node->
leafCount(); i++) {
124 std::cerr <<
"Cannot parse: " << node->
toStr();
147 "Operation: \"" + operation +
"\" doesn't exist.");
170 "Operation doesn't have operand number: " +
176 if (srcNode->first == NULL) {
181 +
" is NULL. Maybe it is temp variable that has not been"
182 +
" written yet? This happens in DAG of operation: " +
operation_.
name());
190 +
" not in dag. This happens in DAG of operation: " +
operation_.
name());
206 "Operation doesn't have operand number: " +
223 std::set<unsigned int> unwrittenOutputs;
224 for (
unsigned int i = 1; i <= outputCount; i++) {
225 unwrittenOutputs.insert(i + inputCount);
228 for (std::map<std::string,TerminalBinding>::iterator iter =
231 unwrittenOutputs.erase(iter->second.second);
233 if (iter->second.first == NULL) {
235 if (iter->second.second > inputCount + outputCount) {
239 TCEString(
" doesn't have result operand number: ") +
242 iter->second.first =
new TerminalNode(iter->second.second);
247 *(ioVar.first), *(iter->second.first), *newEdge);
250 if (!unwrittenOutputs.empty()) {
253 while (!unwrittenOutputs.empty()) {
255 unwrittenOutputs.erase(unwrittenOutputs.begin());
277 "\" already exists.");
298 "\" was not declared.");
350 "\" is not variable.");
381 "\" is not variable.");
397 "Trying to use uninitialized variable: " + varName);
438 std::string varName =
469 "\" != \"IO(x)\" call.");
std::pair< OperationDAGNode *, int > VariableBinding
Node and operand which is referred by a variable.
bool isIdentifier() const
virtual void connectNodes(const Node &nTail, const Node &nHead, Edge &e)
Operation & operation(const char *name)
bool isAssignment() const
OperationNode * currentOperation_
Currently created handled operation.
bool isIntegerLiteral() const
std::map< std::string, VariableBinding > variableBindings_
Node and operand which are referred by IO(x) or declared variable.
Operation & referencedOperation() const
const TokenizerData::TokenTreeNode & rootNode_
Root of tokenized data parsed from OSAL DAG source code.
virtual void addNode(Node &node)
virtual bool isOutput() const
static NullOperation & instance()
static std::string toString(const T &source)
std::map< long, VariableBinding > constantBindings_
Node representing constant value.
int numberOfOutputs() const
TokenTreeNode & leaf(int index) const
std::map< std::string, TerminalBinding > ioVariables_
IO(x) variables and corresponding TerminalNodes and operand indices.
VariableBinding & getConstantBinding(long value)
virtual std::string toString() const
OperationDAGBuilder(const OperationPimpl &operation, OperationDAG &dag, const TokenizerData::TokenTreeNode &root)
std::string toStr() const
bool isFunctionCall() const
void assignVariable(const TokenizerData::TokenTreeNode *dst, VariableBinding &src)
bool hasNode(const Node &) const
virtual int operandCount() const
std::string stringValue() const
void connectOperandToNode(const TokenizerData::TokenTreeNode *var, unsigned int operandIndex)
virtual Operand & operand(int id) const
const OperationPimpl & operation_
OperationDAG * dag_
DAG where all nodes and edges are added.
std::string getVariableName(const TokenizerData::TokenTreeNode *var)
void parseNode(const TokenizerData::TokenTreeNode *node)
void createOperationNode(const std::string &operation)
void declareVariable(const TokenizerData::TokenTreeNode *var)
unsigned int getIOOperand(const TokenizerData::TokenTreeNode *var)
virtual bool isInput() const
std::pair< TerminalNode *, unsigned int > TerminalBinding
Information of object and index of operand of a variable.
const Token & token() const
VariableBinding & getBinding(const TokenizerData::TokenTreeNode *var)
int numberOfInputs() const