examples/stadtx: commit first working example

This commit is contained in:
Michael McLoughlin
2018-12-19 22:09:55 -08:00
parent 48a84b6b13
commit 854271d978
6 changed files with 744 additions and 3 deletions

View File

@@ -3,7 +3,6 @@ package gotypes
import (
"bytes"
"errors"
"fmt"
"go/token"
"go/types"
"strconv"
@@ -113,12 +112,17 @@ func newTuple(t *types.Tuple, offsets []int64, size int64, defaultprefix string)
func (t *Tuple) Lookup(name string) Component {
e := t.byname[name]
if e == nil {
return componenterr(fmt.Sprintf("unknown variable \"%s\"", name))
return errorf("unknown variable \"%s\"", name)
}
return e
}
func (t *Tuple) At(i int) Component { return t.components[i] }
func (t *Tuple) At(i int) Component {
if i >= len(t.components) {
return errorf("index out of range")
}
return t.components[i]
}
func (t *Tuple) Bytes() int { return t.size }