Class RefType

Inheritance Relationships

Base Types

Class Documentation

class RefType : public seq::types::Type, public seq::Generic

Public Functions

RefType(RefType const&)
void operator=(RefType const&)
void setDone()
void setContents(RecordType *contents)
void addMember(std::string name, Expr *expr)
std::string getName() const

Returns the full name (e.g. array[int], Foo[str,bool]) of this type.

std::string genericName()
types::Type *realize(std::vector<types::Type *> types)
std::vector<types::Type *> deduceTypesFromArgTypes(std::vector<types::Type *> argTypes, std::vector<std::string> names = {})
Value *memb(llvm::Value *self, const std::string &name, llvm::BasicBlock *block)

Extract a given member (field or method) from this type.

Return

member value

Parameters
  • self: a value of this type

  • name: name of the member

  • block: where to codegen the member

types::Type *membType(const std::string &name)

Return the type of a given member (field or method) of this type.

Return

type of the member

Parameters
  • name: name of the member

Value *setMemb(llvm::Value *self, const std::string &name, llvm::Value *val, llvm::BasicBlock *block)

Sets the specified member of this type.

Return

value (possibly self) containing new member

Parameters
  • self: a value of this type

  • name: name of the member

  • val: value to assign to member

  • block: where to codegen the assignment

Value *defaultValue(llvm::BasicBlock *block)

Codegens the default value of this type. Usually this is just what you’d expect: zero for integral types, null for pointer and reference types, recursively defined for aggregate types.

Return

value of the default value

Parameters
  • block: where to codegen the default value

void initOps()

Performs a one-time initialization of this type’s methods, including magic methods.

void initFields()

Performs a one-time initialization of this type’s fields.

bool isAtomic() const

Returns whether this type is “atomic”. A type is defined to be atomic if its LLVM representation contains no pointers to heap allocated data. This is used internally by the GC, as we can allocate “atomic” and “non-atomic” blocks separately. Atomic blocks do not need to be scanned when searching for pointers.

bool is(types::Type *type) const

Checks whether this type “is” another type.

unsigned numBaseTypes() const

Returns the number of “base types” of this type. E.g., int.numBaseTypes() would return 0, whereas array[str].numBaseTypes() would return 1, and (int,float,str).numBaseTypes() would return 3.

types::Type *getBaseType(unsigned idx) const

Obtain the base type at index idx. idx should be less than numBaseTypes().

Type *getLLVMType(llvm::LLVMContext &context) const

Returns the LLVM type corresponding to this type.

size_t size(llvm::Module *module) const

Returns the size (in bytes) of the LLVM type corresponding to this type.

types::RefType *asRef()

Returns this type as a reference type, or null if it isn’t a reference type. This is basically for overriding C++’s RTTI/dynamic_cast so that generic types can be converted to their actual types.

Value *make(llvm::BasicBlock *block, std::vector<llvm::Value *> vals = {})
types::RefType *clone(Generic *ref)
void addCachedRealized(std::vector<types::Type *> types, Generic *x)

Public Static Functions

types::RefType *get(std::string name)
types::RefType *none()