mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-23 00:47:56 +01:00
Add a writer1.slice method.
This commit is contained in:
1 parent
519ec373f2
commit
18e32d61e5
10 files changed
+115
-24
No files matched your search
@@ -649,6 +649,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.KeyWrite, 1) || isInDst(q.tm, n, t.KeyWriteU8, 1) ||
|
||||
isInDst(q.tm, n, t.KeyCopyFrom32, 2) || isInDst(q.tm, n, t.KeyCopyHistory32, 2) ||
|
||||
isInDst(q.tm, n, t.KeySlice, 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) ||
|
||||
isThisMethod(q.tm, n, "decode_uncompressed", 2) || isThisMethod(q.tm, n, "decode_huffman", 2) ||
|
||||
|
||||
+7
-5
@@ -56,11 +56,13 @@ func trimQuotes(s string) string {
|
||||
|
||||
// typeExprFoo is an *ast.Node MType (implicit type).
|
||||
var (
|
||||
typeExprBool = a.NewTypeExpr(0, t.IDBool, nil, nil, nil)
|
||||
typeExprIdeal = a.NewTypeExpr(0, t.IDDoubleZ, nil, nil, nil)
|
||||
typeExprList = a.NewTypeExpr(0, t.IDDollar, nil, nil, nil)
|
||||
typeExprStatus = a.NewTypeExpr(0, t.IDStatus, nil, nil, nil)
|
||||
typeExprU64 = a.NewTypeExpr(0, t.IDU64, nil, nil, nil)
|
||||
typeExprBool = a.NewTypeExpr(0, t.IDBool, nil, nil, nil)
|
||||
typeExprIdeal = a.NewTypeExpr(0, t.IDDoubleZ, nil, nil, nil)
|
||||
typeExprList = a.NewTypeExpr(0, t.IDDollar, nil, nil, nil)
|
||||
typeExprStatus = a.NewTypeExpr(0, t.IDStatus, nil, nil, nil)
|
||||
typeExprU8 = a.NewTypeExpr(0, t.IDU8, nil, nil, nil)
|
||||
typeExprU64 = a.NewTypeExpr(0, t.IDU64, nil, nil, nil)
|
||||
typeExprSliceU8 = a.NewTypeExpr(t.IDColon, 0, nil, nil, typeExprU8)
|
||||
|
||||
// TODO: delete this.
|
||||
typeExprPlaceholder = a.NewTypeExpr(0, t.IDU8, nil, nil, nil)
|
||||
|
||||
+5
-1
@@ -349,6 +349,7 @@ func (q *checker) tcheckExprOther(n *a.Expr, depth uint32) error {
|
||||
isInSrc(q.tm, n, t.KeySkip32, 1) ||
|
||||
isInDst(q.tm, n, t.KeyWrite, 1) || isInDst(q.tm, n, t.KeyWriteU8, 1) ||
|
||||
isInDst(q.tm, n, t.KeyCopyFrom32, 2) || isInDst(q.tm, n, t.KeyCopyHistory32, 2) ||
|
||||
isInDst(q.tm, n, t.KeySlice, 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) ||
|
||||
isThisMethod(q.tm, n, "decode_uncompressed", 2) || isThisMethod(q.tm, n, "decode_huffman", 2) ||
|
||||
@@ -370,6 +371,8 @@ 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) {
|
||||
n.SetMType(typeExprSliceU8) // HACK.
|
||||
} else {
|
||||
n.SetMType(typeExprPlaceholder) // HACK.
|
||||
}
|
||||
@@ -528,8 +531,9 @@ func isInSrc(tm *t.Map, n *a.Expr, methodName t.Key, nArgs int) bool {
|
||||
}
|
||||
|
||||
func isInDst(tm *t.Map, n *a.Expr, methodName t.Key, nArgs int) bool {
|
||||
callSuspendible := methodName != t.KeySlice
|
||||
// TODO: check that n.Args() is "(x:bar)".
|
||||
if n.ID0().Key() != t.KeyOpenParen || !n.CallSuspendible() || len(n.Args()) != nArgs {
|
||||
if n.ID0().Key() != t.KeyOpenParen || n.CallSuspendible() != callSuspendible || len(n.Args()) != nArgs {
|
||||
return false
|
||||
}
|
||||
n = n.LHS().Expr()
|
||||
|
||||
@@ -269,6 +269,7 @@ const (
|
||||
KeyIsError = Key(IDIsError >> KeyShift)
|
||||
KeyIsOK = Key(IDIsOK >> KeyShift)
|
||||
KeyIsSuspension = Key(IDIsSuspension >> KeyShift)
|
||||
KeySlice = Key(IDSlice >> KeyShift)
|
||||
|
||||
KeyXUnaryPlus = Key(IDXUnaryPlus >> KeyShift)
|
||||
KeyXUnaryMinus = Key(IDXUnaryMinus >> KeyShift)
|
||||
@@ -442,6 +443,7 @@ const (
|
||||
IDIsError = ID(0xC5<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
||||
IDIsOK = ID(0xC6<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
||||
IDIsSuspension = ID(0xC7<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
||||
IDSlice = ID(0xC8<<KeyShift | FlagsIdent | FlagsImplicitSemicolon)
|
||||
)
|
||||
|
||||
// The IDXFoo IDs are not returned by the tokenizer. They are used by the
|
||||
@@ -637,6 +639,7 @@ var builtInsByKey = [nBuiltInKeys]struct {
|
||||
KeyIsError: {"is_error", IDIsError},
|
||||
KeyIsOK: {"is_ok", IDIsOK},
|
||||
KeyIsSuspension: {"is_suspension", IDIsSuspension},
|
||||
KeySlice: {"slice", IDSlice},
|
||||
}
|
||||
|
||||
var builtInsByName = map[string]ID{}
|
||||
|
||||
Reference in new issue
Block a user