Subj : Re: jsc feature request To : Andy Madigan From : Igor Bukanov Date : Thu Aug 26 2004 09:02 am Andy Madigan wrote: > --- Igor Bukanov wrote: > > >>Andy Madigan wrote: >> >>>This has probably been requested before, but I though since I found >> >>a >> >>>way to do it, I'd ask anyway. >>> >>>What I would like to be able to do is specify what class/method >> >>should >> >>>be called by the main method in a class generated by jsc. The >> >>current >> >>>version of Codegen puts in a call to >> >>OptRuntime.main(Script,String[]). >> >>>However, if line 501 of Codegen.java was changed to instead get a >>>parameter (e.g. getScriptRuntimeClassName()) from it's CompilerEnv. >> >>The >> >>>class would of course have to have a method matching this >> >>signature: >> >>>public static void main(Script,String[]) >>> >>>and generateMain() in Codegen (starting @ line 487) would have to >> >>be >> >>>made non-static (that change doesn't break anything during >> >>compile). >> >>>A parameter could be added to jsc (e.g. "-runtime") that would >> >>allow >> >>>the user to specify the class containing the above method. >>> >>>I've already made the above changes to my version of the sources, >> >>if >> >>>this seems like a good idea, I can send my changed versions to >> >>whoever >> >>>is interested. >> >>You can file a bug at bugzilla.mozilla.org against Rhino, mark it as >>enhacment and add the patch there. But note that to set the class >>name >>you need to add the method to ClassCompiler which provides public API >> >>for class compilation used by jsc, and not CompilerEnvirons which is >>shared by interpreter and compiler and should not have any >>compiler-specific methods. >> >>Regards, Igor >>_______________________________________________ >>mozilla-jseng mailing list >>mozilla-jseng@mozilla.org >>http://mail.mozilla.org/listinfo/mozilla-jseng >> > > Can the runtime class name be an instance variable of Codegen? It could > be passed the variable by ClassCompiler. Perhaps instead of > CompilerEnvirons.setRuntimeClassName(), it could be > Codegen.setRuntimeClassName(), or should it be a parameter of > Codegen.generateCode(), which could pass it to generateMain()? > (Note that the second change would result in a larger change to the API > of Codegen than the first, all methods that call generateCode() would > have to receive the parameter or send a default) Field in Codegen set from ClassCompiler should be fine. Regards, Igor .