array is slotted

types
Jordan Orelli 8 years ago
parent 75c3ac466b
commit d7a9bd98bf

@ -77,3 +77,11 @@ func (a array) String() string {
} }
return fmt.Sprintf("%s(%d)%v", a.t.typeName(), len(a.slots), a.slots) 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] }

@ -13,7 +13,7 @@ type class struct {
func (c class) String() string { return c.typeName() } func (c class) String() string { return c.typeName() }
func (c class) typeName() string { 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 { func (c *class) nü() value {

@ -178,7 +178,7 @@ func (e *Env) syncBaselineTable(t *stbl.Table) {
Debug.Printf("selections: %v", selections) Debug.Printf("selections: %v", selections)
for _, s := range selections { for _, s := range selections {
if err := s.fillSlots(ent, r); err != nil { 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)
} }
} }
} }

@ -24,7 +24,7 @@ func genericType(spec *typeSpec, env *Env) tÿpe {
switch genericName { switch genericName {
case "CHandle", "CStrongHandle": 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 return &t
case "CUtlVector": case "CUtlVector":
return &cutl_vector_t{elem} return &cutl_vector_t{elem}

@ -46,7 +46,7 @@ func (s selection) fillSlotsIter(offset int, dest slotted, path string, r bit.Re
} }
vs, ok := v.(slotted) vs, ok := v.(slotted)
if !ok { 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) return s.fillSlotsIter(offset+1, vs, fmt.Sprintf("%s.%s", path, dest.slotName(slot)), r)
} }

Loading…
Cancel
Save