we got a mem overflow now

types
Jordan Orelli 8 years ago
parent 91f6f235cc
commit 75c3ac466b

@ -72,5 +72,8 @@ func (a array) read(r bit.Reader) error {
}
func (a array) String() string {
return fmt.Sprintf("%s%v", a.t.typeName(), a.slots)
if len(a.slots) > 8 {
return fmt.Sprintf("%s(%d)%v...", a.t.typeName(), len(a.slots), a.slots[:8])
}
return fmt.Sprintf("%s(%d)%v", a.t.typeName(), len(a.slots), a.slots)
}

@ -111,7 +111,7 @@ func (v *uint32_v) read(r bit.Reader) error {
}
func (v uint32_v) String() string {
return strconv.FormatUint(uint64(v), 0)
return strconv.FormatUint(uint64(v), 10)
}
// ------------------------------------------------------------------------------

@ -2,7 +2,6 @@ package ent
import (
"fmt"
"github.com/jordanorelli/hyperstone/bit"
)
type class struct {
@ -11,17 +10,10 @@ type class struct {
fields []field
}
func (c class) String() string {
return fmt.Sprintf("<%s.%d>", c.name, c.version)
}
func (c class) String() string { return c.typeName() }
func (c class) typeName() string {
return fmt.Sprintf("class:%s", c.name)
}
func (c *class) read(r bit.Reader) (value, error) {
bit.ReadBool(r) // ???
return c.nü(), nil
return fmt.Sprintf("%s.%d", c.name, c.version)
}
func (c *class) nü() value {

@ -11,17 +11,7 @@ type entity struct {
}
func (e *entity) read(r bit.Reader) error {
Debug.Printf("entity %s read", e.className())
sr := new(selectionReader)
selections, err := sr.readSelections(r, htree)
if err != nil {
return wrap(err, "entity of type %s failed to read selections", e.className())
}
for _, s := range selections {
if err := s.fillSlots(e, r); err != nil {
return err
}
}
bit.ReadBool(r) // ???
return nil
}
@ -33,11 +23,16 @@ func (e *entity) className() string {
}
func (e *entity) String() string {
return fmt.Sprintf("%s{%v}", e.class.typeName(), e.slots)
return fmt.Sprintf("%s{id: ?}", e.class.typeName())
}
func (e *entity) tÿpe() tÿpe { return e.class }
func (e *entity) slotType(i int) tÿpe { return e.class.fields[i].tÿpe }
func (e *entity) slotType(i int) tÿpe {
if i >= len(e.class.fields) {
return typeError("index out of range in slotType: %d is beyond capacity %d", i, len(e.class.fields))
}
return e.class.fields[i].tÿpe
}
func (e *entity) slotName(i int) string { return e.class.fields[i].name }
func (e *entity) setSlotValue(i int, v value) { e.slots[i] = v }
func (e *entity) getSlotValue(i int) value { return e.slots[i] }

@ -113,6 +113,7 @@ func (e *Env) fillClasses(flat *dota.CSVCMsg_FlattenedSerializer) {
class.fields = make([]field, len(s.GetFieldsIndex()))
for i, id := range s.GetFieldsIndex() {
Debug.Printf("class %s has field %s (%s)", name, e.fields[id].name, e.fields[id].typeName())
class.fields[i] = e.fields[id]
}
}
@ -149,6 +150,7 @@ func (e *Env) syncBaselineTable(t *stbl.Table) {
}
r := new(bit.BufReader)
sr := new(selectionReader)
for _, entry := range t.Entries() {
netId, err := strconv.Atoi(entry.Key)
if err != nil {
@ -166,10 +168,18 @@ func (e *Env) syncBaselineTable(t *stbl.Table) {
continue
}
Debug.Printf("syncBaselines key: %s className: %s", entry.Key, c.name)
ent := c.nü()
ent := c.nü().(*entity)
r.SetSource(entry.Value)
if err := ent.read(r); err != nil {
Debug.Printf("syncBaselines failed to fill an entity: %v", err)
selections, err := sr.readSelections(r)
if err != nil {
Debug.Printf("unable to read selections for %s: %v", className, err)
continue
}
Debug.Printf("selections: %v", selections)
for _, s := range selections {
if err := s.fillSlots(ent, r); err != nil {
Debug.Printf("unable to fill slots for %s: %v", className, err)
}
}
}
}

@ -24,7 +24,7 @@ func genericType(spec *typeSpec, env *Env) tÿpe {
switch genericName {
case "CHandle", "CStrongHandle":
t := handle_t(spec.typeName)
t := handle_t(fmt.Sprintf("%s<%s>", genericName, spec.typeName))
return &t
case "CUtlVector":
return &cutl_vector_t{elem}
@ -76,7 +76,7 @@ func (t *cutl_vector_t) nü() value {
}
func (t cutl_vector_t) typeName() string {
return fmt.Sprintf("vector:%s", t.elem.typeName())
return fmt.Sprintf("CUtlVector<%s>", t.elem.typeName())
}
type cutl_vector struct {
@ -93,5 +93,8 @@ func (v *cutl_vector) read(r bit.Reader) error {
}
func (v cutl_vector) String() string {
return fmt.Sprintf("%s<%v>", v.t.typeName(), v.slots)
if len(v.slots) > 8 {
return fmt.Sprintf("%s(%d)%v...", v.t.typeName(), len(v.slots), v.slots[:8])
}
return fmt.Sprintf("%s(%d)%v", v.t.typeName(), len(v.slots), v.slots)
}

@ -25,7 +25,7 @@ func (h *handle) read(r bit.Reader) error {
}
func (h handle) String() string {
return fmt.Sprintf("handle<%s>: %d", h.t.typeName(), h.id)
return fmt.Sprintf("%s:%d", h.t.typeName(), h.id)
}
func handleType(spec *typeSpec, env *Env) tÿpe {

@ -134,6 +134,7 @@ var hlist = nodeList{
r.add(int(bit.ReadUBitVarFP(br)) + 5)
}},
lNode{"PushOneLeftDeltaOneRightNonZero", 8, 2942, func(r *selectionReader, br bit.Reader) {
Debug.Printf("PushOneLeftDeltaOneRightNonZero")
r.add(1)
r.push(int(bit.ReadUBitVarFP(br)))
}},
@ -267,4 +268,4 @@ var hlist = nodeList{
}},
}
var htree = makeTree(hlist)
var huffRoot = makeTree(hlist)

@ -67,11 +67,11 @@ type selectionReader struct {
all [1024]selection
}
func (r *selectionReader) readSelections(br bit.Reader, n node) ([]selection, error) {
func (r *selectionReader) readSelections(br bit.Reader) ([]selection, error) {
r.cur.count = 1
r.cur.vals[0] = -1
r.count = 0
for fn := walk(n, br); fn != nil; fn = walk(n, br) {
for fn := walk(huffRoot, br); fn != nil; fn = walk(huffRoot, br) {
if err := br.Err(); err != nil {
return nil, fmt.Errorf("unable to read selection: bit reader error: %v", err)
}

@ -24,7 +24,7 @@ type vector_t struct {
}
func (t vector_t) typeName() string {
return fmt.Sprintf("vector:%s", t.elem.typeName())
return fmt.Sprintf("vector<%s>", t.elem.typeName())
}
func (t *vector_t) nü() value {

Loading…
Cancel
Save