endLine(true);
}
}
else if (bmeDecl instanceof MethodOrValue) {
// "attr = expr;" in an initializer or method
final MethodOrValue moval = (MethodOrValue)bmeDecl;
if (moval.isVariable()) {
// simple assignment to a variable attribute
BmeGenerator.generateMemberAccess(bme, new GenerateCallback() {
@Override public void generateValue() {
int boxType = boxUnboxStart(expr.getTerm(), moval);
if (dynblock > 0 && !Util.isTypeUnknown(moval.getType())
&& Util.isTypeUnknown(expr.getTypeModel())) {
TypeUtils.generateDynamicCheck(expr, moval.getType(), GenerateJsVisitor.this, false,
expr.getTypeModel().getTypeArguments());
} else {
expr.visit(GenerateJsVisitor.this);
}
if (boxType == 4) {
out(",");
if (moval instanceof Method) {
//Add parameters
TypeUtils.encodeParameterListForRuntime(specStmt,
((Method)moval).getParameterLists().get(0), GenerateJsVisitor.this);
out(",");
} else {
//TODO extract parameters from Value
out("[/*VALUE Callable params", moval.getClass().getName(), "*/],");
}
TypeUtils.printTypeArguments(expr, expr.getTypeModel().getTypeArguments(),
GenerateJsVisitor.this, false, expr.getTypeModel().getVarianceOverrides());
}
boxUnboxEnd(boxType);
}
}, null, this);
out(";");
} else if (moval.isMember()) {
if (moval instanceof Method) {
//same as fat arrow
qualify(specStmt, bmeDecl);
out(names.name(moval), "=function ", names.name(moval), "(");
//Build the parameter list, we'll use it several times