mozilla / pluotsorbet

[ARCHIVED] PluotSorbet is a J2ME-compatible virtual machine written in JavaScript.
GNU General Public License v2.0
236 stars 46 forks source link

Closure compiler and classes.jar.js broken #1370

Open brendandahl opened 9 years ago

brendandahl commented 9 years ago

Closure compiler is breaking classes.jar.js

Still broke after these fixes, but it gets it farther:

--- a/jit/compiler.ts
+++ b/jit/compiler.ts
@@ -103,6 +103,9 @@ module J2ME {
     }

     var mangledClassName = classInfo.mangledName;
+    if (emitter.closure) {
+      mangledClassName = "window['" + mangledClassName + "']";
+    }

     emitter.writer.writeLn(mangledClassName + ".classSymbols = [" + referencedClasses.map(classInfo => {
       return quote(classInfo.getClassNameSlow());
@@ -215,7 +218,7 @@ module J2ME {
       code += s + "\n";
     });

-    var emitter = new Emitter(writer, false, debugInfo, false);
+    var emitter = new Emitter(writer, true, debugInfo, false);

     var compiledMethods: CompiledMethodInfo [] = [];
     var classInfoList: ClassInfo [] = [];
marco-c commented 9 years ago

With https://github.com/mozilla/j2me.js/pull/1373, I'm enabling only SIMPLE optimizations. We can re-enable more aggressive optimizations when we fix this issue.

marco-c commented 9 years ago

Is this fixed now?

brendandahl commented 9 years ago

No, it will take quite a bit of work to get this working since the closure compiler mangles so many names.