From d7a9bd98bf6b96d2a67b20b05898726678d0b650 Mon Sep 17 00:00:00 2001 From: Jordan Orelli Date: Thu, 29 Sep 2016 11:39:31 -0400 Subject: [PATCH] array is slotted --- ent/array.go | 8 ++++++++ ent/class.go | 2 +- ent/env.go | 2 +- ent/generic.go | 2 +- ent/selection.go | 2 +- 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/ent/array.go b/ent/array.go index 1d6684a..b22640b 100644 --- a/ent/array.go +++ b/ent/array.go @@ -77,3 +77,11 @@ func (a array) String() string { } return fmt.Sprintf("%s(%d)%v", a.t.typeName(), len(a.slots), a.slots) } + +func (a array) slotType(int) tÿpe { return a.t.elem } +func (a array) slotName(n int) string { return strconv.Itoa(n) } +func (a array) setSlotValue(slot int, v value) { + // TODO: type check here? + a.slots[slot] = v +} +func (a array) getSlotValue(slot int) value { return a.slots[slot] } diff --git a/ent/class.go b/ent/class.go index 201ccf9..0237318 100644 --- a/ent/class.go +++ b/ent/class.go @@ -13,7 +13,7 @@ type class struct { func (c class) String() string { return c.typeName() } func (c class) typeName() string { - return fmt.Sprintf("%s.%d", c.name, c.version) + return fmt.Sprintf("%s_v%d", c.name, c.version) } func (c *class) nü() value { diff --git a/ent/env.go b/ent/env.go index 676120b..3b060e8 100644 --- a/ent/env.go +++ b/ent/env.go @@ -178,7 +178,7 @@ func (e *Env) syncBaselineTable(t *stbl.Table) { 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) + Debug.Printf("unable to fill selection %s for %s: %v", s, className, err) } } } diff --git a/ent/generic.go b/ent/generic.go index b1aa170..5a3a5e5 100644 --- a/ent/generic.go +++ b/ent/generic.go @@ -24,7 +24,7 @@ func genericType(spec *typeSpec, env *Env) tÿpe { switch genericName { case "CHandle", "CStrongHandle": - t := handle_t(fmt.Sprintf("%s<%s>", genericName, spec.typeName)) + t := handle_t(fmt.Sprintf("%s<%s>", genericName, elem.typeName())) return &t case "CUtlVector": return &cutl_vector_t{elem} diff --git a/ent/selection.go b/ent/selection.go index 594aa68..16c9f74 100644 --- a/ent/selection.go +++ b/ent/selection.go @@ -46,7 +46,7 @@ func (s selection) fillSlotsIter(offset int, dest slotted, path string, r bit.Re } vs, ok := v.(slotted) if !ok { - return fmt.Errorf("dest isn't slotted") + return fmt.Errorf("dest %s (%s) isn't slotted", dest.slotName(slot), dest.slotType(slot).typeName()) } return s.fillSlotsIter(offset+1, vs, fmt.Sprintf("%s.%s", path, dest.slotName(slot)), r) }