mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 02:38:53 +01:00
shaderir: Add Return
This commit is contained in:
parent
d932787e36
commit
32a88b3b03
@ -132,6 +132,7 @@ func (p *Program) glslBlock(b *Block, f *Func, level int) []string {
|
||||
case Binary:
|
||||
return fmt.Sprintf("(%s) %s (%s)", glslExpr(&e.Exprs[0]), e.Op, glslExpr(&e.Exprs[1]))
|
||||
case Call:
|
||||
// TODO: Take multiple args
|
||||
return fmt.Sprintf("(%s).(%s)", glslExpr(&e.Exprs[0]), glslExpr(&e.Exprs[1]))
|
||||
case Selector:
|
||||
return fmt.Sprintf("(%s).%s", glslExpr(&e.Exprs[0]), glslExpr(&e.Exprs[1]))
|
||||
@ -145,7 +146,7 @@ func (p *Program) glslBlock(b *Block, f *Func, level int) []string {
|
||||
for _, s := range b.Stmts {
|
||||
switch s.Type {
|
||||
case ExprStmt:
|
||||
panic("not implemented")
|
||||
lines = append(lines, fmt.Sprintf("%s%s;", idt, glslExpr(&s.Exprs[0])))
|
||||
case BlockStmt:
|
||||
lines = append(lines, idt+"{")
|
||||
lines = append(lines, p.glslBlock(s.Block, f, level+1)...)
|
||||
@ -160,6 +161,8 @@ func (p *Program) glslBlock(b *Block, f *Func, level int) []string {
|
||||
lines = append(lines, idt+"continue;")
|
||||
case Break:
|
||||
lines = append(lines, idt+"break;")
|
||||
case Return:
|
||||
lines = append(lines, idt+"return;")
|
||||
case Discard:
|
||||
lines = append(lines, idt+"discard;")
|
||||
default:
|
||||
@ -169,3 +172,5 @@ func (p *Program) glslBlock(b *Block, f *Func, level int) []string {
|
||||
|
||||
return lines
|
||||
}
|
||||
|
||||
// TODO: Distinguish regular functions, vertex functions and fragment functions. e.g., Treat gl_Position correctly.
|
||||
|
@ -64,6 +64,7 @@ const (
|
||||
For
|
||||
Continue
|
||||
Break
|
||||
Return
|
||||
Discard
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user