mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-13 12:32:05 +01:00
internal/shader: refactoring
This commit is contained in:
parent
73e4423fe7
commit
5e30e1ee1d
@ -155,16 +155,6 @@ func (cs *compileState) parseExpr(block *block, fname string, expr ast.Expr, mar
|
||||
if lhst.Main != shaderir.None || rhst.Main != shaderir.None {
|
||||
t = shaderir.Type{Main: shaderir.Bool}
|
||||
}
|
||||
case token.AND, token.OR, token.XOR, token.AND_NOT:
|
||||
if lhs[0].Const.Kind() != gconstant.Int {
|
||||
cs.addError(e.Pos(), fmt.Sprintf("operator %s not defined on %s (%s)", op, lhs[0].Const.String(), lhst.String()))
|
||||
return nil, nil, nil, false
|
||||
}
|
||||
if rhs[0].Const.Kind() != gconstant.Int {
|
||||
cs.addError(e.Pos(), fmt.Sprintf("operator %s not defined on %s (%s)", op, rhs[0].Const.String(), rhst.String()))
|
||||
return nil, nil, nil, false
|
||||
}
|
||||
fallthrough
|
||||
default:
|
||||
v = gconstant.BinaryOp(lhs[0].Const, op, rhs[0].Const)
|
||||
switch {
|
||||
|
@ -84,6 +84,11 @@ func AreValidTypesForBinaryOp(op Op, lhs, rhs *Expr, lhst, rhst Type) bool {
|
||||
if op == ModOp {
|
||||
return lhs.Const.Kind() == constant.Int && rhs.Const.Kind() == constant.Int
|
||||
}
|
||||
|
||||
if op == And || op == Or || op == Xor {
|
||||
return lhs.Const.Kind() == constant.Int && rhs.Const.Kind() == constant.Int
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user