mirror of
https://github.com/irmen/prog8.git
synced 2024-09-10 09:54:32 +00:00
fix pipe expression when start term is constant number
This commit is contained in:
parent
c6e92ecac4
commit
dca092fd7c
@ -348,7 +348,8 @@ class ExpressionSimplifier(private val program: Program) : AstWalker() {
|
|||||||
} else if(segments.size>1) {
|
} else if(segments.size>1) {
|
||||||
// replace source+firstsegment by firstsegment(source) call as the new source
|
// replace source+firstsegment by firstsegment(source) call as the new source
|
||||||
val firstSegment = segments.removeAt(0) as IFunctionCall
|
val firstSegment = segments.removeAt(0) as IFunctionCall
|
||||||
val call = FunctionCallExpression(firstSegment.target, mutableListOf(pipe.source), pipe.position)
|
val newArgs = listOf(pipe.source) + firstSegment.args
|
||||||
|
val call = FunctionCallExpression(firstSegment.target, newArgs.toMutableList(), pipe.position)
|
||||||
return listOf(IAstModification.ReplaceNode(pipe.source, call, pipe as Node))
|
return listOf(IAstModification.ReplaceNode(pipe.source, call, pipe as Node))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,26 +29,39 @@ main {
|
|||||||
; }
|
; }
|
||||||
|
|
||||||
|
|
||||||
|
sub func1(ubyte a1, ubyte a2) -> ubyte {
|
||||||
|
return a1+a2+42
|
||||||
|
}
|
||||||
|
|
||||||
|
sub func2(ubyte a1, ubyte a2) -> ubyte {
|
||||||
|
return 200-a1-a2
|
||||||
|
}
|
||||||
|
|
||||||
sub start() {
|
sub start() {
|
||||||
; mcCarthy()
|
; mcCarthy()
|
||||||
|
|
||||||
|
; 9+10+42 = 61
|
||||||
|
; 200-61-2 = 137
|
||||||
|
ubyte result = 9 |> func1(10) |> func2(2)
|
||||||
|
txt.print_ub(result)
|
||||||
|
txt.nl()
|
||||||
|
|
||||||
; a "pixelshader":
|
; a "pixelshader":
|
||||||
sys.gfx_enable(0) ; enable lo res screen
|
; sys.gfx_enable(0) ; enable lo res screen
|
||||||
ubyte shifter
|
; ubyte shifter
|
||||||
|
;
|
||||||
repeat {
|
; repeat {
|
||||||
uword xx
|
; uword xx
|
||||||
uword yy = 0
|
; uword yy = 0
|
||||||
repeat 240 {
|
; repeat 240 {
|
||||||
xx = 0
|
; xx = 0
|
||||||
repeat 320 {
|
; repeat 320 {
|
||||||
sys.gfx_plot(xx, yy, xx*yy + shifter as ubyte)
|
; sys.gfx_plot(xx, yy, xx*yy + shifter as ubyte)
|
||||||
xx++
|
; xx++
|
||||||
}
|
; }
|
||||||
yy++
|
; yy++
|
||||||
}
|
; }
|
||||||
shifter+=4
|
; shifter+=4
|
||||||
}
|
; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user