mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-26 03:38:55 +01:00
parent
f3651e23e4
commit
ce4732a7dc
@ -111,7 +111,22 @@ func (cs *compileState) parseStmt(block *block, stmt ast.Stmt, inParams []variab
|
||||
return nil, false
|
||||
}
|
||||
case *ast.IfStmt:
|
||||
// TODO: Parse stmt.Init
|
||||
if stmt.Init != nil {
|
||||
init := stmt.Init
|
||||
stmt.Init = nil
|
||||
b, ok := cs.parseBlock(block, []ast.Stmt{init, stmt}, nil, nil)
|
||||
if !ok {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
stmts = append(stmts, shaderir.Stmt{
|
||||
Type: shaderir.BlockStmt,
|
||||
Blocks: []shaderir.Block{
|
||||
b.ir,
|
||||
},
|
||||
})
|
||||
return stmts, true
|
||||
}
|
||||
|
||||
exprs, ts, ss, ok := cs.parseExpr(block, stmt.Cond)
|
||||
if !ok {
|
||||
|
14
internal/shader/testdata/if_init.expected.vs
vendored
Normal file
14
internal/shader/testdata/if_init.expected.vs
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
void F0(out vec2 l0) {
|
||||
vec2 l1 = vec2(0);
|
||||
l1 = vec2(0.0);
|
||||
{
|
||||
vec2 l2 = vec2(0);
|
||||
l2 = vec2(1.0);
|
||||
if (((l2).x) == (1.0)) {
|
||||
l0 = l2;
|
||||
return;
|
||||
}
|
||||
}
|
||||
l0 = l1;
|
||||
return;
|
||||
}
|
9
internal/shader/testdata/if_init.go
vendored
Normal file
9
internal/shader/testdata/if_init.go
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
package main
|
||||
|
||||
func Foo() vec2 {
|
||||
v := vec2(0)
|
||||
if v := vec2(1); v.x == 1 {
|
||||
return v
|
||||
}
|
||||
return v
|
||||
}
|
Loading…
Reference in New Issue
Block a user