Skip to content

Instantly share code, notes, and snippets.

@mykmelez
Created August 7, 2014 17:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mykmelez/c5dad14ff4e6a7e80149 to your computer and use it in GitHub Desktop.
Save mykmelez/c5dad14ff4e6a7e80149 to your computer and use it in GitHub Desktop.
+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