From d2f69dccb3643834a79da79be4ece189a7178c9e Mon Sep 17 00:00:00 2001 From: Mel Date: Sun, 29 May 2022 21:42:32 +0000 Subject: Types, Methods and basic Core Lib --- pkg/lang/vm/value/cells.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'pkg/lang/vm/value/cells.go') diff --git a/pkg/lang/vm/value/cells.go b/pkg/lang/vm/value/cells.go index 116fa5a..146402d 100644 --- a/pkg/lang/vm/value/cells.go +++ b/pkg/lang/vm/value/cells.go @@ -31,6 +31,29 @@ func (s StringCell) Get() string { return string(s) } +type TypeCell Type + +func (t TypeCell) DropCell(m mem.Mem) { + typ := t.Get() + for _, f := range typ.Methods { + // Wrap data in a Value to drop it. + val := NewFunction(0).WithData(f) + val.Drop(m) + } + + for _, v := range typ.Statics { + v.Drop(m) + } +} + +func (t TypeCell) MatchingCellKind() mem.CellKind { + return mem.CellKindType +} + +func (t TypeCell) Get() Type { + return Type(t) +} + type OutletCell Value func (o OutletCell) DropCell(m mem.Mem) { -- cgit 1.4.1