Closed iccir closed 8 years ago
In oj 1.x, @implementation Foo
generates the following code:
var Foo = $oj_oj._registerClass({ $oj_c_Foo:1 }, null, function($oj_s, $oj_m) {
function Foo() { this.constructor = Foo;this.$oj_id = ++$oj_oj._id; }
$oj_m.$oj_f_isFoo = function() { return true; }
return Foo;
});
The var Foo = $oj_oj._registerClass(…
is an artifact from the oj 0.x days and results in false positives in ESLint (unused variables). The line should just be:
$oj_oj._registerClass({ $oj_c_Foo:1 }, null, function($oj_s, $oj_m) {
As Ingwie points out in #81, this variable is actually undefined due to _registerClass not returning anything.
oj 2.x now uses up to one temporary return variable per method invocation. This simplifies logic in the compiler and may allow certain optimizations by JS engines (reusing a variable can cause two different types to be assigned to it, which may deoptimize).
Closing for 2.0 release
This issue tracks codegen changes from oj 1 -> oj 2. These changes should be benign, but are significant enough that I wanted to wait for a major version bump.