mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-25 00:55:11 +01:00
Tweak puffsfmt'ing "iterate.8 (etc)".
This commit is contained in:
1 parent
1f9e391e7d
commit
8ee56a7911
2 files changed
+5
-4
No files matched your search
@@ -108,14 +108,15 @@ func Render(w io.Writer, tm *token.Map, src []token.Token, comments []string) (e
|
|||||||
prevID, prevIsTightRight := token.ID(0), false
|
prevID, prevIsTightRight := token.ID(0), false
|
||||||
for _, t := range lineTokens {
|
for _, t := range lineTokens {
|
||||||
const (
|
const (
|
||||||
|
flagsCIL = token.FlagsClose | token.FlagsIdent | token.FlagsLiteral
|
||||||
|
flagsCIS = token.FlagsClose | token.FlagsIdent | token.FlagsStrLiteral
|
||||||
flagsUB = token.FlagsUnaryOp | token.FlagsBinaryOp
|
flagsUB = token.FlagsUnaryOp | token.FlagsBinaryOp
|
||||||
flagsLIC = token.FlagsLiteral | token.FlagsIdent | token.FlagsClose
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if prevID != 0 && !prevIsTightRight && !t.IsTightLeft() {
|
if prevID != 0 && !prevIsTightRight && !t.IsTightLeft() {
|
||||||
// The "(" token's tight-left-ness is context dependent. For
|
// The "(" token's tight-left-ness is context dependent. For
|
||||||
// "f(x)", the "(" is tight-left. For "a * (b + c)", it is not.
|
// "f(x)", the "(" is tight-left. For "a * (b + c)", it is not.
|
||||||
if t.ID.Key() != token.KeyOpenParen || prevID.Flags()&flagsLIC == 0 {
|
if t.ID.Key() != token.KeyOpenParen || prevID.Flags()&flagsCIS == 0 {
|
||||||
buf = append(buf, ' ')
|
buf = append(buf, ' ')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -140,7 +141,7 @@ func Render(w io.Writer, tm *token.Map, src []token.Token, comments []string) (e
|
|||||||
if prevID != 0 && t.ID.Flags()&flagsUB == flagsUB {
|
if prevID != 0 && t.ID.Flags()&flagsUB == flagsUB {
|
||||||
// Token-based (not ast.Node-based) heuristic for whether the
|
// Token-based (not ast.Node-based) heuristic for whether the
|
||||||
// operator looks unary instead of binary.
|
// operator looks unary instead of binary.
|
||||||
prevIsTightRight = prevID.Flags()&flagsLIC == 0
|
prevIsTightRight = prevID.Flags()&flagsCIL == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
prevID = t.ID
|
prevID = t.ID
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ pri func adler32.update(x[] u8)(checksum u32) {
|
|||||||
in.x = in.x[:5552]
|
in.x = in.x[:5552]
|
||||||
}
|
}
|
||||||
|
|
||||||
iterate.8(p ptr u8:in.x) {
|
iterate.8 (p ptr u8:in.x) {
|
||||||
s1 ~+= deref p as u32
|
s1 ~+= deref p as u32
|
||||||
s2 ~+= s1
|
s2 ~+= s1
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user