about summary refs log tree commit diff
path: root/pkg/lang/vm/value/cells.go
blob: 17a09168f969593f71c08519ffc2b283f35810cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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) Get() []Value {
	return a
}

type StringCell string

func (s StringCell) DropCell(m *mem.Mem) {
}

func (s StringCell) Get() string {
	return string(s)
}

type OutletCell Value

func (o OutletCell) DropCell(m *mem.Mem) {
	Value(o).Drop(m)
}

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) Get() Env {
	return Env(e)
}