sun::types::InterfaceType

sun::types::InterfaceType

class · Source (opens in a new tab)

class sun::types::InterfaceType : public sun::types::NominalType

Interface type for user-defined interfaces Interfaces define a contract that classes must implement.

Inherits

Public Functions

InterfaceType

InterfaceType(std::string name_, std::string baseName, std::vector< TypePtr > typeArgs)

public · function · Source (opens in a new tab)

sun::types::InterfaceType::InterfaceType(std::string name_, std::string baseName, std::vector< TypePtr > typeArgs)

Constructor for specialized generic interface.

Related: TypePtr

InterfaceType(std::string interfaceName)

public · function · Source (opens in a new tab)

sun::types::InterfaceType::InterfaceType(std::string interfaceName)

Creates a semantic interface descriptor under its declared name.

InterfaceType(std::string interfaceName, std::vector< std::string > typeParams)

public · function · Source (opens in a new tab)

sun::types::InterfaceType::InterfaceType(std::string interfaceName, std::vector< std::string > typeParams)

Constructor for generic interface definition.

addField

public · function · Source (opens in a new tab)

InterfaceField & sun::types::InterfaceType::addField(const std::string &fieldName, TypePtr fieldType, DeclarationId id={})

Returns the (possibly pre-existing) record so callers can set access.

Related: InterfaceField, TypePtr, DeclarationId

addMethod

public · function · Source (opens in a new tab)

InterfaceMethod & sun::types::InterfaceType::addMethod(const std::string &methodName, TypePtr returnType, std::vector< TypePtr > paramTypes, bool hasDefaultImpl=false, std::vector< std::string > typeParams={})

Registers a method signature on this type for lookup and dispatch.

Related: InterfaceMethod, TypePtr

equals

public · function · Source (opens in a new tab)

bool sun::types::InterfaceType::equals(const Type &other) const override

Reports whether the other type has the same semantic identity.

Related: Type

extendsInterface

public · function · Source (opens in a new tab)

bool sun::types::InterfaceType::extendsInterface(const InterfaceType &target) const

Reports nominal conformance to this interface or one of its ancestors.

Related: InterfaceType

getBaseGenericName

public · function · Source (opens in a new tab)

const std::string & sun::types::InterfaceType::getBaseGenericName() const

Returns the original generic name used to identify this specialization.

getBaseName

public · function · Source (opens in a new tab)

const std::string & sun::types::InterfaceType::getBaseName() const

Base name accessors (user-written name for error messages).

getFatPointerType

public · function · static · Source (opens in a new tab)

static llvm::StructType * sun::types::InterfaceType::getFatPointerType(llvm::LLVMContext &ctx)

Get the fat pointer struct type for interface values: { ptr data, ptr vtable }.

  • data: pointer to the concrete class instance
  • vtable: pointer to the implementing class's vtable for this interface

getField

public · function · Source (opens in a new tab)

const InterfaceField * sun::types::InterfaceType::getField(const std::string &fieldName) const

Returns the field stored by this object.

Related: InterfaceField

getFields

public · function · Source (opens in a new tab)

const std::vector< InterfaceField > & sun::types::InterfaceType::getFields() const

Provides the field declarations belonging to this type.

Related: InterfaceField

getGenericQualifiedName

public · function · Source (opens in a new tab)

const sun::semantic_analysis::QualifiedName & sun::types::InterfaceType::getGenericQualifiedName() const

The original template name, independent of specialization and source aliases.

Related: sun::semantic_analysis::QualifiedName

getKind

public · function · Source (opens in a new tab)

Kind sun::types::InterfaceType::getKind() const override

Returns the type category used for semantic checks and dispatch.

Related: Kind

getLifetimeParams

public · function · Source (opens in a new tab)

const std::vector< std::string > & sun::types::InterfaceType::getLifetimeParams() const

Provides the lifetime parameters associated with this declaration.

getMethod

public · function · Source (opens in a new tab)

const InterfaceMethod * sun::types::InterfaceType::getMethod(const std::string &methodName) const

Returns the method stored by this object.

Related: InterfaceMethod

getMethodCount

public · function · Source (opens in a new tab)

unsigned sun::types::InterfaceType::getMethodCount() const

Returns the number of dynamically dispatchable methods.

getMethodIndex

public · function · Source (opens in a new tab)

int sun::types::InterfaceType::getMethodIndex(DeclarationId declaration) const

Get the slot index for a method in the vtable.

Returns -1 if method not found or if the method is generic. Only non-generic methods can be dispatched via vtable.

Related: DeclarationId

getMethods

public · function · Source (opens in a new tab)

const std::vector< InterfaceMethod > & sun::types::InterfaceType::getMethods() const

Provides the method declarations belonging to this type.

Related: InterfaceMethod

getName

public · function · Source (opens in a new tab)

const std::string & sun::types::InterfaceType::getName() const

Returns the declared name used to identify this object.

getOwnerType

public · function · static · Source (opens in a new tab)

static llvm::StructType * sun::types::InterfaceType::getOwnerType(llvm::LLVMContext &ctx)

Stores the allocation, receiver, dispatch table, and cleanup function.

getParent

public · function · Source (opens in a new tab)

const InterfaceTypePtr & sun::types::InterfaceType::getParent() const

Returns the resolved direct parent, or null for a root interface.

Related: InterfaceTypePtr

getParentIndex

public · function · Source (opens in a new tab)

unsigned sun::types::InterfaceType::getParentIndex() const

Returns the direct parent's dispatch-table slot.

getQualifiedName

public · function · Source (opens in a new tab)

const sun::semantic_analysis::QualifiedName & sun::types::InterfaceType::getQualifiedName() const

Source spelling; declaration records carry module ownership.

Related: sun::semantic_analysis::QualifiedName

getRequiredMethods

public · function · Source (opens in a new tab)

std::vector< const InterfaceMethod * > sun::types::InterfaceType::getRequiredMethods() const

Get methods that don't have default implementations (must be implemented by class).

Related: InterfaceMethod

getTypeArguments

public · function · Source (opens in a new tab)

const std::vector< TypePtr > & sun::types::InterfaceType::getTypeArguments() const

Provides the concrete types supplied for generic specialization.

Related: TypePtr

getTypeParameters

public · function · Source (opens in a new tab)

const std::vector< std::string > & sun::types::InterfaceType::getTypeParameters() const

Provides the generic parameters declared by this type or function.

getVtableType

public · function · Source (opens in a new tab)

llvm::StructType * sun::types::InterfaceType::getVtableType(llvm::LLVMContext &ctx) const

Get the vtable struct type for this interface.

Non-generic methods precede an optional parent table link.

hasBaseName

public · function · Source (opens in a new tab)

bool sun::types::InterfaceType::hasBaseName() const

Reports whether the unqualified declaration name is available.

isGenericDefinition

public · function · Source (opens in a new tab)

bool sun::types::InterfaceType::isGenericDefinition() const

Reports whether this is a generic declaration rather than a concrete instance.

isSpecialized

public · function · Source (opens in a new tab)

bool sun::types::InterfaceType::isSpecialized() const

Reports whether this type was instantiated with concrete type arguments.

setBaseName

public · function · Source (opens in a new tab)

void sun::types::InterfaceType::setBaseName(std::string bn)

Sets the unqualified declaration name without changing its enclosing scopes.

setGenericQualifiedName

public · function · Source (opens in a new tab)

void sun::types::InterfaceType::setGenericQualifiedName(sun::semantic_analysis::QualifiedName name)

Record the template that produced this type.

Related: sun::semantic_analysis::QualifiedName

setInheritedShape

public · function · Source (opens in a new tab)

void sun::types::InterfaceType::setInheritedShape(InterfaceTypePtr parent, std::vector< InterfaceField > effectiveFields, std::vector< InterfaceMethod > effectiveMethods)

Records the resolved parent and its effective members.

Related: InterfaceTypePtr, InterfaceField, InterfaceMethod

setLifetimeParams

public · function · Source (opens in a new tab)

void sun::types::InterfaceType::setLifetimeParams(std::vector< std::string > names)

Stores the lifetime parameters associated with this declaration.

setQualifiedName

public · function · Source (opens in a new tab)

void sun::types::InterfaceType::setQualifiedName(sun::semantic_analysis::QualifiedName qn)

Records the declaration name together with its enclosing scopes.

Related: sun::semantic_analysis::QualifiedName

toDisplayString

public · function · Source (opens in a new tab)

std::string sun::types::InterfaceType::toDisplayString() const override

Returns a source-facing type name without internal compiler prefixes.

toLLVMType

public · function · Source (opens in a new tab)

llvm::Type * sun::types::InterfaceType::toLLVMType(llvm::LLVMContext &ctx) const override

Returns the storage layout for a move-only interface value.

toString

public · function · Source (opens in a new tab)

std::string sun::types::InterfaceType::toString() const override

Returns a readable representation for diagnostics and debugging.

Public Fields

StaticKind

public · variable · static · Source (opens in a new tab)

Kind sun::types::InterfaceType::StaticKind = Kind::Interface

No documentation comment.

Related: Kind, Kind::Interface

visibility

public · variable · Source (opens in a new tab)

sun::semantic_analysis::Visibility sun::types::InterfaceType::visibility =
      sun::semantic_analysis::Visibility::Private

No documentation comment.

Related: sun::semantic_analysis::Visibility, sun::semantic_analysis::Visibility::Private

Public Enums

OwnerField

public · enum · Source (opens in a new tab)

enum sun::types::InterfaceType::OwnerField : unsigned

Identifies the pointer fields in an owning interface handle.

Owner

Owner

No documentation comment.

Object

Object

No documentation comment.

Vtable

Vtable

No documentation comment.

Deinit

Deinit

No documentation comment.

Public Friends

sun::semantic_analysis::TypeRegistry

public · friend · Source (opens in a new tab)

friend class sun::semantic_analysis::TypeRegistry

No documentation comment.

Related: sun::semantic_analysis::TypeRegistry

Private Fields

baseGenericName

private · variable · Source (opens in a new tab)

std::string sun::types::InterfaceType::baseGenericName

No documentation comment.

baseName_

private · variable · Source (opens in a new tab)

std::string sun::types::InterfaceType::baseName_

No documentation comment.

fields

private · variable · Source (opens in a new tab)

std::vector<InterfaceField> sun::types::InterfaceType::fields

No documentation comment.

Related: InterfaceField

genericQualifiedName_

private · variable · Source (opens in a new tab)

sun::semantic_analysis::QualifiedName sun::types::InterfaceType::genericQualifiedName_

No documentation comment.

Related: sun::semantic_analysis::QualifiedName

lifetimeParams_

private · variable · Source (opens in a new tab)

std::vector<std::string> sun::types::InterfaceType::lifetimeParams_

No documentation comment.

methods

private · variable · Source (opens in a new tab)

std::vector<InterfaceMethod> sun::types::InterfaceType::methods

No documentation comment.

Related: InterfaceMethod

name

private · variable · Source (opens in a new tab)

std::string sun::types::InterfaceType::name

No documentation comment.

parent_

private · variable · Source (opens in a new tab)

InterfaceTypePtr sun::types::InterfaceType::parent_

No documentation comment.

Related: InterfaceTypePtr

qualifiedName_

private · variable · Source (opens in a new tab)

sun::semantic_analysis::QualifiedName sun::types::InterfaceType::qualifiedName_

No documentation comment.

Related: sun::semantic_analysis::QualifiedName

typeArguments

private · variable · Source (opens in a new tab)

std::vector<TypePtr> sun::types::InterfaceType::typeArguments

No documentation comment.

Related: TypePtr

typeParameters

private · variable · Source (opens in a new tab)

std::vector<std::string> sun::types::InterfaceType::typeParameters

No documentation comment.