diff options
author | Charlie Stanton <charlie@shtanton.xyz> | 2023-07-19 12:16:39 +0100 |
---|---|---|
committer | Charlie Stanton <charlie@shtanton.xyz> | 2023-07-19 12:16:39 +0100 |
commit | ac153f2b90b966baaf132a487514ae2194a64dd5 (patch) | |
tree | 39f63785de58ce4f6d8055847d5f0efa54d9499b /walk/atom.go | |
parent | 7d53110f2773ba758dea2f5c00483d879d378870 (diff) | |
download | stred-go-ac153f2b90b966baaf132a487514ae2194a64dd5.tar |
Removes lots of old atom based code from walk
Diffstat (limited to 'walk/atom.go')
-rw-r--r-- | walk/atom.go | 119 |
1 files changed, 0 insertions, 119 deletions
diff --git a/walk/atom.go b/walk/atom.go deleted file mode 100644 index 471f030..0000000 --- a/walk/atom.go +++ /dev/null @@ -1,119 +0,0 @@ -package walk - -import ( - "math" - "fmt" -) - -type AtomType int64 -const ( - AtomNull AtomType = iota - AtomBool - AtomNumber - AtomTerminal - AtomStringTerminal - AtomStringRune -) -type AtomOLD struct { - Typ AtomType - data uint64 -} -func NewAtomNull() AtomOLD { - return AtomOLD { - Typ: AtomNull, - data: 0, - } -} -func NewAtomBool(v bool) AtomOLD { - if v { - return AtomOLD { - Typ: AtomBool, - data: 1, - } - } else { - return AtomOLD { - Typ: AtomBool, - data: 0, - } - } -} -func (v AtomOLD) Bool() bool { - if v.Typ != AtomBool { - panic("Tried to use non-bool as bool") - } - return v.data == 1 -} -func NewAtomNumber(v float64) AtomOLD { - return AtomOLD { - Typ: AtomNumber, - data: math.Float64bits(v), - } -} -func (v AtomOLD) Number() float64 { - if v.Typ != AtomNumber { - panic("Tried to use non-number as number") - } - return math.Float64frombits(v.data) -} -func NewAtomTerminal(v ValueTerminal) AtomOLD { - return AtomOLD { - Typ: AtomTerminal, - data: uint64(v), - } -} -func (v AtomOLD) Terminal() ValueTerminal { - if v.Typ != AtomTerminal { - panic("Tried to use non-terminal as terminal") - } - return ValueTerminal(v.data) -} -func NewAtomStringTerminal() AtomOLD { - return AtomOLD { - Typ: AtomStringTerminal, - data: 0, - } -} -func NewAtomStringRune(v rune) AtomOLD { - return AtomOLD { - Typ: AtomStringRune, - data: uint64(v), - } -} -func (v AtomOLD) StringRune() rune { - if v.Typ != AtomStringRune { - panic("Tried to use non-stringrune as stringrune") - } - return rune(v.data) -} -func (v AtomOLD) String() string { - switch v.Typ { - case AtomNull: - return "null" - case AtomBool: - if v.data == 0 { - return "false" - } - return "true" - case AtomNumber: - return fmt.Sprintf("%v", math.Float64frombits(v.data)) - case AtomTerminal: - switch ValueTerminal(v.data) { - case MapBegin: - return "{" - case MapEnd: - return "}" - case ArrayBegin: - return "[" - case ArrayEnd: - return "]" - default: - panic("Invalid terminal atom") - } - case AtomStringTerminal: - return "\"" - case AtomStringRune: - return string(rune(v.data)) - default: - panic("Invalid atom type") - } -} |