Rename writer1.slice to writer1.since_mark.

This commit is contained in:
Nigel Tao committed 2017-10-26 13:03:19 +11:00
1 parent bdfe4abbd3
commit 5052b16f2d
7 files changed
+18 -23

No files matched your search

+1 -1
View File
@@ -168,7 +168,7 @@ func (g *gen) writeExprOther(b *buffer, n *a.Expr, rp replacementPolicy, pp pare
b.writes(")")
return nil
}
if isInDst(g.tm, n, t.KeySlice, 0) {
if isInDst(g.tm, n, t.KeySinceMark, 0) {
b.printf("((puffs_base__slice_u8){ "+
".ptr = %sdst.private_impl.mark, "+
".len = %sdst.private_impl.mark ? %swptr_dst - %sdst.private_impl.mark : 0, })",
+1 -1
View File
@@ -695,7 +695,7 @@ func isInDst(tm *t.Map, n *a.Expr, methodName t.Key, nArgs int) bool {
methodName != t.KeyCopyFromHistory32 &&
methodName != t.KeyCopyFromSlice32 &&
methodName != t.KeyCopyFromSlice &&
methodName != t.KeySlice &&
methodName != t.KeySinceMark &&
methodName != t.KeyMark
// TODO: check that n.Args() is "(x:bar)".
if n.ID0().Key() != t.KeyOpenParen || n.CallSuspendible() != callSuspendible || len(n.Args()) != nArgs {
+1 -1
View File
@@ -723,7 +723,7 @@ func (q *checker) bcheckExprOther(n *a.Expr, depth uint32) (*big.Int, *big.Int,
isInSrc(q.tm, n, t.KeySkip32, 1) ||
isInDst(q.tm, n, t.KeyCopyFromSlice, 1) || isInDst(q.tm, n, t.KeyCopyFromSlice32, 2) ||
isInDst(q.tm, n, t.KeyCopyFromReader32, 2) || isInDst(q.tm, n, t.KeyCopyFromHistory32, 2) ||
isInDst(q.tm, n, t.KeyWriteU8, 1) || isInDst(q.tm, n, t.KeySlice, 0) ||
isInDst(q.tm, n, t.KeyWriteU8, 1) || isInDst(q.tm, n, t.KeySinceMark, 0) ||
isInDst(q.tm, n, t.KeyMark, 0) ||
isThisMethod(q.tm, n, "decode_header", 1) || isThisMethod(q.tm, n, "decode_lsd", 1) ||
isThisMethod(q.tm, n, "decode_extension", 1) || isThisMethod(q.tm, n, "decode_id", 2) ||
+3 -3
View File
@@ -441,7 +441,7 @@ func (q *checker) tcheckExprOther(n *a.Expr, depth uint32) error {
isInSrc(q.tm, n, t.KeySkip32, 1) ||
isInDst(q.tm, n, t.KeyCopyFromSlice, 1) || isInDst(q.tm, n, t.KeyCopyFromSlice32, 2) ||
isInDst(q.tm, n, t.KeyCopyFromReader32, 2) || isInDst(q.tm, n, t.KeyCopyFromHistory32, 2) ||
isInDst(q.tm, n, t.KeyWriteU8, 1) || isInDst(q.tm, n, t.KeySlice, 0) ||
isInDst(q.tm, n, t.KeyWriteU8, 1) || isInDst(q.tm, n, t.KeySinceMark, 0) ||
isInDst(q.tm, n, t.KeyMark, 0) ||
isThisMethod(q.tm, n, "decode_header", 1) || isThisMethod(q.tm, n, "decode_lsd", 1) ||
isThisMethod(q.tm, n, "decode_extension", 1) || isThisMethod(q.tm, n, "decode_id", 2) ||
@@ -464,7 +464,7 @@ func (q *checker) tcheckExprOther(n *a.Expr, depth uint32) error {
n.SetMType(typeExprPlaceholder32) // HACK.
} else if isInSrc(q.tm, n, t.KeyReadU16BE, 0) || isInSrc(q.tm, n, t.KeyReadU16LE, 0) {
n.SetMType(typeExprPlaceholder16) // HACK.
} else if isInDst(q.tm, n, t.KeySlice, 0) {
} else if isInDst(q.tm, n, t.KeySinceMark, 0) {
n.SetMType(typeExprSliceU8) // HACK.
} else if isInDst(q.tm, n, t.KeyCopyFromSlice, 1) {
n.SetMType(typeExprU64) // HACK.
@@ -712,7 +712,7 @@ func isInDst(tm *t.Map, n *a.Expr, methodName t.Key, nArgs int) bool {
methodName != t.KeyCopyFromHistory32 &&
methodName != t.KeyCopyFromSlice32 &&
methodName != t.KeyCopyFromSlice &&
methodName != t.KeySlice &&
methodName != t.KeySinceMark &&
methodName != t.KeyMark
// TODO: check that n.Args() is "(x:bar)".
if n.ID0().Key() != t.KeyOpenParen || n.CallSuspendible() != callSuspendible || len(n.Args()) != nArgs {
+7 -7
View File
@@ -279,6 +279,7 @@ const (
KeyReadU32LE = Key(IDReadU32LE >> KeyShift)
KeyReadU64BE = Key(IDReadU64BE >> KeyShift)
KeyReadU64LE = Key(IDReadU64LE >> KeyShift)
KeySinceMark = Key(IDSinceMark >> KeyShift)
KeyWriteU8 = Key(IDWriteU8 >> KeyShift)
KeyWriteU16BE = Key(IDWriteU16BE >> KeyShift)
KeyWriteU16LE = Key(IDWriteU16LE >> KeyShift)
@@ -296,7 +297,6 @@ const (
KeyCopyFromSlice32 = Key(IDCopyFromSlice32 >> KeyShift)
KeySkip32 = Key(IDSkip32 >> KeyShift)
KeySkip64 = Key(IDSkip64 >> KeyShift)
KeySlice = Key(IDSlice >> KeyShift)
KeyLength = Key(IDLength >> KeyShift)
KeyAvailable = Key(IDAvailable >> KeyShift)
KeyPrefix = Key(IDPrefix >> KeyShift)
@@ -466,6 +466,7 @@ const (
IDReadU32LE = ID(0xB5<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
IDReadU64BE = ID(0xB6<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
IDReadU64LE = ID(0xB7<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
IDSinceMark = ID(0xB8<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
IDWriteU8 = ID(0xB9<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
IDWriteU16BE = ID(0xBA<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
IDWriteU16LE = ID(0xBB<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
@@ -483,11 +484,10 @@ const (
IDCopyFromSlice32 = ID(0xC6<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
IDSkip32 = ID(0xC7<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
IDSkip64 = ID(0xC8<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
IDSlice = ID(0xC9<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
IDLength = ID(0xCA<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
IDAvailable = ID(0xCB<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
IDPrefix = ID(0xCC<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
IDSuffix = ID(0xCD<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
IDLength = ID(0xC9<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
IDAvailable = ID(0xCA<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
IDPrefix = ID(0xCB<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
IDSuffix = ID(0xCC<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
)
// The IDXFoo IDs are not returned by the tokenizer. They are used by the
@@ -671,6 +671,7 @@ var builtInsByKey = [nBuiltInKeys]struct {
KeyReadU32LE: {"read_u32le", IDReadU32LE},
KeyReadU64BE: {"read_u64be", IDReadU64BE},
KeyReadU64LE: {"read_u64le", IDReadU64LE},
KeySinceMark: {"since_mark", IDSinceMark},
KeyWriteU8: {"write_u8", IDWriteU8},
KeyWriteU16BE: {"write_u16be", IDWriteU16BE},
KeyWriteU16LE: {"write_u16le", IDWriteU16LE},
@@ -688,7 +689,6 @@ var builtInsByKey = [nBuiltInKeys]struct {
KeyCopyFromSlice32: {"copy_from_slice32", IDCopyFromSlice32},
KeySkip32: {"skip32", IDSkip32},
KeySkip64: {"skip64", IDSkip64},
KeySlice: {"slice", IDSlice},
KeyLength: {"length", IDLength},
KeyAvailable: {"available", IDAvailable},
KeyPrefix: {"prefix", IDPrefix},
+4 -6
View File
@@ -123,12 +123,10 @@ pub func flate_decoder.decode?(dst writer1, src reader1)() {
// TODO: rename "return" to "raise"?
return z
}
// TODO: should "slice" be "slice!", as the return value lets you
// modify the state of in.dst, so future mutations (via the slice) can
// change the veracity of any in.dst assertions?
//
// Should the RHS be "in.dst[:]" instead of a method call?
var written[] u8 = in.dst.slice()
// TODO: should "since_mark" be "since_mark!", as the return value lets
// you modify the state of in.dst, so future mutations (via the slice)
// can change the veracity of any in.dst assertions?
var written[] u8 = in.dst.since_mark()
// Append written, the decoded output, to the history ringbuffer.
if written.length() >= 0x8000 {
// If written is longer than the ringbuffer, we can ignore the
+1 -4
View File
@@ -50,10 +50,7 @@ pub func zlib_decoder.decode?(dst writer1, src reader1)() {
var z status = try this.flate.decode?(dst:in.dst, src:in.src)
// TODO: expose some API to opt out of checksumming, trading off error
// detection for throughput.
//
// TODO: in.dst.slice needs a previous mark statement. Do that, and
// remove the b_wstart_dst derived variables.
checksum = this.adler.update(x:in.dst.slice())
checksum = this.adler.update(x:in.dst.since_mark())
if z.is_ok() {
break
}