package value import "jinx/pkg/lang/vm/mem" type ArrayCell []Value func (a ArrayCell) DropCell(m mem.Mem) { for _, v := range a { v.Drop(m) } } func (a ArrayCell) MatchingCellKind() mem.CellKind { return mem.CellKindArray } func (a ArrayCell) Get() []Value { return a } type StringCell string func (s StringCell) DropCell(m mem.Mem) { } func (s StringCell) MatchingCellKind() mem.CellKind { return mem.CellKindString } 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) { Value(o).Drop(m) } func (o OutletCell) MatchingCellKind() mem.CellKind { return mem.CellKindOutlet } func (o OutletCell) Get() Value { return Value(o) } type EnvCell Env func (e EnvCell) DropCell(m mem.Mem) { for _, v := range e.references { m.Release(v.outlet) } } func (e EnvCell) MatchingCellKind() mem.CellKind { return mem.CellKindEnv } func (e EnvCell) Get() Env { return Env(e) }