Latest worklog

BlitzMax Forums/Brucey's Modules/Latest worklog

simonh(Posted 2008) [#1]
An intriguing worklog post, Brucey. If you're taking it on, then you're a brave man - I've written a source code converter before and well, they can be a huge pain in the ass. Which language do you plan to convert to?


Brucey(Posted 2008) [#2]
Heh... I'm building it "open", so that one could in theory, create a new code-gen plugin, but I'm currently focussing on C++, since it's vaguely syntactically similar to BlitzMax. And then perhaps Obj/C :-)

Come to think of it, Java is also similar to C++ ...

Rather than have to write lots of tests... I've written a small Unit Test Suite, which runs the engine against lots of source files. 2 Files per test. 1 is bmx, other is cpp. If the generated cpp matches my hand-coded cpp, then it passes.
The nice thing about this is I can pre-write lots of examples, and as time goes on, the tests stop failing and begin to pass.


simonh(Posted 2008) [#3]
Very cool. There is one obvious difference between C++ and BlitzMax though - the memory management! How the heck do you plan to convert BM's GC?

Good luck with it though, if you pull if off it would be an amazingly handy tool!


Brucey(Posted 2008) [#4]
How the heck do you plan to convert BM's GC?

yeah... I had initially mentioned that, but didn't think it was very interesting :-)

I've been working on some self-GC'ing classes, using those smart pointer thingies, and it seems to work quite well. Code looks a bit messy with all those Template angle-brackets, but since it's generated I'm not too fussed.


Brucey(Posted 2008) [#5]
Obj/C on the otherhand can manage itself with AutoRelease and whatnot... which is nice.

Not sure how I'm going to hack the fact that I can call BBRETAIN in my glue code when I want to drop a BlitzMax object into a foreign container... ack.

Oh well :-)


slenkar(Posted 2008) [#6]
it sounds like a good project,

could it handle collision ,drawing images, and those builtin blitzmax commands?


Brucey(Posted 2008) [#7]
could it handle collision ,drawing images, and those builtin blitzmax commands?

No idea. The main issue with the built-in stuff is the lack of SuperStrict - ie. laziness ;-)

On a brighter note, I've just got it generating good C++ for this snippet :
Type TMyType

	Field count:Int

	Function Create:TMyType()
		Local this:TMyType = New TMyType
		this.count = 0
		Return this
	End Function

	Method DoSomething:Int(param:Int)
		count:+ param
		Return count
	End Method
	
End Type

Although I've just realised I've made some assumptions which turned out to be a problem... ho hum :-)