* methods into a vtable. It will be of the form
* <code>_ = foo.prototype</code>, where <code>foo</code> is the constructor
* function for <code>vtableType</code>.
*/
private JsStatement vtableStatFor(JClassType vtableType) {
JsNameRef prototypeField = new JsNameRef(
jsprogram.createSourceInfoSynthetic(FragmentExtractor.class,
"prototype field"), "prototype");
JsExpression constructorRef;
SourceInfo sourceInfoVtableSetup = jsprogram.createSourceInfoSynthetic(
FragmentExtractor.class, "vtable setup");
if (vtableType == jprogram.getTypeJavaLangString()) {
// The methods of java.lang.String are put onto JavaScript's String
// prototype
SourceInfo sourceInfoConstructorRef = jsprogram.createSourceInfoSynthetic(
FragmentExtractor.class, "String constructor");
constructorRef = new JsNameRef(sourceInfoConstructorRef, "String");
} else {
constructorRef = map.nameForType(vtableType).makeRef(
sourceInfoVtableSetup);
}
prototypeField.setQualifier(constructorRef);
SourceInfo underlineSourceInfo = jsprogram.createSourceInfoSynthetic(
FragmentExtractor.class, "global _ field");
return (new JsBinaryOperation(sourceInfoVtableSetup, JsBinaryOperator.ASG,
jsprogram.getScope().declareName("_").makeRef(underlineSourceInfo),
prototypeField)).makeStmt();