Files
ldc/ir/irtypestruct.h
David Nadlinger a3a511ca55 Refactored IrType construction to use static get() method.
This also allows us to enable the assert in IrType::IrType.

Unfortunately, this is mostly a "peace of mind" commit, there
doesn't seem to have been a bug actually caused by the transitory
duplicate IrTypePointer/IrTypeStruct instances.

The remaining xyz2llvm static methods are not exactly pretty,
they should probably just be folded into get.
2012-12-20 23:52:09 +01:00

86 lines
2.2 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//===-- ir/irtypestruct.h - IrType subclasses for aggregates ----*- C++ -*-===//
//
// LDC the LLVM D compiler
//
// This file is distributed under the BSD-style LDC license. See the LICENSE
// file for details.
//
//===----------------------------------------------------------------------===//
//
// Provides the IrType subclasses used to represent D struct types
// (see irtypeclass.h for the class version).
//
//===----------------------------------------------------------------------===//
#ifndef __LDC_IR_IRTYPESTRUCT_H__
#define __LDC_IR_IRTYPESTRUCT_H__
#include "ir/irtype.h"
//////////////////////////////////////////////////////////////////////////////
struct AggregateDeclaration;
struct StructDeclaration;
struct TypeStruct;
//////////////////////////////////////////////////////////////////////////////
class IrTypeAggr : public IrType
{
public:
///
IrTypeAggr* isAggr() { return this; }
///
typedef std::vector<VarDeclaration*>::iterator iterator;
///
iterator def_begin() { return default_fields.begin(); }
///
iterator def_end() { return default_fields.end(); }
protected:
///
IrTypeAggr(AggregateDeclaration* ad);
/// AggregateDeclaration this type represents.
AggregateDeclaration* aggr;
/// Sorted list of all default fields.
/// A default field is a field that contributes to the default initializer
/// and the default type, and thus it has it's own unique GEP index into
/// the aggregate.
/// For classes, field of any super classes are not included.
std::vector<VarDeclaration*> default_fields;
};
//////////////////////////////////////////////////////////////////////////////
class IrTypeStruct : public IrTypeAggr
{
public:
///
static IrTypeStruct* get(StructDeclaration* sd);
///
IrTypeStruct* isStruct() { return this; }
///
llvm::Type* buildType();
protected:
///
IrTypeStruct(StructDeclaration* sd);
/// StructDeclaration this type represents.
StructDeclaration* sd;
/// DMD TypeStruct of this type.
TypeStruct* ts;
};
//////////////////////////////////////////////////////////////////////////////
#endif