Add generated C's io0_etc pointers

This commit is contained in:
Nigel Tao committed 2019-07-06 21:55:37 +10:00
1 parent e08a4dfa3b
commit a842746807
3 files changed
+64

No files matched your search

+6
View File
@@ -73,16 +73,22 @@ const (
// advances, it cannot advance past io2_etc. In the rarer case that an iop_etc
// pointer retreats, undoing a read or write, it cannot retreat past io1_etc.
//
// The iop_etc pointer can change over the lifetime of a function. The ioN_etc
// pointers, for numeric N, cannot.
//
// At the start of a function, these pointers are initialized from an
// io_buffer's fields (ptr, ri, wi, len). For an io_reader:
// - io0_etc = ptr
// - io1_etc = ptr + ri
// - iop_etc = ptr + ri
// - io2_etc = ptr + wi
// and for an io_writer:
// - io0_etc = ptr
// - io1_etc = ptr + wi
// - iop_etc = ptr + wi
// - io2_etc = ptr + len
const (
io0Prefix = "io0_" // Base.
io1Prefix = "io1_" // Lower bound.
io2Prefix = "io2_" // Upper bound.
iopPrefix = "iop_" // Pointer.
+2
View File
@@ -102,6 +102,7 @@ func (g *gen) writeLoadDerivedVar(b *buffer, hack string, prefix string, name t.
if header {
b.printf("uint8_t* %s%s = NULL;", iopPrefix, preName)
b.printf("uint8_t* %s%s WUFFS_BASE__POTENTIALLY_UNUSED = NULL;", io0Prefix, preName)
b.printf("uint8_t* %s%s WUFFS_BASE__POTENTIALLY_UNUSED = NULL;", io1Prefix, preName)
b.printf("uint8_t* %s%s WUFFS_BASE__POTENTIALLY_UNUSED = NULL;", io2Prefix, preName)
}
@@ -112,6 +113,7 @@ func (g *gen) writeLoadDerivedVar(b *buffer, hack string, prefix string, name t.
iopPrefix, preName, preName, preName, i1)
if header {
b.printf("%s%s = %s->data.ptr;", io0Prefix, preName, preName)
b.printf("%s%s = %s%s;", io1Prefix, preName, iopPrefix, preName)
b.printf("%s%s = %s->data.ptr + %s->%s;",
io2Prefix, preName, preName, preName, i2)