mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-02-12 18:03:13 +01:00
Replace ArrayIter<> with Array<>::iterator.
Just use the new iterator instead of the old Java-like class. Also removes a dead iterator and replaces an iterator with a pointer in some place.
This commit is contained in:
@@ -25,7 +25,6 @@
|
||||
#include "gen/runtime.h"
|
||||
#include "gen/structs.h"
|
||||
#include "gen/tollvm.h"
|
||||
#include "gen/utils.h"
|
||||
#include "ir/iraggr.h"
|
||||
#include "ir/irtypeclass.h"
|
||||
|
||||
@@ -42,12 +41,11 @@ void DtoResolveClass(ClassDeclaration* cd)
|
||||
LOG_SCOPE;
|
||||
|
||||
// make sure the base classes are processed first
|
||||
ArrayIter<BaseClass> base_iter(cd->baseclasses);
|
||||
while (base_iter.more())
|
||||
for (BaseClasses::iterator I = cd->baseclasses->begin(),
|
||||
E = cd->baseclasses->end();
|
||||
I != E; ++I)
|
||||
{
|
||||
BaseClass* bc = base_iter.get();
|
||||
DtoResolveClass(bc->base);
|
||||
base_iter.next();
|
||||
DtoResolveClass((*I)->base);
|
||||
}
|
||||
|
||||
// make sure type exists
|
||||
@@ -59,10 +57,11 @@ void DtoResolveClass(ClassDeclaration* cd)
|
||||
cd->ir.irAggr = irAggr;
|
||||
|
||||
// make sure all fields really get their ir field
|
||||
ArrayIter<VarDeclaration> it(cd->fields);
|
||||
for (; !it.done(); it.next())
|
||||
for (VarDeclarations::iterator I = cd->fields.begin(),
|
||||
E = cd->fields.end();
|
||||
I != E; ++I)
|
||||
{
|
||||
VarDeclaration* vd = it.get();
|
||||
VarDeclaration* vd = *I;
|
||||
if (vd->ir.irField == NULL) {
|
||||
new IrField(vd);
|
||||
} else {
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#include "gen/llvmhelpers.h"
|
||||
#include "gen/logger.h"
|
||||
#include "gen/tollvm.h"
|
||||
#include "gen/utils.h"
|
||||
#include "ir/irtype.h"
|
||||
#include "ir/irvar.h"
|
||||
#include "llvm/ADT/SmallString.h"
|
||||
@@ -53,9 +52,11 @@ void InterfaceDeclaration::codegen(IRState *p)
|
||||
DtoResolveClass(this);
|
||||
|
||||
// Emit any members (e.g. final functions).
|
||||
for (ArrayIter<Dsymbol> it(members); !it.done(); it.next())
|
||||
for (Dsymbols::iterator I = members->begin(),
|
||||
E = members->end();
|
||||
I != E; ++I)
|
||||
{
|
||||
it->codegen(p);
|
||||
(*I)->codegen(p);
|
||||
}
|
||||
|
||||
// Emit TypeInfo.
|
||||
@@ -87,9 +88,11 @@ void StructDeclaration::codegen(IRState *p)
|
||||
{
|
||||
DtoResolveStruct(this);
|
||||
|
||||
for (ArrayIter<Dsymbol> it(members); !it.done(); it.next())
|
||||
for (Dsymbols::iterator I = members->begin(),
|
||||
E = members->end();
|
||||
I != E; ++I)
|
||||
{
|
||||
it->codegen(p);
|
||||
(*I)->codegen(p);
|
||||
}
|
||||
|
||||
// Define the __initZ symbol.
|
||||
@@ -127,9 +130,11 @@ void ClassDeclaration::codegen(IRState *p)
|
||||
{
|
||||
DtoResolveClass(this);
|
||||
|
||||
for (ArrayIter<Dsymbol> it(members); !it.done(); it.next())
|
||||
for (Dsymbols::iterator I = members->begin(),
|
||||
E = members->end();
|
||||
I != E; ++I)
|
||||
{
|
||||
it->codegen(p);
|
||||
(*I)->codegen(p);
|
||||
}
|
||||
|
||||
llvm::GlobalValue::LinkageTypes const linkage = DtoExternalLinkage(this);
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
#include "gen/llvmhelpers.h"
|
||||
#include "gen/logger.h"
|
||||
#include "gen/tollvm.h"
|
||||
#include "gen/utils.h"
|
||||
#include "ir/irtypeaggr.h"
|
||||
#include "llvm/ADT/SmallString.h"
|
||||
#include "llvm/Support/FileSystem.h"
|
||||
@@ -149,9 +148,11 @@ llvm::DIType ldc::DIBuilder::CreateEnumType(Type *type)
|
||||
assert(type->ty == Tenum && "only enums allowed for debug info in dwarfEnumType");
|
||||
TypeEnum *te = static_cast<TypeEnum *>(type);
|
||||
llvm::SmallVector<llvm::Value *, 8> subscripts;
|
||||
for (ArrayIter<Dsymbol> it(te->sym->members); it.more(); it.next())
|
||||
for (Dsymbols::iterator I = te->sym->members->begin(),
|
||||
E = te->sym->members->end();
|
||||
I != E; ++I)
|
||||
{
|
||||
EnumMember *em = it->isEnumMember();
|
||||
EnumMember *em = (*I)->isEnumMember();
|
||||
llvm::StringRef Name(em->toChars());
|
||||
uint64_t Val = em->value->toInteger();
|
||||
llvm::Value *Subscript = DBuilder.createEnumerator(Name, Val);
|
||||
@@ -251,12 +252,13 @@ void ldc::DIBuilder::AddBaseFields(ClassDeclaration *sd, llvm::DIFile file,
|
||||
AddBaseFields(sd->baseClass, file, elems);
|
||||
}
|
||||
|
||||
ArrayIter<VarDeclaration> it(sd->fields);
|
||||
size_t narr = sd->fields.dim;
|
||||
elems.reserve(narr);
|
||||
for (; !it.done(); it.next())
|
||||
for (VarDeclarations::iterator I = sd->fields.begin(),
|
||||
E = sd->fields.end();
|
||||
I != E; ++I)
|
||||
{
|
||||
VarDeclaration* vd = it.get();
|
||||
VarDeclaration* vd = *I;
|
||||
elems.push_back(CreateMemberType(vd->loc.linnum, vd->type, file, vd->toChars(), vd->offset));
|
||||
}
|
||||
}
|
||||
@@ -321,12 +323,12 @@ llvm::DIType ldc::DIBuilder::CreateCompositeType(Type *type)
|
||||
{
|
||||
if (t->ty == Tstruct)
|
||||
{
|
||||
ArrayIter<VarDeclaration> it(sd->fields);
|
||||
size_t narr = sd->fields.dim;
|
||||
elems.reserve(narr);
|
||||
for (; !it.done(); it.next())
|
||||
elems.reserve(sd->fields.dim);
|
||||
for (VarDeclarations::iterator I = sd->fields.begin(),
|
||||
E = sd->fields.end();
|
||||
I != E; ++I)
|
||||
{
|
||||
VarDeclaration* vd = it.get();
|
||||
VarDeclaration* vd = *I;
|
||||
llvm::DIType dt = CreateMemberType(vd->loc.linnum, vd->type, file, vd->toChars(), vd->offset);
|
||||
elems.push_back(dt);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
#include "gen/llvmhelpers.h"
|
||||
#include "gen/logger.h"
|
||||
#include "gen/tollvm.h"
|
||||
#include "gen/utils.h"
|
||||
#include "llvm/Analysis/ValueTracking.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
namespace cl = llvm::cl;
|
||||
@@ -337,9 +336,10 @@ static void DtoCreateNestedContextType(FuncDeclaration* fd) {
|
||||
|
||||
// Add the direct nested variables of this function, and update their indices to match.
|
||||
// TODO: optimize ordering for minimal space usage?
|
||||
VarDeclarationIter closureVarsIter(fd->closureVars);
|
||||
for (; closureVarsIter.more(); closureVarsIter.next()) {
|
||||
VarDeclaration* vd = *closureVarsIter;
|
||||
for (VarDeclarations::iterator I = fd->closureVars.begin(),
|
||||
E = fd->closureVars.end();
|
||||
I != E; ++I) {
|
||||
VarDeclaration* vd = *I;
|
||||
if (!vd->ir.irLocal)
|
||||
vd->ir.irLocal = new IrLocal(vd);
|
||||
|
||||
@@ -443,9 +443,10 @@ void DtoCreateNestedContext(FuncDeclaration* fd) {
|
||||
irfunction->nestedVar = frame;
|
||||
|
||||
// go through all nested vars and assign addresses where possible.
|
||||
VarDeclarationIter closureVarsIter(fd->closureVars);
|
||||
for (; closureVarsIter.more(); closureVarsIter.next()) {
|
||||
VarDeclaration* vd = *closureVarsIter;
|
||||
for (VarDeclarations::iterator I = fd->closureVars.begin(),
|
||||
E = fd->closureVars.end();
|
||||
I != E; ++I) {
|
||||
VarDeclaration *vd = *I;
|
||||
|
||||
LLValue* gep = DtoGEPi(frame, 0, vd->ir.irLocal->nestedIndex, vd->toChars());
|
||||
if (vd->isParameter()) {
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#include "gen/logger.h"
|
||||
#include "gen/structs.h"
|
||||
#include "gen/tollvm.h"
|
||||
#include "gen/utils.h"
|
||||
#include "ir/iraggr.h"
|
||||
#include "llvm/ADT/DenseMap.h"
|
||||
#include "llvm/Support/ManagedStatic.h"
|
||||
@@ -58,9 +57,11 @@ void DtoResolveStruct(StructDeclaration* sd, Loc& callerLoc)
|
||||
sd->ir.irAggr = iraggr;
|
||||
|
||||
// Set up our field metadata.
|
||||
for (ArrayIter<VarDeclaration> it(sd->fields); !it.done(); it.next())
|
||||
for (VarDeclarations::iterator I = sd->fields.begin(),
|
||||
E = sd->fields.end();
|
||||
I != E; ++I)
|
||||
{
|
||||
VarDeclaration* vd = it.get();
|
||||
VarDeclaration *vd = *I;
|
||||
assert(!vd->ir.irField);
|
||||
(void)new IrField(vd);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#include "gen/logger.h"
|
||||
#include "gen/tollvm.h"
|
||||
#include "gen/llvmhelpers.h"
|
||||
#include "gen/utils.h"
|
||||
#include "gen/arrays.h"
|
||||
#include "gen/metadata.h"
|
||||
#include "gen/runtime.h"
|
||||
@@ -126,8 +125,7 @@ LLGlobalVariable * IrAggr::getInterfaceArraySymbol()
|
||||
assert(n > 0 && "getting ClassInfo.interfaces storage symbol, but we "
|
||||
"don't implement any interfaces");
|
||||
|
||||
VarDeclarationIter idx(Type::typeinfoclass->fields, 3);
|
||||
LLType* InterfaceTy = DtoType(idx->type->nextOf());
|
||||
LLType* InterfaceTy = DtoType(Type::typeinfoclass->fields[3]->type->nextOf());
|
||||
|
||||
// create Interface[N]
|
||||
LLArrayType* array_type = llvm::ArrayType::get(InterfaceTy,n);
|
||||
@@ -283,9 +281,6 @@ llvm::GlobalVariable * IrAggr::getInterfaceVtbl(BaseClass * b, bool new_instance
|
||||
constants.reserve(vtbl_array.dim);
|
||||
|
||||
if (!b->base->isCPPinterface()) { // skip interface info for CPP interfaces
|
||||
// start with the interface info
|
||||
VarDeclarationIter interfaces_idx(Type::typeinfoclass->fields, 3);
|
||||
|
||||
// index into the interfaces array
|
||||
llvm::Constant* idxs[2] = {
|
||||
DtoConstSize_t(0),
|
||||
@@ -415,7 +410,7 @@ LLConstant * IrAggr::getClassInfoInterfaces()
|
||||
assert(stripModifiers(type)->irtype->isClass()->getNumInterfaceVtbls() == n &&
|
||||
"inconsistent number of interface vtables in this class");
|
||||
|
||||
VarDeclarationIter interfaces_idx(Type::typeinfoclass->fields, 3);
|
||||
VarDeclaration *interfaces_idx = Type::typeinfoclass->fields[3];
|
||||
|
||||
if (n == 0)
|
||||
return getNullValue(DtoType(interfaces_idx->type));
|
||||
@@ -435,7 +430,7 @@ LLConstant * IrAggr::getClassInfoInterfaces()
|
||||
LLType* classinfo_type = DtoType(Type::typeinfoclass->type);
|
||||
LLType* voidptrptr_type = DtoType(
|
||||
Type::tvoid->pointerTo()->pointerTo());
|
||||
VarDeclarationIter idx(Type::typeinfoclass->fields, 3);
|
||||
VarDeclaration *idx = Type::typeinfoclass->fields[3];
|
||||
LLStructType* interface_type = isaStruct(DtoType(idx->type->nextOf()));
|
||||
assert(interface_type);
|
||||
|
||||
@@ -517,11 +512,12 @@ void IrAggr::initializeInterface()
|
||||
if (!base->vtblInterfaces)
|
||||
return;
|
||||
|
||||
ArrayIter<BaseClass> it(*base->vtblInterfaces);
|
||||
for (; !it.done(); it.next())
|
||||
for (BaseClasses::iterator I = base->vtblInterfaces->begin(),
|
||||
E = base->vtblInterfaces->end();
|
||||
I != E; ++I)
|
||||
{
|
||||
// add to the interface list
|
||||
interfacesWithVtbls.push_back(it.get());
|
||||
interfacesWithVtbls.push_back(*I);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -315,12 +315,11 @@ std::vector<llvm::Type*> IrTypeClass::buildVtblType(Type* first, FuncDeclaration
|
||||
types.push_back(DtoType(first));
|
||||
|
||||
// then come the functions
|
||||
ArrayIter<FuncDeclaration> it(*vtbl_array);
|
||||
it.index = 1;
|
||||
|
||||
for (; !it.done(); it.next())
|
||||
for (FuncDeclarations::iterator I = vtbl_array->begin() + 1,
|
||||
E = vtbl_array->end();
|
||||
I != E; ++I)
|
||||
{
|
||||
FuncDeclaration* fd = it.get();
|
||||
FuncDeclaration* fd = *I;
|
||||
if (fd == NULL)
|
||||
{
|
||||
// FIXME
|
||||
|
||||
Reference in New Issue
Block a user