mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-22 16:47:28 +01:00
Generate C code for an_array[:].
This commit is contained in:
1 parent
f107ec155d
commit
a9f12c23a4
6 files changed
+70
-16
No files matched your search
@@ -761,8 +761,12 @@ func (q *checker) bcheckExprOther(n *a.Expr, depth uint32) (*big.Int, *big.Int,
|
||||
}
|
||||
|
||||
case t.KeyColon:
|
||||
// TODO.
|
||||
return nil, nil, fmt.Errorf("check: unrecognized token.Key (0x%X) for bcheckExprOther", n.ID0().Key())
|
||||
mhs := n.MHS().Expr()
|
||||
rhs := n.RHS().Expr()
|
||||
if mhs == nil && rhs == nil {
|
||||
return nil, nil, nil
|
||||
}
|
||||
return nil, nil, fmt.Errorf("TODO: bcheckExprOther for a non-trivial slice")
|
||||
|
||||
case t.KeyDot:
|
||||
// TODO: delete this hack that only matches "in".
|
||||
|
||||
+35
-1
@@ -487,7 +487,41 @@ func (q *checker) tcheckExprOther(n *a.Expr, depth uint32) error {
|
||||
|
||||
case t.KeyColon:
|
||||
// n is a slice.
|
||||
// TODO.
|
||||
if mhs := n.MHS().Expr(); mhs != nil {
|
||||
if err := q.tcheckExpr(mhs, depth); err != nil {
|
||||
return err
|
||||
}
|
||||
mTyp := mhs.MType()
|
||||
if !mTyp.IsNumTypeOrIdeal() {
|
||||
return fmt.Errorf("check: %s is a slice expression but %s has type %s, not a numeric type",
|
||||
n.String(q.tm), mhs.String(q.tm), mTyp.String(q.tm))
|
||||
}
|
||||
}
|
||||
if rhs := n.RHS().Expr(); rhs != nil {
|
||||
if err := q.tcheckExpr(rhs, depth); err != nil {
|
||||
return err
|
||||
}
|
||||
rTyp := rhs.MType()
|
||||
if !rTyp.IsNumTypeOrIdeal() {
|
||||
return fmt.Errorf("check: %s is a slice expression but %s has type %s, not a numeric type",
|
||||
n.String(q.tm), rhs.String(q.tm), rTyp.String(q.tm))
|
||||
}
|
||||
}
|
||||
lhs := n.LHS().Expr()
|
||||
if err := q.tcheckExpr(lhs, depth); err != nil {
|
||||
return err
|
||||
}
|
||||
lTyp := lhs.MType()
|
||||
switch lTyp.Decorator().Key() {
|
||||
default:
|
||||
return fmt.Errorf("check: %s is a slice expression but %s has type %s, not an array or slice type",
|
||||
n.String(q.tm), lhs.String(q.tm), lTyp.String(q.tm))
|
||||
case t.KeyOpenBracket:
|
||||
n.SetMType(a.NewTypeExpr(t.IDColon, 0, nil, nil, lTyp.Inner()))
|
||||
case t.KeyColon:
|
||||
n.SetMType(lTyp)
|
||||
}
|
||||
return nil
|
||||
|
||||
case t.KeyDot:
|
||||
return q.tcheckDot(n, depth)
|
||||
|
||||
Reference in new issue
Block a user