mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-18 08:32:11 +01:00
Add an array.copy_from method.
This commit is contained in:
1 parent
569e800bac
commit
ed8a91ef51
10 files changed
+116
-43
No files matched your search
+24
-6
@@ -658,15 +658,16 @@ func (q *checker) bcheckExprOther(n *a.Expr, depth uint32) (*big.Int, *big.Int,
|
||||
isThisMethod(q.tm, n, "init_huff", 4) {
|
||||
|
||||
for _, o := range n.Args() {
|
||||
a := o.Arg().Value()
|
||||
// TODO: check that the arg range at the caller and the
|
||||
// signature are compatible.
|
||||
oMin, oMax, err := q.bcheckExpr(o.Arg().Value(), depth)
|
||||
aMin, aMax, err := q.bcheckExpr(a, depth)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
// TODO: check that oMin and oMax is within the function's
|
||||
// TODO: check that aMin and aMax is within the function's
|
||||
// declared arg bounds.
|
||||
_, _ = oMin, oMax
|
||||
_, _ = aMin, aMax
|
||||
}
|
||||
break
|
||||
}
|
||||
@@ -706,12 +707,29 @@ func (q *checker) bcheckExprOther(n *a.Expr, depth uint32) (*big.Int, *big.Int,
|
||||
}
|
||||
// TODO: delete this hack that only matches "foo.decode(etc)".
|
||||
if isThatMethod(q.tm, n, q.tm.ByName("decode").Key(), 2) {
|
||||
for _, aNode := range n.Args() {
|
||||
a := aNode.Arg().Value()
|
||||
_, _, err := q.bcheckExpr(a, depth)
|
||||
for _, o := range n.Args() {
|
||||
a := o.Arg().Value()
|
||||
aMin, aMax, err := q.bcheckExpr(a, depth)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
// TODO: check that aMin and aMax is within the function's
|
||||
// declared arg bounds.
|
||||
_, _ = aMin, aMax
|
||||
}
|
||||
return nil, nil, nil
|
||||
}
|
||||
// TODO: delete this hack that only matches "foo.copy_from(etc)".
|
||||
if isThatMethod(q.tm, n, t.KeyCopyFrom, 1) {
|
||||
for _, o := range n.Args() {
|
||||
a := o.Arg().Value()
|
||||
aMin, aMax, err := q.bcheckExpr(a, depth)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
// TODO: check that aMin and aMax is within the function's
|
||||
// declared arg bounds.
|
||||
_, _ = aMin, aMax
|
||||
}
|
||||
return nil, nil, nil
|
||||
}
|
||||
|
||||
+3
-17
@@ -428,23 +428,9 @@ func (q *checker) tcheckExprOther(n *a.Expr, depth uint32) error {
|
||||
return nil
|
||||
}
|
||||
// TODO: delete this hack that only matches "foo.set_literal_width(etc)".
|
||||
if isThatMethod(q.tm, n, q.tm.ByName("set_literal_width").Key(), 1) {
|
||||
foo := n.LHS().Expr().LHS().Expr()
|
||||
if err := q.tcheckExpr(foo, depth); err != nil {
|
||||
return err
|
||||
}
|
||||
n.LHS().SetTypeChecked()
|
||||
n.LHS().Expr().SetMType(typeExprPlaceholder) // HACK.
|
||||
for _, o := range n.Args() {
|
||||
if err := q.tcheckArg(o.Arg(), depth); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
n.SetMType(typeExprPlaceholder) // HACK.
|
||||
return nil
|
||||
}
|
||||
// TODO: delete this hack that only matches "foo.decode(etc)".
|
||||
if isThatMethod(q.tm, n, q.tm.ByName("decode").Key(), 2) {
|
||||
if isThatMethod(q.tm, n, q.tm.ByName("set_literal_width").Key(), 1) ||
|
||||
isThatMethod(q.tm, n, q.tm.ByName("decode").Key(), 2) ||
|
||||
isThatMethod(q.tm, n, t.KeyCopyFrom, 1) {
|
||||
foo := n.LHS().Expr().LHS().Expr()
|
||||
if err := q.tcheckExpr(foo, depth); err != nil {
|
||||
return err
|
||||
|
||||
Reference in new issue
Block a user