mirror of
https://github.com/irmen/prog8.git
synced 2024-12-24 01:29:28 +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) {
|
||||
// replace source+firstsegment by firstsegment(source) call as the new source
|
||||
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))
|
||||
}
|
||||
}
|
||||
|
@ -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() {
|
||||
; mcCarthy()
|
||||
|
||||
; 9+10+42 = 61
|
||||
; 200-61-2 = 137
|
||||
ubyte result = 9 |> func1(10) |> func2(2)
|
||||
txt.print_ub(result)
|
||||
txt.nl()
|
||||
|
||||
; a "pixelshader":
|
||||
sys.gfx_enable(0) ; enable lo res screen
|
||||
ubyte shifter
|
||||
|
||||
repeat {
|
||||
uword xx
|
||||
uword yy = 0
|
||||
repeat 240 {
|
||||
xx = 0
|
||||
repeat 320 {
|
||||
sys.gfx_plot(xx, yy, xx*yy + shifter as ubyte)
|
||||
xx++
|
||||
}
|
||||
yy++
|
||||
}
|
||||
shifter+=4
|
||||
}
|
||||
; sys.gfx_enable(0) ; enable lo res screen
|
||||
; ubyte shifter
|
||||
;
|
||||
; repeat {
|
||||
; uword xx
|
||||
; uword yy = 0
|
||||
; repeat 240 {
|
||||
; xx = 0
|
||||
; repeat 320 {
|
||||
; sys.gfx_plot(xx, yy, xx*yy + shifter as ubyte)
|
||||
; xx++
|
||||
; }
|
||||
; yy++
|
||||
; }
|
||||
; shifter+=4
|
||||
; }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user