Exemplo n.º 1
0
 static void generateLet(
     final Tree.LetExpression that, final Set<Declaration> directs, final GenerateJsVisitor gen) {
   gen.out("function(){var ");
   boolean first = true;
   HashSet<Declaration> decs2 = new HashSet<>();
   for (Tree.Statement st : that.getLetClause().getVariables()) {
     if (!first) gen.out(",");
     if (st instanceof Tree.Variable) {
       final Tree.Variable var = (Tree.Variable) st;
       gen.out(gen.getNames().name(var.getDeclarationModel()), "=");
       var.getSpecifierExpression().getExpression().visit(gen);
       directs.add(var.getDeclarationModel());
       decs2.add(var.getDeclarationModel());
     } else if (st instanceof Tree.Destructure) {
       final String expvar = gen.getNames().createTempVariable();
       gen.out(expvar, "=");
       ((Tree.Destructure) st).getSpecifierExpression().visit(gen);
       decs2.addAll(
           new Destructurer(
                   ((Tree.Destructure) st).getPattern(), gen, directs, expvar, false, false)
               .getDeclarations());
     }
     first = false;
   }
   gen.out(";return ");
   gen.visitSingleExpression(that.getLetClause().getExpression());
   gen.out("}()");
   directs.removeAll(decs2);
 }
Exemplo n.º 2
0
 @Override
 public void visit(Tree.Variable that) {
   super.visit(that);
   if (that.getDeclarationModel() == declaration) {
     specify();
   }
 }