Created
August 7, 2014 17:57
-
-
Save mykmelez/c5dad14ff4e6a7e80149 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+Native["com/sun/cldc/isolate/Isolate.waitStatus.(I)V"] = function(ctx, stack) { | |
+ var maxStatus = stack.pop(), _this = stack.pop(); | |
+ if (_this.status < maxStatus) { | |
+ _this.waitStatusFunc = function() { | |
+ if (_this.status >= maxStatus) { | |
+ delete _this.waitStatusFunc; | |
+ ctx.resume(); | |
+ } | |
+ }; | |
+ throw VM.Pause; | |
+ } | |
+} | |
+ | |
Native["com/sun/cldc/isolate/Isolate.nativeStart.()V"] = function(ctx, stack) { | |
var _this = stack.pop(); | |
var mainClass = util.fromJavaString(_this.class.getField("_mainClass", "Ljava/lang/String;", false).get(_this)); | |
var mainArgs = _this.class.getField("_mainArgs", "[Ljava/lang/String;", false).get(_this); | |
mainArgs.forEach(function(str, n) { | |
mainArgs[n] = util.fromJavaString(str); | |
}); | |
- _this.status = 2; // STARTED | |
+ _this._status = 2; // STARTED | |
+ Object.defineProperty(_this, "status", { | |
+ get: function() { return this._status }, | |
+ set: function(val) { | |
+ this._status = val; | |
+ if (this._waitStatusFunc) { | |
+ this._waitStatusFunc(); | |
+ } | |
+ }, | |
+ | |
+ }); | |
_this.runtime = ctx.runtime.vm.run(mainClass, mainArgs); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment