mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-12 20:18:59 +01:00
shader: Bug fix: Some oeprators should be evaluated as bool
This commit is contained in:
parent
fb63df48ae
commit
f3651e23e4
@ -91,8 +91,16 @@ func (cs *compileState) parseExpr(block *block, expr ast.Expr) ([]shaderir.Expr,
|
||||
}, []shaderir.Type{t}, stmts, true
|
||||
}
|
||||
|
||||
op, ok := shaderir.OpFromToken(e.Op)
|
||||
if !ok {
|
||||
cs.addError(e.Pos(), fmt.Sprintf("unexpected operator: %s", e.Op))
|
||||
return nil, nil, nil, false
|
||||
}
|
||||
|
||||
var t shaderir.Type
|
||||
switch {
|
||||
case op == shaderir.LessThanOp || op == shaderir.LessThanEqualOp || op == shaderir.GreaterThanOp || op == shaderir.GreaterThanEqualOp || op == shaderir.EqualOp || op == shaderir.NotEqualOp || op == shaderir.AndAnd || op == shaderir.OrOr:
|
||||
t = shaderir.Type{Main: shaderir.Bool}
|
||||
case lhst.Equal(&rhst):
|
||||
t = lhst
|
||||
case lhst.Main == shaderir.Float || lhst.Main == shaderir.Int:
|
||||
@ -129,12 +137,6 @@ func (cs *compileState) parseExpr(block *block, expr ast.Expr) ([]shaderir.Expr,
|
||||
return nil, nil, nil, false
|
||||
}
|
||||
|
||||
op, ok := shaderir.OpFromToken(e.Op)
|
||||
if !ok {
|
||||
cs.addError(e.Pos(), fmt.Sprintf("unexpected operator: %s", e.Op))
|
||||
return nil, nil, nil, false
|
||||
}
|
||||
|
||||
return []shaderir.Expr{
|
||||
{
|
||||
Type: shaderir.Binary,
|
||||
|
Loading…
Reference in New Issue
Block a user