Skip to content

Commit 1d36cb8

Browse files
committed
Added DynT and DynType
1 parent 245a0f2 commit 1d36cb8

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

kmir/src/kmir/kdist/mir-semantics/ty.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,8 @@ syntax ExistentialPredicateBinders ::= List {ExistentialPredicateBinder, ""}
280280
| typeInfoRefType(Ty) [symbol(TypeInfo::RefType) , group(mir-enum---pointee-type)]
281281
| typeInfoTupleType(types: Tys, layout: MaybeLayoutShape)
282282
[symbol(TypeInfo::TupleType) , group(mir-enum---types--layout)]
283+
| TypeInfoDynType(name: MIRString, layout: MaybeLayoutShape)
284+
[symbol(TypeInfo::DynType) , group(mir-enum---name--layout)]
283285
| typeInfoFunType(MIRString) [symbol(TypeInfo::FunType) , group(mir-enum)]
284286
| "typeInfoVoidType" [symbol(TypeInfo::VoidType) , group(mir-enum)]
285287

kmir/src/kmir/ty.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,28 @@ def nbytes(self, types: Mapping[Ty, TypeMetadata]) -> int:
675675
return size.in_bytes
676676

677677

678+
@dataclass
679+
class DynT(TypeMetadata):
680+
name: str
681+
layout: LayoutShape | None
682+
683+
@staticmethod
684+
def from_raw(data: Any) -> DynT:
685+
match data:
686+
case {
687+
'DynType': {
688+
'name': name,
689+
'layout': layout,
690+
}
691+
}:
692+
return DynT(
693+
name=name,
694+
layout=LayoutShape.from_raw(layout) if layout is not None else None,
695+
)
696+
case _:
697+
raise _cannot_parse_as('DynT', data)
698+
699+
678700
@dataclass
679701
class FunT(TypeMetadata):
680702
type_str: str

0 commit comments

Comments
 (0)