}
gen.out(")");
}
static void methodDeclaration(TypeDeclaration outer, Tree.MethodDeclaration that, GenerateJsVisitor gen) {
final Method m = that.getDeclarationModel();
if (that.getSpecifierExpression() != null) {
// method(params) => expr
if (outer == null) {
// Not in a prototype definition. Null to do here if it's a
// member in prototype style.
if (gen.opts.isOptimize() && m.isMember()) { return; }
gen.comment(that);
gen.initDefaultedParameters(that.getParameterLists().get(0), m);
gen.out(m.isToplevel() ? GenerateJsVisitor.function : "var ");
}
else {
// prototype definition
gen.comment(that);
gen.initDefaultedParameters(that.getParameterLists().get(0), m);
gen.out(gen.getNames().self(outer), ".");
}
gen.out(gen.getNames().name(m));
if (!m.isToplevel())gen.out("=");
singleExprFunction(that.getParameterLists(),
that.getSpecifierExpression().getExpression(), m, true, !m.isToplevel(), gen);
gen.endLine(true);
if (outer != null) {
gen.out(gen.getNames().self(outer), ".");
}
gen.out(gen.getNames().name(m), ".$crtmm$=");
TypeUtils.encodeForRuntime(m, that.getAnnotationList(), gen);
gen.endLine(true);
gen.share(m);
}
else if (outer == null // don't do the following in a prototype definition
&& m == that.getScope()) { //Check for refinement of simple param declaration
if (m.getContainer() instanceof Class && m.isClassOrInterfaceMember()) {
//Declare the method just by pointing to the param function
final String name = gen.getNames().name(((Class)m.getContainer()).getParameter(m.getName()));
if (name != null) {
gen.out(gen.getNames().self((Class)m.getContainer()), ".", gen.getNames().name(m), "=", name);
gen.endLine(true);
}
} else if (m.getContainer() instanceof Method) {
//Declare the function just by forcing the name we used in the param list
final String name = gen.getNames().name(((Method)m.getContainer()).getParameter(m.getName()));
gen.getNames().forceName(m, name);
}
//Only the first paramlist can have defaults
gen.initDefaultedParameters(that.getParameterLists().get(0), m);
if (!(gen.opts.isOptimize() && m.isClassOrInterfaceMember()) && gen.shouldStitch(m)) {
if (gen.stitchNative(m, that)) {
if (m.isShared()) {
gen.share(m);
}
}
}
} else if (m == that.getScope() && m.getContainer() instanceof TypeDeclaration && m.isMember()
&& (m.isFormal() || gen.shouldStitch(m))) {
gen.out(gen.getNames().self((TypeDeclaration)m.getContainer()), ".",
gen.getNames().name(m), "=");
if (m.isFormal()) {
gen.out("{$fml:1,$crtmm$:");
TypeUtils.encodeForRuntime(that, m, gen);
gen.out("};");
} else if (gen.shouldStitch(m)) {
if (gen.stitchNative(m, that) && m.isShared()) {
gen.share(m);
}
}
}
}