shader: Remove variable.init

This commit is contained in:
Hajime Hoshi 2020-06-07 05:20:04 +09:00
parent 147c82f212
commit e14cd559b6

View File

@ -27,7 +27,6 @@ import (
type variable struct { type variable struct {
name string name string
typ typ typ typ
init shaderir.Expr
} }
type constant struct { type constant struct {
@ -255,10 +254,11 @@ func (s *compileState) parseVariable(block *block, vs *ast.ValueSpec) []variable
if init != nil { if init != nil {
e = s.parseExpr(block, init) e = s.parseExpr(block, init)
} }
// TODO: Add an assign statement for e.
_ = e
vars = append(vars, variable{ vars = append(vars, variable{
name: name, name: name,
typ: t, typ: t,
init: e,
}) })
} }
return vars return vars
@ -430,14 +430,13 @@ func (cs *compileState) parseBlock(outer *block, b *ast.BlockStmt, inParams, out
name: e.(*ast.Ident).Name, name: e.(*ast.Ident).Name,
} }
v.typ = cs.detectType(block, l.Rhs[i]) v.typ = cs.detectType(block, l.Rhs[i])
v.init = cs.parseExpr(block, l.Rhs[i])
block.vars = append(block.vars, v) block.vars = append(block.vars, v)
block.ir.LocalVars = append(block.ir.LocalVars, v.typ.ir) block.ir.LocalVars = append(block.ir.LocalVars, v.typ.ir)
block.ir.Stmts = append(block.ir.Stmts, shaderir.Stmt{ block.ir.Stmts = append(block.ir.Stmts, shaderir.Stmt{
Type: shaderir.Assign, Type: shaderir.Assign,
Exprs: []shaderir.Expr{ Exprs: []shaderir.Expr{
cs.parseExpr(block, l.Lhs[i]), cs.parseExpr(block, l.Lhs[i]),
v.init, cs.parseExpr(block, l.Rhs[i]),
}, },
}) })
} }