mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
shader: Bug fix: true/false should be available as a local variable
This commit is contained in:
parent
a5af597594
commit
e543d4f107
@ -369,14 +369,6 @@ func (cs *compileState) parseExpr(block *block, expr ast.Expr) ([]shaderir.Expr,
|
|||||||
return exprs, f.ir.OutParams, stmts, true
|
return exprs, f.ir.OutParams, stmts, true
|
||||||
|
|
||||||
case *ast.Ident:
|
case *ast.Ident:
|
||||||
if e.Name == "true" || e.Name == "false" {
|
|
||||||
return []shaderir.Expr{
|
|
||||||
{
|
|
||||||
Type: shaderir.NumberExpr,
|
|
||||||
Const: gconstant.MakeBool(e.Name == "true"),
|
|
||||||
},
|
|
||||||
}, []shaderir.Type{{Main: shaderir.Bool}}, nil, true
|
|
||||||
}
|
|
||||||
if e.Name == "_" {
|
if e.Name == "_" {
|
||||||
return []shaderir.Expr{
|
return []shaderir.Expr{
|
||||||
{
|
{
|
||||||
@ -425,6 +417,14 @@ func (cs *compileState) parseExpr(block *block, expr ast.Expr) ([]shaderir.Expr,
|
|||||||
},
|
},
|
||||||
}, nil, nil, true
|
}, nil, nil, true
|
||||||
}
|
}
|
||||||
|
if e.Name == "true" || e.Name == "false" {
|
||||||
|
return []shaderir.Expr{
|
||||||
|
{
|
||||||
|
Type: shaderir.NumberExpr,
|
||||||
|
Const: gconstant.MakeBool(e.Name == "true"),
|
||||||
|
},
|
||||||
|
}, []shaderir.Type{{Main: shaderir.Bool}}, nil, true
|
||||||
|
}
|
||||||
cs.addError(e.Pos(), fmt.Sprintf("unexpected identifier: %s", e.Name))
|
cs.addError(e.Pos(), fmt.Sprintf("unexpected identifier: %s", e.Name))
|
||||||
|
|
||||||
case *ast.ParenExpr:
|
case *ast.ParenExpr:
|
||||||
|
@ -506,3 +506,15 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
|||||||
t.Errorf("error must be non-nil but was nil")
|
t.Errorf("error must be non-nil but was nil")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestShaderBoolLiteral(t *testing.T) {
|
||||||
|
if _, err := NewShader([]byte(`package main
|
||||||
|
|
||||||
|
func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
||||||
|
true := vec4(0)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
`)); err != nil {
|
||||||
|
t.Errorf("error must be nil but was non-nil")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user