Le 09/04/2013 21:49, Malek a �crit :
> Hey guys,
>
>
> When you develop with Haxe many of you are likely to be using
> FlashDevelop as an IDE, because it's the one that integrates Haxe best
> as of today.
>
> I was wondering, how do you do live debugging ?
I had a thought for it some months ago and here's what I came up :
- use JS output (or Neko) which are both dynamic enough to allow runtime
prototype changes.
- when you want to update the code, go through all the classes and mute
the prototype with the new version
For instance that would be the following JS code :
var MyClass = MyClass || function(args) { /* constructor_code */ };
MyClass.prototype.myMethod = function() {
/* method code */
}
This way everytime you recompile + reload the JS all the method code
gets updated.
Some things can be improved in order to deal with new variables :
- you can create some additional code that will store all instances
created (as weakmap keys for instance) and when you update the code,
will run some parts of the class constructor an all instances in order
to define default values for new member variables
So for instance if you have the following constructor :
function new() {
this.x = 0;
this.y = 1;
this.name = "Test";
doSomethingElse();
}
You will generate the following method :
function MyClass_fix(inst) {
if( typeof(inst.x) == "undefined" ) inst.x = 0;
if( typeof(inst.y) == "undefined" ) inst.y = 1;
if( typeof(
inst.name) == "undefined" )
inst.name = "Test";
}
And apply it on all live instances of the class after rebinding the
prototypes.
That should work quite well and does not require many changes in the
Haxe compiler.
Best,
Nicolas