mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 02:38:53 +01:00
all: unnecessary use of fmt.Sprintf (#2691)
Signed-off-by: guoguangwu <guoguangwu@magic-shield.com>
This commit is contained in:
parent
c908685e55
commit
54e1263565
@ -464,7 +464,7 @@ type disposeShaderCommand struct {
|
||||
}
|
||||
|
||||
func (c *disposeShaderCommand) String() string {
|
||||
return fmt.Sprintf("dispose-shader: target")
|
||||
return "dispose-shader: target"
|
||||
}
|
||||
|
||||
// Exec executes the disposeShaderCommand.
|
||||
@ -503,7 +503,7 @@ type newShaderCommand struct {
|
||||
}
|
||||
|
||||
func (c *newShaderCommand) String() string {
|
||||
return fmt.Sprintf("new-shader")
|
||||
return "new-shader"
|
||||
}
|
||||
|
||||
// Exec executes a newShaderCommand.
|
||||
|
@ -870,7 +870,7 @@ func (cs *compileState) parseExpr(block *block, fname string, expr ast.Expr, mar
|
||||
// In the context where a local variable is marked as used, any expressions must have its
|
||||
// meaning. Then, a blank identifier is not available there.
|
||||
if markLocalVariableUsed {
|
||||
cs.addError(e.Pos(), fmt.Sprintf("cannot use _ as value"))
|
||||
cs.addError(e.Pos(), "cannot use _ as value")
|
||||
return nil, nil, nil, false
|
||||
}
|
||||
return []shaderir.Expr{
|
||||
@ -1068,7 +1068,7 @@ func (cs *compileState) parseExpr(block *block, fname string, expr ast.Expr, mar
|
||||
return nil, nil, nil, false
|
||||
}
|
||||
if len(exprs) != 1 {
|
||||
cs.addError(e.Pos(), fmt.Sprintf("multiple-value context is not available at a composite literal"))
|
||||
cs.addError(e.Pos(), "multiple-value context is not available at a composite literal")
|
||||
return nil, nil, nil, false
|
||||
}
|
||||
stmts = append(stmts, ss...)
|
||||
@ -1112,7 +1112,7 @@ func (cs *compileState) parseExpr(block *block, fname string, expr ast.Expr, mar
|
||||
stmts = append(stmts, ss...)
|
||||
|
||||
if len(exprs) != 1 {
|
||||
cs.addError(e.Pos(), fmt.Sprintf("multiple-value context is not available at an index expression"))
|
||||
cs.addError(e.Pos(), "multiple-value context is not available at an index expression")
|
||||
return nil, nil, nil, false
|
||||
}
|
||||
idx := exprs[0]
|
||||
@ -1130,7 +1130,7 @@ func (cs *compileState) parseExpr(block *block, fname string, expr ast.Expr, mar
|
||||
}
|
||||
stmts = append(stmts, ss...)
|
||||
if len(exprs) != 1 {
|
||||
cs.addError(e.Pos(), fmt.Sprintf("multiple-value context is not available at an index expression"))
|
||||
cs.addError(e.Pos(), "multiple-value context is not available at an index expression")
|
||||
return nil, nil, nil, false
|
||||
}
|
||||
x := exprs[0]
|
||||
|
@ -497,7 +497,7 @@ func (cs *compileState) functionReturnTypes(block *block, expr ast.Expr) ([]shad
|
||||
|
||||
func (s *compileState) parseVariable(block *block, fname string, vs *ast.ValueSpec) ([]variable, []shaderir.Expr, []shaderir.Stmt, bool) {
|
||||
if len(vs.Names) != len(vs.Values) && len(vs.Values) != 1 && len(vs.Values) != 0 {
|
||||
s.addError(vs.Pos(), fmt.Sprintf("the numbers of lhs and rhs don't match"))
|
||||
s.addError(vs.Pos(), "the numbers of lhs and rhs don't match")
|
||||
return nil, nil, nil, false
|
||||
}
|
||||
|
||||
@ -542,7 +542,7 @@ func (s *compileState) parseVariable(block *block, fname string, vs *ast.ValueSp
|
||||
ts = rts
|
||||
}
|
||||
if len(ts) > 1 {
|
||||
s.addError(vs.Pos(), fmt.Sprintf("the numbers of lhs and rhs don't match"))
|
||||
s.addError(vs.Pos(), "the numbers of lhs and rhs don't match")
|
||||
}
|
||||
t = ts[0]
|
||||
}
|
||||
@ -585,7 +585,7 @@ func (s *compileState) parseVariable(block *block, fname string, vs *ast.ValueSp
|
||||
inittypes = ts
|
||||
}
|
||||
if len(ts) != len(vs.Names) {
|
||||
s.addError(vs.Pos(), fmt.Sprintf("the numbers of lhs and rhs don't match"))
|
||||
s.addError(vs.Pos(), "the numbers of lhs and rhs don't match")
|
||||
continue
|
||||
}
|
||||
}
|
||||
@ -760,12 +760,12 @@ func (cs *compileState) parseFunc(block *block, d *ast.FuncDecl) (function, bool
|
||||
|
||||
checkVaryings := func(vs []variable) {
|
||||
if len(cs.ir.Varyings) != len(vs) {
|
||||
cs.addError(d.Pos(), fmt.Sprintf("the number of vertex entry point's returning values and the number of fragment entry point's params must be the same"))
|
||||
cs.addError(d.Pos(), "the number of vertex entry point's returning values and the number of fragment entry point's params must be the same")
|
||||
return
|
||||
}
|
||||
for i, t := range cs.ir.Varyings {
|
||||
if t.Main != vs[i].typ.Main {
|
||||
cs.addError(d.Pos(), fmt.Sprintf("vertex entry point's returning value types and fragment entry point's param types must match"))
|
||||
cs.addError(d.Pos(), "vertex entry point's returning value types and fragment entry point's param types must match")
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -789,7 +789,7 @@ func (cs *compileState) parseFunc(block *block, d *ast.FuncDecl) (function, bool
|
||||
|
||||
// The first out-param is treated as gl_Position in GLSL.
|
||||
if outParams[0].typ.Main != shaderir.Vec4 {
|
||||
cs.addError(d.Pos(), fmt.Sprintf("vertex entry point must have at least one returning vec4 value for a position"))
|
||||
cs.addError(d.Pos(), "vertex entry point must have at least one returning vec4 value for a position")
|
||||
return function{}, false
|
||||
}
|
||||
|
||||
@ -804,16 +804,16 @@ func (cs *compileState) parseFunc(block *block, d *ast.FuncDecl) (function, bool
|
||||
cs.varyingParsed = true
|
||||
case cs.fragmentEntry:
|
||||
if len(inParams) == 0 {
|
||||
cs.addError(d.Pos(), fmt.Sprintf("fragment entry point must have at least one vec4 parameter for a position"))
|
||||
cs.addError(d.Pos(), "fragment entry point must have at least one vec4 parameter for a position")
|
||||
return function{}, false
|
||||
}
|
||||
if inParams[0].typ.Main != shaderir.Vec4 {
|
||||
cs.addError(d.Pos(), fmt.Sprintf("fragment entry point must have at least one vec4 parameter for a position"))
|
||||
cs.addError(d.Pos(), "fragment entry point must have at least one vec4 parameter for a position")
|
||||
return function{}, false
|
||||
}
|
||||
|
||||
if len(outParams) != 0 || returnType.Main != shaderir.Vec4 {
|
||||
cs.addError(d.Pos(), fmt.Sprintf("fragment entry point must have one returning vec4 value for a color"))
|
||||
cs.addError(d.Pos(), "fragment entry point must have one returning vec4 value for a color")
|
||||
return function{}, false
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ func (cs *compileState) parseStmt(block *block, fname string, stmt ast.Stmt, inP
|
||||
switch stmt.Tok {
|
||||
case token.DEFINE:
|
||||
if len(stmt.Lhs) != len(stmt.Rhs) && len(stmt.Rhs) != 1 {
|
||||
cs.addError(stmt.Pos(), fmt.Sprintf("single-value context and multiple-value context cannot be mixed"))
|
||||
cs.addError(stmt.Pos(), "single-value context and multiple-value context cannot be mixed")
|
||||
return nil, false
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ func (cs *compileState) parseStmt(block *block, fname string, stmt ast.Stmt, inP
|
||||
stmts = append(stmts, ss...)
|
||||
case token.ASSIGN:
|
||||
if len(stmt.Lhs) != len(stmt.Rhs) && len(stmt.Rhs) != 1 {
|
||||
cs.addError(stmt.Pos(), fmt.Sprintf("single-value context and multiple-value context cannot be mixed"))
|
||||
cs.addError(stmt.Pos(), "single-value context and multiple-value context cannot be mixed")
|
||||
return nil, false
|
||||
}
|
||||
ss, ok := cs.assign(block, fname, stmt.Pos(), stmt.Lhs, stmt.Rhs, inParams, false)
|
||||
@ -75,7 +75,7 @@ func (cs *compileState) parseStmt(block *block, fname string, stmt ast.Stmt, inP
|
||||
stmts = append(stmts, ss...)
|
||||
|
||||
if lhs[0].Type == shaderir.UniformVariable {
|
||||
cs.addError(stmt.Pos(), fmt.Sprintf("a uniform variable cannot be assigned"))
|
||||
cs.addError(stmt.Pos(), "a uniform variable cannot be assigned")
|
||||
return nil, false
|
||||
}
|
||||
|
||||
@ -559,7 +559,7 @@ func (cs *compileState) parseStmt(block *block, fname string, stmt ast.Stmt, inP
|
||||
|
||||
case *ast.ExprStmt:
|
||||
if _, ok := stmt.X.(*ast.CallExpr); !ok {
|
||||
cs.addError(stmt.Pos(), fmt.Sprintf("the statement is evaluated but not used"))
|
||||
cs.addError(stmt.Pos(), "the statement is evaluated but not used")
|
||||
return nil, false
|
||||
}
|
||||
|
||||
@ -576,7 +576,7 @@ func (cs *compileState) parseStmt(block *block, fname string, stmt ast.Stmt, inP
|
||||
continue
|
||||
}
|
||||
if expr.Exprs[0].Type == shaderir.BuiltinFuncExpr {
|
||||
cs.addError(stmt.Pos(), fmt.Sprintf("the statement is evaluated but not used"))
|
||||
cs.addError(stmt.Pos(), "the statement is evaluated but not used")
|
||||
return nil, false
|
||||
}
|
||||
stmts = append(stmts, shaderir.Stmt{
|
||||
@ -622,7 +622,7 @@ func (cs *compileState) assign(block *block, fname string, pos token.Pos, lhs, r
|
||||
ts = rts
|
||||
}
|
||||
if len(ts) > 1 {
|
||||
cs.addError(pos, fmt.Sprintf("single-value context and multiple-value context cannot be mixed"))
|
||||
cs.addError(pos, "single-value context and multiple-value context cannot be mixed")
|
||||
return nil, false
|
||||
}
|
||||
|
||||
@ -634,7 +634,7 @@ func (cs *compileState) assign(block *block, fname string, pos token.Pos, lhs, r
|
||||
}
|
||||
|
||||
if len(r) > 1 {
|
||||
cs.addError(pos, fmt.Sprintf("single-value context and multiple-value context cannot be mixed"))
|
||||
cs.addError(pos, "single-value context and multiple-value context cannot be mixed")
|
||||
return nil, false
|
||||
}
|
||||
|
||||
@ -646,7 +646,7 @@ func (cs *compileState) assign(block *block, fname string, pos token.Pos, lhs, r
|
||||
|
||||
if len(l) != len(r) {
|
||||
if len(r) == 0 {
|
||||
cs.addError(pos, fmt.Sprintf("right-hand side (no value) used as value"))
|
||||
cs.addError(pos, "right-hand side (no value) used as value")
|
||||
} else {
|
||||
cs.addError(pos, fmt.Sprintf("assignment mismatch: %d variables but the right-hand side has %d values", len(l), len(r)))
|
||||
}
|
||||
@ -675,7 +675,7 @@ func (cs *compileState) assign(block *block, fname string, pos token.Pos, lhs, r
|
||||
}
|
||||
|
||||
if isAssignmentForbidden(&l[0]) {
|
||||
cs.addError(pos, fmt.Sprintf("a uniform variable cannot be assigned"))
|
||||
cs.addError(pos, "a uniform variable cannot be assigned")
|
||||
return nil, false
|
||||
}
|
||||
allblank = false
|
||||
@ -747,7 +747,7 @@ func (cs *compileState) assign(block *block, fname string, pos token.Pos, lhs, r
|
||||
return nil, false
|
||||
}
|
||||
if len(rhsExprs) != len(lhs) {
|
||||
cs.addError(pos, fmt.Sprintf("single-value context and multiple-value context cannot be mixed"))
|
||||
cs.addError(pos, "single-value context and multiple-value context cannot be mixed")
|
||||
}
|
||||
stmts = append(stmts, ss...)
|
||||
}
|
||||
@ -797,7 +797,7 @@ func (cs *compileState) assign(block *block, fname string, pos token.Pos, lhs, r
|
||||
}
|
||||
|
||||
if define && allblank {
|
||||
cs.addError(pos, fmt.Sprintf("no new variables on left side of :="))
|
||||
cs.addError(pos, "no new variables on left side of :=")
|
||||
return nil, false
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ func (cs *compileState) parseType(block *block, fname string, expr ast.Expr) (sh
|
||||
}
|
||||
case *ast.ArrayType:
|
||||
if t.Len == nil {
|
||||
cs.addError(t.Pos(), fmt.Sprintf("array length must be specified"))
|
||||
cs.addError(t.Pos(), "array length must be specified")
|
||||
return shaderir.Type{}, false
|
||||
}
|
||||
var length int
|
||||
@ -69,16 +69,16 @@ func (cs *compileState) parseType(block *block, fname string, expr ast.Expr) (sh
|
||||
return shaderir.Type{}, false
|
||||
}
|
||||
if len(exprs) != 1 {
|
||||
cs.addError(t.Pos(), fmt.Sprintf("invalid length of array"))
|
||||
cs.addError(t.Pos(), "invalid length of array")
|
||||
return shaderir.Type{}, false
|
||||
}
|
||||
if exprs[0].Type != shaderir.NumberExpr {
|
||||
cs.addError(t.Pos(), fmt.Sprintf("length of array must be a constant number"))
|
||||
cs.addError(t.Pos(), "length of array must be a constant number")
|
||||
return shaderir.Type{}, false
|
||||
}
|
||||
l, ok := gconstant.Int64Val(exprs[0].Const)
|
||||
if !ok {
|
||||
cs.addError(t.Pos(), fmt.Sprintf("length of array must be an integer"))
|
||||
cs.addError(t.Pos(), "length of array must be an integer")
|
||||
return shaderir.Type{}, false
|
||||
}
|
||||
length = int(l)
|
||||
@ -89,7 +89,7 @@ func (cs *compileState) parseType(block *block, fname string, expr ast.Expr) (sh
|
||||
return shaderir.Type{}, false
|
||||
}
|
||||
if elm.Main == shaderir.Array {
|
||||
cs.addError(t.Pos(), fmt.Sprintf("array of array is forbidden"))
|
||||
cs.addError(t.Pos(), "array of array is forbidden")
|
||||
return shaderir.Type{}, false
|
||||
}
|
||||
return shaderir.Type{
|
||||
|
Loading…
Reference in New Issue
Block a user