Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/engine/Type.v3
Original file line number Diff line number Diff line change
Expand Up @@ -398,28 +398,56 @@ class HeapTypeDecl(final: bool, supertypes: Array<HeapType>) extends Decl {
enum Packedness { UNPACKED, PACKED_I8, PACKED_I16 }
type StorageType(valtype: ValueType, pack: Packedness, mutable: bool) { }

// Information added to a struct declaration, specific to the object model.
class StructDeclInfo {
var next: StructDeclInfo;
}

// Struct type declaration. (ext:gc)
class StructDecl extends HeapTypeDecl {
def field_types: Array<StorageType>;
def defaultable = allHaveDefaultValues(field_types);
var infos: StructDeclInfo; // extended information about a struct

new(final: bool, supertypes: Array<HeapType>, field_types) super(final, supertypes) {}

def render(buf: StringBuilder) -> StringBuilder {
return putUid(buf.put1("struct #%d", heaptype_index));
}
def addInfo(info: StructDeclInfo) -> this {
info.next = infos;
this.infos = info;
}
def getInfo<T>() -> T {
for (s = infos; s != null; s = s.next) if (T.?(s)) return T.!(s);
return T.default;
}
}

// Information added to an array declaration, specific to the object model.
class ArrayDeclInfo {
var next: ArrayDeclInfo;
}

// Array type declaration. (ext:gc)
class ArrayDecl extends HeapTypeDecl {
def elem_types: Array<StorageType>;
def defaultable = allHaveDefaultValues(elem_types);
var infos: ArrayDeclInfo; // extended information about an array

new(final: bool, supertypes: Array<HeapType>, elem_types) super(final, supertypes) {}

def render(buf: StringBuilder) -> StringBuilder {
return putUid(buf.put1("array #%d", heaptype_index));
}
def addInfo(info: ArrayDeclInfo) -> this {
info.next = infos;
this.infos = info;
}
def getInfo<T>() -> T {
for (s = infos; s != null; s = s.next) if (T.?(s)) return T.!(s);
return T.default;
}
}

// Continuation type declaration. (ext:stack-switching)
Expand Down
Loading
Loading