MicroC module - runtime error line

BlitzMax Forums/BlitzMax Programming/MicroC module - runtime error line

Blueapples(Posted 2008) [#1]
Is there a way to get the line number that causes a runtime error from the binphx.microc module?

I'm getting this error "You cannot divide a string" and I have no idea where in my 80 line script it's coming from. Anyone figured out a way to do this?


Blueapples(Posted 2008) [#2]
Two things. This script is actually about 400 lines. I was looking at the INI file for it somehow.

And I got it to work. Just added a Field to Type TScriptInstr to contain the Line that cause the instruction to be added, set this in AddInstr, and added it to the binary dump format. This makes the binary format quite a bit bigger, so it's only added if a switch DebugOn is true.

If anyone's using MicroC and would find this useful let me know. Too bad it isn't in a google code or sourceforge project or I could just apply for membership and check in my fixes.


Helios(Posted 2008) [#3]
Seems you've fixed it yourself. However if you are actually intrested in this module, give me a few days and I'll rewrite it. I have some free time at the moment and its in bad need of it ;).


Blueapples(Posted 2008) [#4]
I am actually really interested in the module, I think it's pretty fantastic. If you have the time to rework it I would be very appreciative. As it stands it's meeting my needs but a new version would be welcome - I don't think there can be too many scripting languages for BlitzMax.


Helios(Posted 2008) [#5]
Alrighty. Well I rewrote a bunch of it today, in a couple of days I should be able to post a new version.


Helios(Posted 2008) [#6]
Well here you go, have fun with it. Its been entirely rewritten from scratch over the last few days. Works pretty well and is a lot cleaner than the first version.

Bunch of new feature now as well, including a runtime library containing common functions (data structures, math, .etc), eachin support, .etc.

The only real differences you may see, is that quite a few of the names of functions have changed, some types have been made static (you don't need to create TCompiler or TVirtualMachine instances any more, you just use the functions contained in them), and arrays have also been removed in preference to other data structures (lists, hashs, .etc). It overcomplicated the compiler code and had little benefit compared to other choices.

Anyhow, download here;
http://www.binaryphoenix.com/index.php?action=download&id=91

If you find any bugs, make sure to send me an email. There are probably quite a few in the first release.


Blueapples(Posted 2008) [#7]
Sweet! I'll take a look at it today.

One thing I wanted to mention before but I forgot to say was it would be really handy if command set functions could support object parameters and return values directly. I've had to resort to using Handles with all the obvious problems that will create as far as memory leaks go, etc. (script authors have to remember to call Release() all the time). And of course I see "GetParameterObject:Object(index:Int)", so you thought of the same thing. Awesome!

I've also got a command set generator that whips through a file and finds any lines that end in {Export} and creates a new command set class. Basically it looks at the function definition, then generates the calls needed to pop arguments off the stack, calls the real function, then push the return value of the real function on to the stack. Pretty handy since all you have to do is write regular BM functions, put ' {Export} at the end of the line for each function, then call csgen and it spits out the glue so the functions can be called in MC.

You can integrate this into the release if you like. It looks like the new version doesn't have TVMCommandSet anymore, but that's no big deal since the class hardly did anything, just called the VM's RegisterFunction method.

csgen source: http://blueapples.org/twiki/pub/Main/BlitzMax/csgen.bmx


Helios(Posted 2008) [#8]
"And of course I see "GetParameterObject:Object(index:Int)", so you thought of the same thing. Awesome!"
- Yes not sure why I didn't include that in the first one.

"You can integrate this into the release if you like. It looks like the new version doesn't have TVMCommandSet anymore, but that's no big deal since the class hardly did anything, just called the VM's RegisterFunction method."
- What I really want to do is what I normally do when I design scripting languages, which is use reflection to register all functions within a class to the VM. Unfortunatly as far as I can see BMax can't get reflected details on static functions. Bit of a shame really :S.

Personally I think the best thing about this release, is the inclusion of type balancing, which caused some pretty odd errors in the first version (for instance int+string = int, when it should really be a string result).

I'm also considering to make this languaged typed rather than type-less, theres really only so many speed improvements you can make in a type-less language. I can usually make far faster VM's for typed languages.

I also wonder if I should post a topic about this module, or leave it in this one.

Anyhow should stop rambling now, I'll have a look at csgen. And if you have any suggestions on what else to put into the language I'll be happy to hear them :D.

Also do you think I should release the other language I made with this? I made two compilers for the VM, one with a basic syntax the other with this C syntax.


Blueapples(Posted 2008) [#9]
A basic syntax would be pretty nice, always good provide multiple options.

What do you think about supporting objects and method calls? That gets into a whole messy world. In my own scripting language I haven't even really looked at it - procedural APIs like what MaxGUI has work pretty well for scripting. Just wanted to see what you think about the topic if you've considered it for MicroC.


Helios(Posted 2008) [#10]
I've written a couple of OOP style scripting languages before, but to be honest I always felt it bloated the language a lot and generally was not of that much use in a scripting language.


Blueapples(Posted 2008) [#11]
Sent you a couple bug reports, but looking pretty good


Helios(Posted 2008) [#12]
Fixed the first one, the second one is because singe-quote chracters are not supported for defining strings. I'll probably readadd this now though.

If you want to add support before I release the next version, just open the Lexer.bmx file and find the line;

			Case "~q"


and change it to;

			Case "~q", "'"



Blueapples(Posted 2008) [#13]
Man this is going to be so cool. I've been spamming Helios about bugs and stuff. If you're at all into scripting languages, you guys have got to download this and play with it once the new build is up. Esp with the BASIC syntax to compare/contrast with the C/javascript style syntax.


Helios(Posted 2008) [#14]
New version (goter sort out a version numbering system for this >.>);
http://www.binaryphoenix.com/index.php?action=download&id=92

Tons of bugs have been fixed, and a few new features have been added (among which is a new compiler which uses a BASIC syntax). Theres also a new command-line compiler tool (called MCC), that can now generate glue-code from blitzmax source files, to make it even easier to export functions to MicroC.

I really should get around to writing a read-me.

I should probably post a proper topic for this as well.


Helios(Posted 2008) [#15]
http://www.blitzbasic.com/Community/posts.php?topic=77298

There is a topic there if you wish to continue this ;).