Madness Script 2.0.0

I know I know! I said I was putting down the Madness Script Project but since then I started using it for the Ascension Project. So I got some pretty new and fine toys and various bugs fixed. I will need to remake the entire documentation for the project both in the code and here on this website. At the bottom of this post you can also read all the changes that was made to the mSCRiPT language.

Here’s the source and interpeter: mSCRiPT-2.0.0


So first I’ll show the new organization of the standard library.I kept my original promise of making every class in the standard library to be a dynamic class and inheritable. Well I almost kept that promise, some of the classes I haven’t made dynamic as I see it as a potential easy way to make everything crash and burn. Thanks to sticking to this dynamic choice I could re-arrange entirely how you access classes in the standard library. I have introduced the concept of Modules in the language. A Module is basically a DynamicClass who have removed the ability to have instances of itself. So it basically works like a namespace in C++. What I’ve done is that the entire standard library has been placed in a Module which is stored as a global variable under the symbol Standard. And all the classes you could use before trough the Kernel.New* methods can now be accessed trough this module but like how you should be able to access a class.

Here’s a short example of what I mean:

myArray = Standard.Array.New
myLoop = Standard.Loop.New
MyClass = Standard.Class.New("MyClass")
// etc...

Here you also see more clearly that the standard classes have been turned into DynamicClasses now instead. Even the DynamicClass is accessed this way. Some things though have been turned into Modules themselves instead, like the Kernel and the helper classes are some good examples. You can add new methods to these by just calling the Module.NewMethod method. The Modules have their parents new/delete methods removed and only have now NewMethod and DeleteMethod but they work exactly like the *ClassMethod methods. But more on that later.

Also another change of organization but that is more close to the source are that of the Kernel. I’ve moved all the static class variables to the kernel instead so you can create a new interpreter environment by just creating a new kernel instance. So you can have two different interpreters in one application that do not affect each others at all. Though this change meant that each object keep track of it’s kernel and the appropriate kernel have to be activated before creating a new object but this is nothing you have to worry about unless you are developing your own source classes to the language or a plugin.


Well there’s a lot to document on this new version since nearly everything has been changed. I will have to remake the mSCRiPT tutorial. Though I will probably try and write so that the comments in the source are Doxygen compatible so that I can generate a developers documentation for it. Would help myself a lot too!

Garbage Collector

Aight for this version I implemented the Hans Boehm Garbage Collector for the language and some small simple tests told me that it worked… For Windows. Well I have a problem to get it running on Linux for some reason. The GC library worked perfectly with any other small app without the error message but when I tried to just allocated memory trough new for a ScriptObject, the collector aborted runtime with the error message that some stack value is absurd or something. Don’t know what’s wrong, probing the net gave nothing so, if anyone get it’s working please tell me.

Code Example

Here comes the new code example for this version.


Person = Standard.Class.Inherit("Person")

methodInit = Person.NewInstanceMethod("@Init", "n")
methodInit < self.@AddInstanceVariable("name", n)

methodSay = Person.NewInstanceMethod("Say", "(Text)words")
methodSay < Standard.Kernel.PrintLine(name, " says \"", words, "\"")
methodSay < self

john = Person.New("John Doe")
max = Person.New("Max Anderson")
albert = Person.New("Albert Wester")

conversation = Text.New("Hi!Hello John!Good day Mr. Doe")
john.Say(conversation.SubStr(0, 3))
max.Say(conversation.SubStr(3, 11))
albert.Say(conversation.SubStr(14, 16))


 - Changed the garbage collection system.
   - Now uses the Hans Boehm GC library.
 - Added the Module class which acts as namespaces in C++.
   - Modules are dynamic classes which have the New method removed.
   - Modules also have the AddInstanceMethod and RemoveInstanceMethod removed.
   - The AddClassMethod and RemoveClassMethod has been renamed to AddMethod and RemoveMethod.
   - Any variable starting with a capital letter(A-Z) will be accessable trough a method with the same symbol.
 - Changed how DynamicClass and DynamicObject work together.
   - DynamicClass now have a pointer to it's parent DynamicClass.
   - DynamicObject now don't hold any reference to any dynamic instance method but do a lookup in the class.
   - Added support for the object to define methods to handle Syntax and Runtime exceptions.
 - Added support for ScriptObject to handle a call to an undefined symbol for the instance.
   - To use this in DynamicObject and DynamicClass just override "OnMissingMethod"
   - Module uses this method to make variables starting with capital letter accessible trough a method dynamicly.
 - Remade the entire heirarchy of the standard library.
   - Everything is placed in the Standard module.
   - Most of the Standard classes now inherit from DynamicClass or Module.
   - Now no variables are saved staticly but have been moved to Kernel. So if you create a new instance of Kernel
     you get a new interpeter. Though you have to activate which Kernel you are using currently. Not made tread safe either!
 - Changed PluginManager so that it also passes along a pointer to the managers kernel so that the requesting
   interpeter is accessible in the plugin.
 - Lot's of more and various bugs that appeared as I worked with the code are fixed.

No Comments »

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress. Theme: TheBuckmaker