зеркало из https://github.com/mozilla/pluotsorbet.git
assume exceptions are implemented in java, not JS
This commit is contained in:
Родитель
888ba71b10
Коммит
1ec0f26911
28
classes.js
28
classes.js
|
@ -161,8 +161,6 @@ Classes.prototype.newObject = function(className) {
|
|||
ctor.prototype = this.newObject(superClassName);
|
||||
var o = new ctor();
|
||||
|
||||
o.getClassName = new Function(util.format("return \"%s\"", className));
|
||||
|
||||
var cp = ca.getConstantPool();
|
||||
|
||||
ca.getFields().forEach(function(field) {
|
||||
|
@ -172,31 +170,9 @@ Classes.prototype.newObject = function(className) {
|
|||
|
||||
ca.getMethods().forEach(function(method) {
|
||||
var methodName = cp[method.name_index].bytes;
|
||||
o[methodName] = new Frame(ca, method);
|
||||
var signature = cp[method.signature_index].bytes;
|
||||
o[methodName + "$" + signature] = new Frame(ca, method);
|
||||
});
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
Classes.prototype.newException = function(className, message, cause) {
|
||||
var ex = this.newObject(className);
|
||||
|
||||
var ca = this.getClass(className);
|
||||
var cp = ca.getConstantPool();
|
||||
var ctors = [];
|
||||
ca.getMethods().forEach(function(method) {
|
||||
if (cp[method.name_index].bytes === "<init>") {
|
||||
ctors[cp[method.signature_index].bytes] = method;
|
||||
}
|
||||
});
|
||||
var ctor = ctors["(Ljava/lang/String;)V"];
|
||||
if (ctor) {
|
||||
}
|
||||
|
||||
Object.keys(ctors).forEach(function (ctor) {
|
||||
console.log(ctor);
|
||||
});
|
||||
ex["<init>"](message, cause);
|
||||
return ex;
|
||||
}
|
||||
|
||||
|
|
12
frame.js
12
frame.js
|
@ -79,17 +79,21 @@ Frame.prototype._throw = function(ex) {
|
|||
}
|
||||
}
|
||||
|
||||
Frame.prototype._newException = function(className) {
|
||||
Frame.prototype._newException = function(className, message) {
|
||||
var self = this;
|
||||
var ex = CLASSES.newException(className, function () {
|
||||
var ex = CLASSES.newObject(className);
|
||||
var done = arguments[arguments.length-1];
|
||||
var ctor = ex["<init>$(Ljava/lang/String;)V"];
|
||||
ctor.setPid(self._pid);
|
||||
ctor.run([ex, message], function () {
|
||||
self._throw(ex);
|
||||
return arguments[arguments.length-1]();
|
||||
return done();
|
||||
});
|
||||
}
|
||||
|
||||
Frame.prototype.run = function(args, done) {
|
||||
var self = this;
|
||||
|
||||
|
||||
this._ip = 0;
|
||||
this._stack = [];
|
||||
this._widened = false;
|
||||
|
|
Загрузка…
Ссылка в новой задаче