mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-13 12:32:05 +01:00
shader: Refactoring
This commit is contained in:
parent
2c1e71931e
commit
bee79e3b67
@ -259,7 +259,6 @@ func (cs *compileState) parseDecl(b *block, d ast.Decl) {
|
|||||||
}
|
}
|
||||||
for i, v := range vs {
|
for i, v := range vs {
|
||||||
b.vars = append(b.vars, v)
|
b.vars = append(b.vars, v)
|
||||||
b.ir.LocalVars = append(b.ir.LocalVars, v.typ)
|
|
||||||
if inits[i] != nil {
|
if inits[i] != nil {
|
||||||
b.ir.Stmts = append(b.ir.Stmts, shaderir.Stmt{
|
b.ir.Stmts = append(b.ir.Stmts, shaderir.Stmt{
|
||||||
Type: shaderir.Assign,
|
Type: shaderir.Assign,
|
||||||
@ -504,6 +503,11 @@ func (cs *compileState) parseBlock(outer *block, b *ast.BlockStmt, inParams, out
|
|||||||
vars: vars,
|
vars: vars,
|
||||||
outer: outer,
|
outer: outer,
|
||||||
}
|
}
|
||||||
|
defer func() {
|
||||||
|
for _, v := range block.vars[len(inParams)+len(outParams):] {
|
||||||
|
block.ir.LocalVars = append(block.ir.LocalVars, v.typ)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
for _, l := range b.List {
|
for _, l := range b.List {
|
||||||
switch l := l.(type) {
|
switch l := l.(type) {
|
||||||
@ -520,7 +524,6 @@ func (cs *compileState) parseBlock(outer *block, b *ast.BlockStmt, inParams, out
|
|||||||
}
|
}
|
||||||
v.typ = ts[0]
|
v.typ = ts[0]
|
||||||
block.vars = append(block.vars, v)
|
block.vars = append(block.vars, v)
|
||||||
block.ir.LocalVars = append(block.ir.LocalVars, v.typ)
|
|
||||||
|
|
||||||
// Prase RHS first for the order of the statements.
|
// Prase RHS first for the order of the statements.
|
||||||
rhs, stmts := cs.parseExpr(block, l.Rhs[i])
|
rhs, stmts := cs.parseExpr(block, l.Rhs[i])
|
||||||
@ -708,7 +711,6 @@ func (cs *compileState) parseExpr(block *block, expr ast.Expr) (shaderir.Expr, [
|
|||||||
block.vars = append(block.vars, variable{
|
block.vars = append(block.vars, variable{
|
||||||
typ: p,
|
typ: p,
|
||||||
})
|
})
|
||||||
block.ir.LocalVars = append(block.ir.LocalVars, p)
|
|
||||||
args = append(args, shaderir.Expr{
|
args = append(args, shaderir.Expr{
|
||||||
Type: shaderir.LocalVariable,
|
Type: shaderir.LocalVariable,
|
||||||
Index: idx,
|
Index: idx,
|
||||||
|
Loading…
Reference in New Issue
Block a user