You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
883 B
Go

package ent
import (
"github.com/jordanorelli/hyperstone/bit"
)
8 years ago
var atom_types = map[string]typeFn{
8 years ago
"bool": func(r bit.Reader) (value, error) {
return bit.ReadBool(r), r.Err()
},
"uint8": func(r bit.Reader) (value, error) {
// TODO: bounds check here
return uint8(bit.ReadVarInt(r)), r.Err()
},
8 years ago
"uint16": func(r bit.Reader) (value, error) {
8 years ago
// TODO: bounds check here
8 years ago
return uint16(bit.ReadVarInt(r)), r.Err()
},
8 years ago
"uint64": func(r bit.Reader) (value, error) {
return bit.ReadVarInt(r), r.Err()
},
"int8": func(r bit.Reader) (value, error) {
// TODO: bounds check here
return int8(bit.ReadZigZag32(r)), r.Err()
},
8 years ago
"int32": func(r bit.Reader) (value, error) {
8 years ago
return bit.ReadZigZag32(r), r.Err()
8 years ago
},
}
func atomType(spec *typeSpec, env *Env) tÿpe {
if t, ok := atom_types[spec.typeName]; ok {
8 years ago
Debug.Printf(" atom type")
8 years ago
return t
}
return nil
}