paulbartrum / jurassic

A .NET library to parse and execute JavaScript code.
MIT License
868 stars 121 forks source link

Prototype Chain Fixed #178

Closed ackava closed 3 years ago

ackava commented 4 years ago
  1. Android does not have method for DefineDynamicModule(name, boolean), so I have added small check.

  2. FIXED, MemberAccessExpression does not tell what is undefined, consider a = b.c.d in this expression if b is undefined, it should return error cannot read propertydof undefined. This helps in debugging quicker.

  3. FIXED, Object.getPrototypeOf should return inherited function as it does correctly in Chrome, you can check this script.

var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var A = /** @class */ (function () {
    function A() {
    }
    return A;
}());
var B = /** @class */ (function (_super) {
    __extends(B, _super);
    function B() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return B;
}(A));
console.log(Object.getPrototypeOf(B) === A);

This error has been fixed and a unit test has been added to test this case.

paulbartrum commented 3 years ago
  1. Android does not have method for DefineDynamicModule(name, boolean), so I have added small check.

No need for this, just make sure the ENABLE_DEBUGGING compiler flag is not present when compiling.

  1. FIXED, MemberAccessExpression does not tell what is undefined, consider a = b.c.d in this expression if b is undefined, it should return error cannot read property d of undefined. This helps in debugging quicker.

I have nothing against making the error messages better, but it needs to be done in such a way as to not bloat the resulting code generation. (Or at least the benchmarks should show no slowdown.)

  1. FIXED, Object.getPrototypeOf should return inherited function as it does correctly in Chrome, you can check this script.

Both setPrototypeOf() and real class support are now in master, so this should be fully fixed now.

Is there anything left for this PR to address, or can I close it?

ackava commented 3 years ago

@paulbartrum Yes you can close this.