Add a (table T).linearize method

This commit is contained in:
Nigel Tao committed 2018-05-18 13:54:07 +10:00
1 parent f6cd4b2af2
commit 85256c7a45
13 files changed
+120 -2

No files matched your search

+2
View File
@@ -180,4 +180,6 @@ var TableFuncs = []string{
"T2.height()(ret u64)",
"T2.stride()(ret u64)",
"T2.width()(ret u64)",
"T2.linearize()(ret T1)",
}
+4 -1
View File
@@ -532,8 +532,11 @@ func (q *checker) tcheckExprCall(n *a.Expr, depth uint32) error {
case t.QID{t.IDBase, t.IDDagger1}:
genericType1 = lhs.MType().Receiver()
case t.QID{t.IDBase, t.IDDagger2}:
genericType1 = lhs.MType().Receiver() // TODO: convert table T to slice T.
genericType2 = lhs.MType().Receiver()
if genericType2.Decorator() != t.IDTable {
return fmt.Errorf("check: internal error: %q is not a generic table", genericType2.Str(q.tm))
}
genericType1 = a.NewTypeExpr(t.IDSlice, 0, 0, nil, nil, genericType2.Inner())
}
// Check that the func's in type matches the arguments.
+2
View File
@@ -478,6 +478,7 @@ const (
IDHeight = ID(0x216)
IDStride = ID(0x217)
IDWidth = ID(0x218)
IDLinearize = ID(0x219)
)
var builtInsByID = [nBuiltInIDs]string{
@@ -684,6 +685,7 @@ var builtInsByID = [nBuiltInIDs]string{
IDHeight: "height",
IDStride: "stride",
IDWidth: "width",
IDLinearize: "linearize",
}
var builtInsByName = map[string]ID{}