mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-04 05:31:06 +00:00
Make the range insert operation return an iterator, even though the STL
range insert doesn't git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2413 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
91b078dd54
commit
ea1e8c70eb
@ -118,14 +118,14 @@ public:
|
|||||||
iterator insert(iterator Pos, ValueSubclass *Inst);
|
iterator insert(iterator Pos, ValueSubclass *Inst);
|
||||||
|
|
||||||
// ValueHolder::insert - This method inserts the specified _range_ of values
|
// ValueHolder::insert - This method inserts the specified _range_ of values
|
||||||
// before the 'Pos' iterator. This currently only works for vector
|
// before the 'Pos' iterator, returning a new iterator that points to the
|
||||||
// iterators...
|
// first item inserted. *This currently only works for vector iterators...*
|
||||||
//
|
//
|
||||||
// FIXME: This is not generic so that the code does not have to be around
|
// FIXME: This is not generic so that the code does not have to be around
|
||||||
// to be used... is this ok?
|
// to be used... is this ok?
|
||||||
//
|
//
|
||||||
void insert(iterator Pos, // Where to insert
|
iterator insert(iterator Pos, // Where to insert
|
||||||
iterator First, iterator Last); // Vector to read insts from
|
iterator First, iterator Last); // Vector to read insts from
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -172,12 +172,18 @@ ValueHolder<ValueSubclass,ItemParentType,SymTabType>
|
|||||||
// to be used... is this ok?
|
// to be used... is this ok?
|
||||||
//
|
//
|
||||||
template<class ValueSubclass, class ItemParentType, class SymTabType>
|
template<class ValueSubclass, class ItemParentType, class SymTabType>
|
||||||
void ValueHolder<ValueSubclass,ItemParentType,SymTabType>
|
ValueHolder<ValueSubclass,ItemParentType,SymTabType>::iterator
|
||||||
::insert(iterator Pos, // Where to insert
|
ValueHolder<ValueSubclass,ItemParentType,SymTabType>
|
||||||
|
::insert(iterator Pos, // Where to insert
|
||||||
iterator First, iterator Last) { // Vector to read insts from
|
iterator First, iterator Last) { // Vector to read insts from
|
||||||
|
|
||||||
|
// Since the vector range insert operation doesn't return an updated iterator,
|
||||||
|
// we have to convert the iterator to and index and back to assure that it
|
||||||
|
// cannot get invalidated. Gross hack, but effective.
|
||||||
|
//
|
||||||
|
unsigned Offset = Pos-begin();
|
||||||
|
|
||||||
// Check to make sure that the values are not already in some valueholder...
|
// Check to make sure that the values are not already in some valueholder...
|
||||||
|
|
||||||
for (iterator X = First; X != Last; ++X) {
|
for (iterator X = First; X != Last; ++X) {
|
||||||
assert((*X)->getParent() == 0 &&
|
assert((*X)->getParent() == 0 &&
|
||||||
"Cannot insert into valueholder, value already has a parent!");
|
"Cannot insert into valueholder, value already has a parent!");
|
||||||
@ -192,6 +198,8 @@ void ValueHolder<ValueSubclass,ItemParentType,SymTabType>
|
|||||||
for (;First != Last; ++First)
|
for (;First != Last; ++First)
|
||||||
if ((*First)->hasName())
|
if ((*First)->hasName())
|
||||||
Parent->getSymbolTableSure()->insert(*First);
|
Parent->getSymbolTableSure()->insert(*First);
|
||||||
|
|
||||||
|
return begin()+Offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user