mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-21 08:47:28 +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
@@ -58,6 +58,23 @@ func (g *gen) writeStatement(b *buffer, n *a.Node, depth uint32) error {
|
||||
b.writes(");\n")
|
||||
return nil
|
||||
}
|
||||
// TODO: delete this hack that only matches "foo.copy_from(etc)".
|
||||
if isThatMethod(g.tm, n, t.KeyCopyFrom, 1) {
|
||||
b.writes("puffs_base_slice_u8_copy_from(")
|
||||
// TODO: don't hard-code this.history (a [32768]u8) as the
|
||||
// receiver. In any case, the receiver should probably be a slice
|
||||
// instead of an array.
|
||||
b.writes("((puffs_base_slice_u8){")
|
||||
b.writes(".ptr=self->private_impl.f_history,")
|
||||
b.writes(".len=sizeof(self->private_impl.f_history)})")
|
||||
b.writeb(',')
|
||||
a := n.Args()[0].Arg().Value()
|
||||
if err := g.writeExpr(b, a, replaceCallSuspendibles, parenthesesMandatory, depth); err != nil {
|
||||
return err
|
||||
}
|
||||
b.writes(");\n")
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("TODO: generate code for foo() when foo is not a ? call-suspendible")
|
||||
|
||||
case a.KIf:
|
||||
|
||||
Reference in new issue
Block a user