[llvm-commits] [hlvm] r38332 - /hlvm/trunk/hlvm/Reader/XMLReader.cpp
Reid Spencer
reid at x10sys.com
Sat Jul 7 17:02:25 PDT 2007
Author: reid
Date: Sat Jul 7 19:02:25 2007
New Revision: 38332
URL: http://llvm.org/viewvc/llvm-project?rev=38332&view=rev
Log:
We can't depend on a Block's getContainingBlock method because the block
structure is built bottom up. Instead, retain in the reader a stack of
blocks being constructed and use that stack to locate auto vars.
Modified:
hlvm/trunk/hlvm/Reader/XMLReader.cpp
Modified: hlvm/trunk/hlvm/Reader/XMLReader.cpp
URL: http://llvm.org/viewvc/llvm-project/hlvm/trunk/hlvm/Reader/XMLReader.cpp?rev=38332&r1=38331&r2=38332&view=diff
==============================================================================
--- hlvm/trunk/hlvm/Reader/XMLReader.cpp (original)
+++ hlvm/trunk/hlvm/Reader/XMLReader.cpp Sat Jul 7 19:02:25 2007
@@ -67,7 +67,8 @@
Locator* loc;
URI* uri;
Block* block;
- std::vector<Block*> blocks;
+ typedef std::vector<Block*> BlockStack;
+ BlockStack blocks;
Function* func;
Bundle* bundle;
bool isError;
@@ -725,15 +726,16 @@
Locator* loc = getLocator(cur);
// Find the referrent variable in a block
- Block* blk = block;
Value* referent = 0;
- while (blk != 0) {
+ for (BlockStack::reverse_iterator I = blocks.rbegin(), E = blocks.rend();
+ I != E; ++I )
+ {
+ Block* blk = *I;
if (AutoVarOp* av = blk->getAutoVar(id))
if (av->getName() == id) {
referent = av;
break;
}
- blk = blk->getParentBlock();
}
// Didn't find an autovar? Try a function argument
@@ -859,24 +861,22 @@
const char* label = getAttribute(cur, "label",false);
xmlNodePtr child = cur->children;
MultiOperator::OprndList ops;
- if (block)
- blocks.push_back(block);
Block* result = ast->new_Block(loc);
block = result;
if (label)
block->setLabel(label);
+ blocks.push_back(block);
while (child && skipBlanks(child) && child->type == XML_ELEMENT_NODE)
{
Operator* op = parseOperator(child);
block->addOperand(op);
child = child->next;
}
+ blocks.pop_back();
if (blocks.empty())
block = 0;
- else {
+ else
block = blocks.back();
- blocks.pop_back();
- }
return result;
}
More information about the llvm-commits
mailing list