mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-12 13:55:57 +03:00
Make IrDsymbol to be a typesafe union to reduce memory usage
This commit is contained in:
parent
5b15095c81
commit
18f33b1815
27 changed files with 465 additions and 293 deletions
|
@ -18,6 +18,7 @@
|
|||
#include "gen/logger.h"
|
||||
#include "gen/tollvm.h"
|
||||
#include "ir/iraggr.h"
|
||||
#include "irdsymbol.h"
|
||||
#include "ir/irtypeclass.h"
|
||||
#include "ir/irtypestruct.h"
|
||||
#include <algorithm>
|
||||
|
@ -376,3 +377,22 @@ void IrAggr::addFieldInitializers(
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
IrAggr *getIrAggr(AggregateDeclaration *decl, bool create)
|
||||
{
|
||||
if (!isIrAggrCreated(decl) && create)
|
||||
{
|
||||
assert(decl->ir.irAggr == NULL);
|
||||
decl->ir.irAggr = new IrAggr(decl);
|
||||
decl->ir.m_type = IrDsymbol::AggrType;
|
||||
}
|
||||
assert(decl->ir.irAggr != NULL);
|
||||
return decl->ir.irAggr;
|
||||
}
|
||||
|
||||
bool isIrAggrCreated(AggregateDeclaration *decl)
|
||||
{
|
||||
int t = decl->ir.type();
|
||||
assert(t == IrDsymbol::AggrType || t == IrDsymbol::NotSet);
|
||||
return t == IrDsymbol::AggrType;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue