From 3c34366bdd5d817a184d6b1c901d03a16b6faa4b Mon Sep 17 00:00:00 2001 From: Charlie Stanton Date: Fri, 12 May 2023 14:25:32 +0100 Subject: Adds the json_array IO format --- walk/atom.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'walk/atom.go') diff --git a/walk/atom.go b/walk/atom.go index dfe5fe4..299c39d 100644 --- a/walk/atom.go +++ b/walk/atom.go @@ -37,6 +37,12 @@ func NewAtomBool(v bool) Atom { } } } +func (v Atom) Bool() bool { + if v.Typ != AtomBool { + panic("Tried to use non-bool as bool") + } + return v.data == 1 +} func NewAtomNumber(v float64) Atom { return Atom { Typ: AtomNumber, @@ -73,6 +79,12 @@ func NewAtomStringRune(v rune) Atom { data: uint64(v), } } +func (v Atom) StringRune() rune { + if v.Typ != AtomStringRune { + panic("Tried to use non-stringrune as stringrune") + } + return rune(v.data) +} func (v Atom) String() string { switch v.Typ { case AtomNull: -- cgit v1.2.3