vm: support immutable compound types

This commit is contained in:
Anna Shaleva 2022-05-30 10:41:00 +03:00
parent 107f5e0793
commit 7296f0c913
10 changed files with 102 additions and 15 deletions

View file

@ -0,0 +1,21 @@
package stackitem
type ro struct {
isReadOnly bool
}
// IsReadOnly implements Immutable interface.
func (r *ro) IsReadOnly() bool {
return r.isReadOnly
}
// MarkAsReadOnly implements immutable interface.
func (r *ro) MarkAsReadOnly() {
r.isReadOnly = true
}
// Immutable is an interface supported by compound types (Array, Map, Struct).
type Immutable interface {
IsReadOnly() bool
MarkAsReadOnly()
}