static void objectArgument(final Tree.ObjectArgument that, final GenerateJsVisitor gen) { final Class c = (Class) that.getDeclarationModel().getTypeDeclaration(); gen.out("(function()"); gen.beginBlock(); gen.out("//ObjectArgument ", that.getIdentifier().getText()); gen.location(that); gen.endLine(); gen.out(GenerateJsVisitor.function, gen.getNames().name(c), "()"); gen.beginBlock(); gen.instantiateSelf(c); gen.referenceOuter(c); Tree.ExtendedType xt = that.getExtendedType(); final Tree.ClassBody body = that.getClassBody(); final Tree.SatisfiedTypes sts = that.getSatisfiedTypes(); final List<Declaration> superDecs = new ArrayList<Declaration>(3); if (!gen.opts.isOptimize()) { new GenerateJsVisitor.SuperVisitor(superDecs).visit(that.getClassBody()); } TypeGenerator.callSupertypes( sts == null ? null : TypeUtils.getTypes(sts.getTypes()), xt == null ? null : xt.getType(), c, that, superDecs, xt == null ? null : xt.getInvocationExpression(), xt == null ? null : c.getParameterList(), gen); body.visit(gen); gen.out("return ", gen.getNames().self(c), ";"); gen.endBlock(false, true); // Add reference to metamodel gen.out(gen.getNames().name(c), ".$crtmm$="); TypeUtils.encodeForRuntime(that, c, gen); gen.endLine(true); TypeGenerator.typeInitialization( xt, sts, c, new GenerateJsVisitor.PrototypeInitCallback() { @Override public void addToPrototypeCallback() { gen.addToPrototype(that, c, body.getStatements()); } }, gen, null, null); gen.out("return ", gen.getNames().name(c), "(new ", gen.getNames().name(c), ".$$);"); gen.endBlock(); gen.out("())"); }