@TheComet
Quote: "Pre-compiling DBP code is (in my opinion) going to be not far from completely useless. The only case where it might be worth doing is if the programmer is retarded. In such a case, front-end code (the code being passed to the DBP compiler) could be made more optimized.
"
Yeah.. was expecting that reaction
Quote: "Have you seen the abomination of assembly output of a DBP executable?"
That's actually why it's necessary. The DBpro compiler simply spits out every simple operation in your program, even when they're completely redundant.
ie.
#constant SomeValue 10
A = SomeValue * 5
produces,
4 MOV EAX IMM4 , 10
4 MOV EBX IMM4 , 5
4 IMUL EAX EBX4
4 MOV MEM4 EAX @$L0 ; MUL
4 MOV EAX MEM4 @$L0
4 MOV MEM4 EAX @A ; ASSIGN X TO X
4 MOV MEM IMM4 @$_SLN_, 4
4 MOV EAX MEM4 @$_ERR_
4 CMP EAX4 0
4 JNE $labelend ; CALL Normal Runtime Error Hook
Normally the optimizer would catch / precompute such calculations so they never make to the code generation stage, but not here.
If we did, we get,
becomes,
2 MOV EAX IMM4 , 50
2 MOV MEM4 EAX @A ; ASSIGN X TO X
2 MOV MEM IMM4 @$_SLN_, 2
2 MOV EAX MEM4 @$_ERR_
2 CMP EAX4 0
2 JNE $labelend ; CALL Normal Runtime Error Hook
I know, I know.. how useless.. But redundancies don't just occur in constant expressions, BASIC programs are full of them. Take this solution for drawing a grid.
height=10
width = 10
TileSize=32
for ylp=0 to height-1
For xlp=0 to width-1
R=rnd(255)
G=rnd(255)
B=rnd(255)
box xlp*TileSize, Ylp*TileSize, (xlp*TileSize)+TileSize, (Ylp*TileSize)+TileSize, Rgb(R,G,B),0,0,Rgb(R,G,B)
next
next
sync
wait key
there's at least 3 operations on the BOX line that are dead weight.
Xpos=xlp*TileSize
Ypos=ylp*TileSize
Col= Rgb(R,G,B)
box Xpos, Ypos, Xpos+TileSize, Ypos+TileSize, col,0,0,col
This is really what the solver does, it tries to only compute values when they're needed. Not just within a single expression, but across the current scope.
@Chris,
Quote: "
Anything from catching typos before compilation and boosting the compilation speed is most certainly beneficial
"
Now... I haven't tied this targeting DBPRO, but would be surprised if the end compilation speed from the Dbpro, was dramatically quicker. Obviously, if pre-processor was able to strip a lot of material from the input sources. Say, like toggling a debug modes, or switching off the intro/menus or whatever.. Then i'd expect a quicker built time from Dbpro.
ie.
// #Define IntroMode = 0
// #IF IntroMode = 1
#include "Intro.dba"
// #Endif
#include "Game.dba"
So post processing the source, the output that goes to Dbpro would be,
The function limit thing sounds an awful lot like the
variable limits (Test Dark Basic Compilers Variable Limits ) etc, people were hitting in DB classic back in the day. Can think of way to get around it, but it's not pretty.