private void generateSeedFuncAndPrototype(JClassType x,
List<JsStatement> globalStmts) {
SourceInfo sourceInfo = x.getSourceInfo().makeChild(
GenerateJavaScriptVisitor.class, "Seed and function prototype");
if (x != program.getTypeJavaLangString()) {
JsName seedFuncName = names.get(x);
// seed function
// function com_example_foo_Foo() { }
JsFunction seedFunc = new JsFunction(sourceInfo, topScope,
seedFuncName, true);
seedFuncName.setStaticRef(seedFunc);
JsBlock body = new JsBlock(sourceInfo);
seedFunc.setBody(body);
JsExprStmt seedFuncStmt = seedFunc.makeStmt();
globalStmts.add(seedFuncStmt);
typeForStatMap.put(seedFuncStmt, x);
// setup prototype, assign to temp
// _ = com_example_foo_Foo.prototype = new com_example_foo_FooSuper();
JsNameRef lhs = prototype.makeRef(sourceInfo);
lhs.setQualifier(seedFuncName.makeRef(sourceInfo));
JsExpression rhs;
if (x.getSuperClass() != null) {
JsNew newExpr = new JsNew(sourceInfo);
JsNameRef superPrototypeRef = names.get(x.getSuperClass()).makeRef(
sourceInfo);