restructure

This commit is contained in:
basil 2025-06-08 15:02:35 -04:00
parent edcbfde351
commit eebaadc16e
Signed by: basil
SSH key fingerprint: SHA256:y04xIFL/yqNaG9ae9Vl95vELtHfApGAIoOGLeVLP/fE
21 changed files with 937 additions and 626 deletions

33
runtime/types.go Normal file
View file

@ -0,0 +1,33 @@
package runtime
//go:generate stringer -type LoxType -trimprefix LoxType
type LoxType int
const (
LoxTypeString LoxType = iota
LoxTypeNumber
LoxTypeBoolean
LoxTypeNil
LoxTypeUndefined
)
type LoxValue struct {
raw any
}
func (v *LoxValue) Type() LoxType {
switch v.raw.(type) {
case string:
return LoxTypeString
case float64, float32:
return LoxTypeNumber
case bool:
return LoxTypeBoolean
default:
return LoxTypeUndefined
}
}
func Value(v any) *LoxValue {
return &LoxValue{v}
}