sun::types::InterfaceType
class · Source (opens in a new tab)
class sun::types::InterfaceType : public sun::types::NominalTypeInterface type for user-defined interfaces Interfaces define a contract that classes must implement.
Inherits
- sun::types::NominalType (public)
Public Functions
- InterfaceType
- addField
- addMethod
- equals
- extendsInterface
- getBaseGenericName
- getBaseName
- getFatPointerType
- getField
- getFields
- getGenericQualifiedName
- getKind
- getLifetimeParams
- getMethod
- getMethodCount
- getMethodIndex
- getMethods
- getName
- getParent
- getParentIndex
- getQualifiedName
- getRequiredMethods
- getTypeArguments
- getTypeParameters
- getVtableType
- hasBaseName
- isGenericDefinition
- isSpecialized
- setBaseName
- setGenericQualifiedName
- setInheritedShape
- setLifetimeParams
- setMethodReturnType
- setQualifiedName
- toDisplayString
- toLLVMType
- toString
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 overrideReports 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) constReports 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() constReturns 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() constBase 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) constReturns 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() constProvides 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() constThe 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 overrideReturns 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() constProvides 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) constReturns the method stored by this object.
Related: InterfaceMethod
getMethodCount
public · function · Source (opens in a new tab)
unsigned sun::types::InterfaceType::getMethodCount() constReturns the number of dynamically dispatchable methods.
getMethodIndex
public · function · Source (opens in a new tab)
int sun::types::InterfaceType::getMethodIndex(DeclarationId declaration) constGet 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() constProvides 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() constReturns the declared name used to identify this object.
getParent
public · function · Source (opens in a new tab)
const InterfaceTypePtr & sun::types::InterfaceType::getParent() constReturns 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() constReturns 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() constSource 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() constGet 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() constProvides 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() constProvides 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) constGet 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() constReports whether the unqualified declaration name is available.
isGenericDefinition
public · function · Source (opens in a new tab)
bool sun::types::InterfaceType::isGenericDefinition() constReports 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() constReports 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.
setMethodReturnType
public · function · Source (opens in a new tab)
void sun::types::InterfaceType::setMethodReturnType(const std::string &methodName, TypePtr returnType)Rebind one method's return type.
Exists for the builtin IError: it is registered before any source is read, so message() starts as static_ptr<u8> and is retargeted to the String class when the stdlib registers one (see SemanticAnalyzer::registerClassShape).
Related: TypePtr
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 overrideReturns 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 overrideInterfaces are represented as fat pointers: { ptr data, ptr vtable }.
The vtable contains methods and an optional parent table link. Views borrow the concrete object and never run its cleanup.
toString
public · function · Source (opens in a new tab)
std::string sun::types::InterfaceType::toString() const overrideReturns 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::InterfaceNo 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::PrivateNo documentation comment.
Related: sun::semantic_analysis::Visibility, sun::semantic_analysis::Visibility::Private
Public Friends
sun::semantic_analysis::TypeRegistry
public · friend · Source (opens in a new tab)
friend class sun::semantic_analysis::TypeRegistryNo documentation comment.
Related: sun::semantic_analysis::TypeRegistry
Private Fields
- baseGenericName
- baseName_
- fields
- genericQualifiedName_
- lifetimeParams_
- methods
- name
- parent_
- qualifiedName_
- typeArguments
- typeParameters
baseGenericName
private · variable · Source (opens in a new tab)
std::string sun::types::InterfaceType::baseGenericNameNo 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::fieldsNo 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::methodsNo documentation comment.
Related: InterfaceMethod
name
private · variable · Source (opens in a new tab)
std::string sun::types::InterfaceType::nameNo 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::typeArgumentsNo documentation comment.
Related: TypePtr
typeParameters
private · variable · Source (opens in a new tab)
std::vector<std::string> sun::types::InterfaceType::typeParametersNo documentation comment.