/[jscoverage]/trunk/instrument-js.c
ViewVC logotype

Diff of /trunk/instrument-js.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 378 by siliconforks, Tue Oct 28 05:31:03 2008 UTC revision 379 by siliconforks, Tue Oct 28 17:50:42 2008 UTC
# Line 267  Line 267 
267    }    }
268  }  }
269    
270  static void instrument_expression(JSParseNode * node, Stream * f);  static void output_expression(JSParseNode * node, Stream * f, bool parenthesize_object_literals);
271  static void instrument_statement(JSParseNode * node, Stream * f, int indent, bool is_jscoverage_if);  static void instrument_statement(JSParseNode * node, Stream * f, int indent, bool is_jscoverage_if);
272  static void output_statement(JSParseNode * node, Stream * f, int indent, bool is_jscoverage_if);  static void output_statement(JSParseNode * node, Stream * f, int indent, bool is_jscoverage_if);
273    
# Line 284  Line 284 
284      Stream_write_string(f, "each ");      Stream_write_string(f, "each ");
285    }    }
286    Stream_write_char(f, '(');    Stream_write_char(f, '(');
287    instrument_expression(node->pn_left, f);    output_expression(node->pn_left, f, false);
288    Stream_write_char(f, ')');    Stream_write_char(f, ')');
289  }  }
290    
# Line 311  Line 311 
311      p = p->pn_kid;      p = p->pn_kid;
312    }    }
313    
314    instrument_expression(p, f);    output_expression(p, f, false);
315    p = for_node;    p = for_node;
316    while (p->pn_type == TOK_FOR) {    while (p->pn_type == TOK_FOR) {
317      Stream_write_char(f, ' ');      Stream_write_char(f, ' ');
# Line 320  Line 320 
320    }    }
321    if (if_node) {    if (if_node) {
322      Stream_write_string(f, " if (");      Stream_write_string(f, " if (");
323      instrument_expression(if_node->pn_kid1, f);      output_expression(if_node->pn_kid1, f, false);
324      Stream_write_char(f, ')');      Stream_write_char(f, ')');
325    }    }
326  }  }
327    
 static void output_destructuring_expression(JSParseNode * node, Stream * f) {  
   switch (node->pn_type) {  
   case TOK_NAME:  
     assert(node->pn_arity == PN_NAME);  
     print_string_atom(node->pn_atom, f);  
     if (node->pn_expr != NULL) {  
       Stream_write_string(f, " = ");  
       instrument_expression(node->pn_expr, f);  
     }  
     break;  
   case TOK_RB:  
     Stream_write_char(f, '[');  
     for (JSParseNode * p = node->pn_head; p != NULL; p = p->pn_next) {  
       if (p != node->pn_head) {  
         Stream_write_string(f, ", ");  
       }  
       /* TOK_COMMA is a special case: a hole in the array */  
       if (p->pn_type != TOK_COMMA) {  
         output_destructuring_expression(p, f);  
       }  
     }  
     if (node->pn_extra == PNX_ENDCOMMA) {  
       Stream_write_char(f, ',');  
     }  
     Stream_write_char(f, ']');  
     break;  
   case TOK_RC:  
     Stream_write_char(f, '{');  
     for (JSParseNode * p = node->pn_head; p != NULL; p = p->pn_next) {  
       if (p != node->pn_head) {  
         Stream_write_string(f, ", ");  
       }  
       if (p->pn_type != TOK_COLON) {  
         fatal_source(file_id, p->pn_pos.begin.lineno, "unsupported node type (%d)", p->pn_type);  
       }  
       instrument_expression(p->pn_left, f);  
       Stream_write_string(f, ": ");  
       output_destructuring_expression(p->pn_right, f);  
     }  
     Stream_write_char(f, '}');  
     break;  
   case TOK_ASSIGN:  
     output_destructuring_expression(node->pn_left, f);  
     Stream_write_string(f, " = ");  
     instrument_expression(node->pn_right, f);  
     break;  
   default:  
     fatal_source(file_id, node->pn_pos.begin.lineno, "unsupported node type (%d)", node->pn_type);  
     break;  
   }  
 }  
   
328  static void instrument_function(JSParseNode * node, Stream * f, int indent, enum FunctionType type) {  static void instrument_function(JSParseNode * node, Stream * f, int indent, enum FunctionType type) {
329    assert(node->pn_type == TOK_FUNCTION);    assert(node->pn_type == TOK_FUNCTION);
330    assert(node->pn_arity == PN_FUNC);    assert(node->pn_arity == PN_FUNC);
# Line 433  Line 381 
381          }          }
382        }        }
383        assert(expression != NULL);        assert(expression != NULL);
384        output_destructuring_expression(expression, f);        output_expression(expression, f, false);
385      }      }
386      else {      else {
387        print_string_atom(param, f);        print_string_atom(param, f);
# Line 487  Line 435 
435      }      }
436      else {      else {
437        Stream_write_char(f, '(');        Stream_write_char(f, '(');
438        instrument_expression(function_node, f);        output_expression(function_node, f, false);
439        Stream_write_char(f, ')');        Stream_write_char(f, ')');
440      }      }
441    }    }
442    else {    else {
443      instrument_expression(function_node, f);      output_expression(function_node, f, false);
444    }    }
445    Stream_write_char(f, '(');    Stream_write_char(f, '(');
446    for (struct JSParseNode * p = function_node->pn_next; p != NULL; p = p->pn_next) {    for (struct JSParseNode * p = function_node->pn_next; p != NULL; p = p->pn_next) {
447      if (p != node->pn_head->pn_next) {      if (p != node->pn_head->pn_next) {
448        Stream_write_string(f, ", ");        Stream_write_string(f, ", ");
449      }      }
450      instrument_expression(p, f);      output_expression(p, f, false);
451    }    }
452    Stream_write_char(f, ')');    Stream_write_char(f, ')');
453  }  }
# Line 510  Line 458 
458      if (p != list->pn_head) {      if (p != list->pn_head) {
459        Stream_write_string(f, ", ");        Stream_write_string(f, ", ");
460      }      }
461      output_destructuring_expression(p, f);      output_expression(p, f, false);
462    }    }
463  }  }
464    
# Line 527  Line 475 
475  TOK_INSTANCEOF  binary  TOK_INSTANCEOF  binary
476  TOK_IN          binary  TOK_IN          binary
477  */  */
478  static void instrument_expression(JSParseNode * node, Stream * f) {  static void output_expression(JSParseNode * node, Stream * f, bool parenthesize_object_literals) {
479    switch (node->pn_type) {    switch (node->pn_type) {
480    case TOK_FUNCTION:    case TOK_FUNCTION:
481      instrument_function(node, f, 0, FUNCTION_NORMAL);      instrument_function(node, f, 0, FUNCTION_NORMAL);
# Line 537  Line 485 
485        if (p != node->pn_head) {        if (p != node->pn_head) {
486          Stream_write_string(f, ", ");          Stream_write_string(f, ", ");
487        }        }
488        instrument_expression(p, f);        output_expression(p, f, parenthesize_object_literals);
489      }      }
490      break;      break;
491    case TOK_ASSIGN:    case TOK_ASSIGN:
492      switch (node->pn_left->pn_type) {      output_expression(node->pn_left, f, parenthesize_object_literals);
     case TOK_RB:  
       output_destructuring_expression(node->pn_left, f);  
       break;  
     case TOK_RC:  
       Stream_write_char(f, '(');  
       output_destructuring_expression(node->pn_left, f);  
       Stream_write_char(f, ')');  
       break;  
     default:  
       instrument_expression(node->pn_left, f);  
       break;  
     }  
493      Stream_write_char(f, ' ');      Stream_write_char(f, ' ');
494      switch (node->pn_op) {      switch (node->pn_op) {
495      case JSOP_ADD:      case JSOP_ADD:
# Line 574  Line 510 
510        break;        break;
511      }      }
512      Stream_write_string(f, "= ");      Stream_write_string(f, "= ");
513      instrument_expression(node->pn_right, f);      output_expression(node->pn_right, f, false);
514      break;      break;
515    case TOK_HOOK:    case TOK_HOOK:
516      instrument_expression(node->pn_kid1, f);      output_expression(node->pn_kid1, f, parenthesize_object_literals);
517      Stream_write_string(f, "? ");      Stream_write_string(f, "? ");
518      instrument_expression(node->pn_kid2, f);      output_expression(node->pn_kid2, f, false);
519      Stream_write_string(f, ": ");      Stream_write_string(f, ": ");
520      instrument_expression(node->pn_kid3, f);      output_expression(node->pn_kid3, f, false);
521      break;      break;
522    case TOK_OR:    case TOK_OR:
523    case TOK_AND:    case TOK_AND:
# Line 597  Line 533 
533    case TOK_DIVOP:    case TOK_DIVOP:
534      switch (node->pn_arity) {      switch (node->pn_arity) {
535      case PN_BINARY:      case PN_BINARY:
536        instrument_expression(node->pn_left, f);        output_expression(node->pn_left, f, parenthesize_object_literals);
537        Stream_printf(f, " %s ", get_op(node->pn_op));        Stream_printf(f, " %s ", get_op(node->pn_op));
538        instrument_expression(node->pn_right, f);        output_expression(node->pn_right, f, false);
539        break;        break;
540      case PN_LIST:      case PN_LIST:
541        for (struct JSParseNode * p = node->pn_head; p != NULL; p = p->pn_next) {        for (struct JSParseNode * p = node->pn_head; p != NULL; p = p->pn_next) {
542          if (p != node->pn_head) {          if (p == node->pn_head) {
543              output_expression(p, f, parenthesize_object_literals);
544            }
545            else {
546            Stream_printf(f, " %s ", get_op(node->pn_op));            Stream_printf(f, " %s ", get_op(node->pn_op));
547              output_expression(p, f, false);
548          }          }
         instrument_expression(p, f);  
549        }        }
550        break;        break;
551      default:      default:
# Line 617  Line 556 
556      switch (node->pn_op) {      switch (node->pn_op) {
557      case JSOP_NEG:      case JSOP_NEG:
558        Stream_write_char(f, '-');        Stream_write_char(f, '-');
559        instrument_expression(node->pn_kid, f);        output_expression(node->pn_kid, f, false);
560        break;        break;
561      case JSOP_POS:      case JSOP_POS:
562        Stream_write_char(f, '+');        Stream_write_char(f, '+');
563        instrument_expression(node->pn_kid, f);        output_expression(node->pn_kid, f, false);
564        break;        break;
565      case JSOP_NOT:      case JSOP_NOT:
566        Stream_write_char(f, '!');        Stream_write_char(f, '!');
567        instrument_expression(node->pn_kid, f);        output_expression(node->pn_kid, f, false);
568        break;        break;
569      case JSOP_BITNOT:      case JSOP_BITNOT:
570        Stream_write_char(f, '~');        Stream_write_char(f, '~');
571        instrument_expression(node->pn_kid, f);        output_expression(node->pn_kid, f, false);
572        break;        break;
573      case JSOP_TYPEOF:      case JSOP_TYPEOF:
574        Stream_write_string(f, "typeof ");        Stream_write_string(f, "typeof ");
575        instrument_expression(node->pn_kid, f);        output_expression(node->pn_kid, f, false);
576        break;        break;
577      case JSOP_VOID:      case JSOP_VOID:
578        Stream_write_string(f, "void ");        Stream_write_string(f, "void ");
579        instrument_expression(node->pn_kid, f);        output_expression(node->pn_kid, f, false);
580        break;        break;
581      default:      default:
582        fatal_source(file_id, node->pn_pos.begin.lineno, "unknown operator (%d)", node->pn_op);        fatal_source(file_id, node->pn_pos.begin.lineno, "unknown operator (%d)", node->pn_op);
# Line 654  Line 593 
593      case JSOP_INCPROP:      case JSOP_INCPROP:
594      case JSOP_INCELEM:      case JSOP_INCELEM:
595        Stream_write_string(f, "++");        Stream_write_string(f, "++");
596        instrument_expression(node->pn_kid, f);        output_expression(node->pn_kid, f, false);
597        break;        break;
598      case JSOP_DECNAME:      case JSOP_DECNAME:
599      case JSOP_DECPROP:      case JSOP_DECPROP:
600      case JSOP_DECELEM:      case JSOP_DECELEM:
601        Stream_write_string(f, "--");        Stream_write_string(f, "--");
602        instrument_expression(node->pn_kid, f);        output_expression(node->pn_kid, f, false);
603        break;        break;
604      case JSOP_NAMEINC:      case JSOP_NAMEINC:
605      case JSOP_PROPINC:      case JSOP_PROPINC:
606      case JSOP_ELEMINC:      case JSOP_ELEMINC:
607        instrument_expression(node->pn_kid, f);        output_expression(node->pn_kid, f, parenthesize_object_literals);
608        Stream_write_string(f, "++");        Stream_write_string(f, "++");
609        break;        break;
610      case JSOP_NAMEDEC:      case JSOP_NAMEDEC:
611      case JSOP_PROPDEC:      case JSOP_PROPDEC:
612      case JSOP_ELEMDEC:      case JSOP_ELEMDEC:
613        instrument_expression(node->pn_kid, f);        output_expression(node->pn_kid, f, parenthesize_object_literals);
614        Stream_write_string(f, "--");        Stream_write_string(f, "--");
615        break;        break;
616      default:      default:
# Line 685  Line 624 
624      break;      break;
625    case TOK_DELETE:    case TOK_DELETE:
626      Stream_write_string(f, "delete ");      Stream_write_string(f, "delete ");
627      instrument_expression(node->pn_kid, f);      output_expression(node->pn_kid, f, false);
628      break;      break;
629    case TOK_DOT:    case TOK_DOT:
630      /* numeric literals must be parenthesized */      /* numeric literals must be parenthesized */
631      switch (node->pn_expr->pn_type) {      switch (node->pn_expr->pn_type) {
632      case TOK_NUMBER:      case TOK_NUMBER:
633        Stream_write_char(f, '(');        Stream_write_char(f, '(');
634        instrument_expression(node->pn_expr, f);        output_expression(node->pn_expr, f, false);
635        Stream_write_char(f, ')');        Stream_write_char(f, ')');
636        break;        break;
637      default:      default:
638        instrument_expression(node->pn_expr, f);        output_expression(node->pn_expr, f, true);
639        break;        break;
640      }      }
641      /*      /*
# Line 732  Line 671 
671      }      }
672      break;      break;
673    case TOK_LB:    case TOK_LB:
674      instrument_expression(node->pn_left, f);      output_expression(node->pn_left, f, false);
675      Stream_write_char(f, '[');      Stream_write_char(f, '[');
676      instrument_expression(node->pn_right, f);      output_expression(node->pn_right, f, false);
677      Stream_write_char(f, ']');      Stream_write_char(f, ']');
678      break;      break;
679    case TOK_LP:    case TOK_LP:
# Line 748  Line 687 
687        }        }
688        /* TOK_COMMA is a special case: a hole in the array */        /* TOK_COMMA is a special case: a hole in the array */
689        if (p->pn_type != TOK_COMMA) {        if (p->pn_type != TOK_COMMA) {
690          instrument_expression(p, f);          output_expression(p, f, false);
691        }        }
692      }      }
693      if (node->pn_extra == PNX_ENDCOMMA) {      if (node->pn_extra == PNX_ENDCOMMA) {
# Line 757  Line 696 
696      Stream_write_char(f, ']');      Stream_write_char(f, ']');
697      break;      break;
698    case TOK_RC:    case TOK_RC:
699      Stream_write_char(f, '(');      if (parenthesize_object_literals) {
700          Stream_write_char(f, '(');
701        }
702      Stream_write_char(f, '{');      Stream_write_char(f, '{');
703      for (struct JSParseNode * p = node->pn_head; p != NULL; p = p->pn_next) {      for (struct JSParseNode * p = node->pn_head; p != NULL; p = p->pn_next) {
704        if (p->pn_type != TOK_COLON) {        if (p->pn_type != TOK_COLON) {
# Line 777  Line 718 
718          else {          else {
719            Stream_write_string(f, "set ");            Stream_write_string(f, "set ");
720          }          }
721          instrument_expression(p->pn_left, f);          output_expression(p->pn_left, f, false);
722          if (p->pn_right->pn_type != TOK_FUNCTION) {          if (p->pn_right->pn_type != TOK_FUNCTION) {
723            fatal_source(file_id, p->pn_pos.begin.lineno, "expected function");            fatal_source(file_id, p->pn_pos.begin.lineno, "expected function");
724          }          }
725          instrument_function(p->pn_right, f, 0, FUNCTION_GETTER_OR_SETTER);          instrument_function(p->pn_right, f, 0, FUNCTION_GETTER_OR_SETTER);
726          break;          break;
727        default:        default:
728          instrument_expression(p->pn_left, f);          output_expression(p->pn_left, f, false);
729          Stream_write_string(f, ": ");          Stream_write_string(f, ": ");
730          instrument_expression(p->pn_right, f);          output_expression(p->pn_right, f, false);
731          break;          break;
732        }        }
733      }      }
734      Stream_write_char(f, '}');      Stream_write_char(f, '}');
735      Stream_write_char(f, ')');      if (parenthesize_object_literals) {
736          Stream_write_char(f, ')');
737        }
738      break;      break;
739    case TOK_RP:    case TOK_RP:
740      Stream_write_char(f, '(');      Stream_write_char(f, '(');
741      instrument_expression(node->pn_kid, f);      output_expression(node->pn_kid, f, false);
742      Stream_write_char(f, ')');      Stream_write_char(f, ')');
743      break;      break;
744    case TOK_NAME:    case TOK_NAME:
745      print_string_atom(node->pn_atom, f);      print_string_atom(node->pn_atom, f);
746        if (node->pn_expr != NULL) {
747          Stream_write_string(f, " = ");
748          output_expression(node->pn_expr, f, false);
749        }
750      break;      break;
751    case TOK_STRING:    case TOK_STRING:
752      print_quoted_string_atom(node->pn_atom, f);      print_quoted_string_atom(node->pn_atom, f);
# Line 847  Line 794 
794      }      }
795      break;      break;
796    case TOK_INSTANCEOF:    case TOK_INSTANCEOF:
797      instrument_expression(node->pn_left, f);      output_expression(node->pn_left, f, parenthesize_object_literals);
798      Stream_write_string(f, " instanceof ");      Stream_write_string(f, " instanceof ");
799      instrument_expression(node->pn_right, f);      output_expression(node->pn_right, f, false);
800      break;      break;
801    case TOK_IN:    case TOK_IN:
802      instrument_expression(node->pn_left, f);      output_expression(node->pn_left, f, false);
803      Stream_write_string(f, " in ");      Stream_write_string(f, " in ");
804      instrument_expression(node->pn_right, f);      output_expression(node->pn_right, f, false);
805      break;      break;
806    case TOK_LEXICALSCOPE:    case TOK_LEXICALSCOPE:
807      assert(node->pn_arity == PN_NAME);      assert(node->pn_arity == PN_NAME);
# Line 865  Line 812 
812      assert(node->pn_expr->pn_left->pn_arity == PN_LIST);      assert(node->pn_expr->pn_left->pn_arity == PN_LIST);
813      instrument_declarations(node->pn_expr->pn_left, f);      instrument_declarations(node->pn_expr->pn_left, f);
814      Stream_write_string(f, ") ");      Stream_write_string(f, ") ");
815      instrument_expression(node->pn_expr->pn_right, f);      output_expression(node->pn_expr->pn_right, f, true);
816      break;      break;
817    case TOK_YIELD:    case TOK_YIELD:
818      assert(node->pn_arity == PN_UNARY);      assert(node->pn_arity == PN_UNARY);
819      Stream_write_string(f, "yield");      Stream_write_string(f, "yield");
820      if (node->pn_kid != NULL) {      if (node->pn_kid != NULL) {
821        Stream_write_char(f, ' ');        Stream_write_char(f, ' ');
822        instrument_expression(node->pn_kid, f);        output_expression(node->pn_kid, f, true);
823      }      }
824      break;      break;
825    case TOK_ARRAYCOMP:    case TOK_ARRAYCOMP:
# Line 944  Line 891 
891    
892      Stream_printf(f, "%*s", indent, "");      Stream_printf(f, "%*s", indent, "");
893      Stream_write_string(f, "if (");      Stream_write_string(f, "if (");
894      instrument_expression(node->pn_kid1, f);      output_expression(node->pn_kid1, f, false);
895      Stream_write_string(f, ") {\n");      Stream_write_string(f, ") {\n");
896      if (is_jscoverage_if && node->pn_kid3) {      if (is_jscoverage_if && node->pn_kid3) {
897        uint16_t else_start = node->pn_kid3->pn_pos.begin.lineno;        uint16_t else_start = node->pn_kid3->pn_pos.begin.lineno;
# Line 981  Line 928 
928      assert(node->pn_arity == PN_BINARY);      assert(node->pn_arity == PN_BINARY);
929      Stream_printf(f, "%*s", indent, "");      Stream_printf(f, "%*s", indent, "");
930      Stream_write_string(f, "switch (");      Stream_write_string(f, "switch (");
931      instrument_expression(node->pn_left, f);      output_expression(node->pn_left, f, false);
932      Stream_write_string(f, ") {\n");      Stream_write_string(f, ") {\n");
933      {      {
934        JSParseNode * list = node->pn_right;        JSParseNode * list = node->pn_right;
# Line 993  Line 940 
940          switch (p->pn_type) {          switch (p->pn_type) {
941          case TOK_CASE:          case TOK_CASE:
942            Stream_write_string(f, "case ");            Stream_write_string(f, "case ");
943            instrument_expression(p->pn_left, f);            output_expression(p->pn_left, f, false);
944            Stream_write_string(f, ":\n");            Stream_write_string(f, ":\n");
945            break;            break;
946          case TOK_DEFAULT:          case TOK_DEFAULT:
# Line 1017  Line 964 
964      assert(node->pn_arity == PN_BINARY);      assert(node->pn_arity == PN_BINARY);
965      Stream_printf(f, "%*s", indent, "");      Stream_printf(f, "%*s", indent, "");
966      Stream_write_string(f, "while (");      Stream_write_string(f, "while (");
967      instrument_expression(node->pn_left, f);      output_expression(node->pn_left, f, false);
968      Stream_write_string(f, ") {\n");      Stream_write_string(f, ") {\n");
969      instrument_statement(node->pn_right, f, indent + 2, false);      instrument_statement(node->pn_right, f, indent + 2, false);
970      Stream_write_string(f, "}\n");      Stream_write_string(f, "}\n");
# Line 1030  Line 977 
977      Stream_write_string(f, "}\n");      Stream_write_string(f, "}\n");
978      Stream_printf(f, "%*s", indent, "");      Stream_printf(f, "%*s", indent, "");
979      Stream_write_string(f, "while (");      Stream_write_string(f, "while (");
980      instrument_expression(node->pn_right, f);      output_expression(node->pn_right, f, false);
981      Stream_write_string(f, ");\n");      Stream_write_string(f, ");\n");
982      break;      break;
983    case TOK_FOR:    case TOK_FOR:
# Line 1047  Line 994 
994        assert(node->pn_left->pn_arity == PN_TERNARY);        assert(node->pn_left->pn_arity == PN_TERNARY);
995        Stream_write_string(f, "for (");        Stream_write_string(f, "for (");
996        if (node->pn_left->pn_kid1) {        if (node->pn_left->pn_kid1) {
997          instrument_expression(node->pn_left->pn_kid1, f);          output_expression(node->pn_left->pn_kid1, f, false);
998        }        }
999        Stream_write_string(f, ";");        Stream_write_string(f, ";");
1000        if (node->pn_left->pn_kid2) {        if (node->pn_left->pn_kid2) {
1001          Stream_write_char(f, ' ');          Stream_write_char(f, ' ');
1002          instrument_expression(node->pn_left->pn_kid2, f);          output_expression(node->pn_left->pn_kid2, f, false);
1003        }        }
1004        Stream_write_string(f, ";");        Stream_write_string(f, ";");
1005        if (node->pn_left->pn_kid3) {        if (node->pn_left->pn_kid3) {
1006          Stream_write_char(f, ' ');          Stream_write_char(f, ' ');
1007          instrument_expression(node->pn_left->pn_kid3, f);          output_expression(node->pn_left->pn_kid3, f, false);
1008        }        }
1009        Stream_write_char(f, ')');        Stream_write_char(f, ')');
1010        break;        break;
# Line 1073  Line 1020 
1020      assert(node->pn_arity == PN_UNARY);      assert(node->pn_arity == PN_UNARY);
1021      Stream_printf(f, "%*s", indent, "");      Stream_printf(f, "%*s", indent, "");
1022      Stream_write_string(f, "throw ");      Stream_write_string(f, "throw ");
1023      instrument_expression(node->pn_u.unary.kid, f);      output_expression(node->pn_u.unary.kid, f, false);
1024      Stream_write_string(f, ";\n");      Stream_write_string(f, ";\n");
1025      break;      break;
1026    case TOK_TRY:    case TOK_TRY:
# Line 1090  Line 1037 
1037          assert(catch->pn_type == TOK_CATCH);          assert(catch->pn_type == TOK_CATCH);
1038          Stream_printf(f, "%*s", indent, "");          Stream_printf(f, "%*s", indent, "");
1039          Stream_write_string(f, "catch (");          Stream_write_string(f, "catch (");
1040          output_destructuring_expression(catch->pn_kid1, f);          output_expression(catch->pn_kid1, f, false);
1041          if (catch->pn_kid2) {          if (catch->pn_kid2) {
1042            Stream_write_string(f, " if ");            Stream_write_string(f, " if ");
1043            instrument_expression(catch->pn_kid2, f);            output_expression(catch->pn_kid2, f, false);
1044          }          }
1045          Stream_write_string(f, ") {\n");          Stream_write_string(f, ") {\n");
1046          instrument_statement(catch->pn_kid3, f, indent + 2, false);          instrument_statement(catch->pn_kid3, f, indent + 2, false);
# Line 1128  Line 1075 
1075      assert(node->pn_arity == PN_BINARY);      assert(node->pn_arity == PN_BINARY);
1076      Stream_printf(f, "%*s", indent, "");      Stream_printf(f, "%*s", indent, "");
1077      Stream_write_string(f, "with (");      Stream_write_string(f, "with (");
1078      instrument_expression(node->pn_left, f);      output_expression(node->pn_left, f, false);
1079      Stream_write_string(f, ") {\n");      Stream_write_string(f, ") {\n");
1080      instrument_statement(node->pn_right, f, indent + 2, false);      instrument_statement(node->pn_right, f, indent + 2, false);
1081      Stream_printf(f, "%*s", indent, "");      Stream_printf(f, "%*s", indent, "");
# Line 1136  Line 1083 
1083      break;      break;
1084    case TOK_VAR:    case TOK_VAR:
1085      Stream_printf(f, "%*s", indent, "");      Stream_printf(f, "%*s", indent, "");
1086      instrument_expression(node, f);      output_expression(node, f, false);
1087      Stream_write_string(f, ";\n");      Stream_write_string(f, ";\n");
1088      break;      break;
1089    case TOK_RETURN:    case TOK_RETURN:
# Line 1145  Line 1092 
1092      Stream_write_string(f, "return");      Stream_write_string(f, "return");
1093      if (node->pn_kid != NULL) {      if (node->pn_kid != NULL) {
1094        Stream_write_char(f, ' ');        Stream_write_char(f, ' ');
1095        instrument_expression(node->pn_kid, f);        output_expression(node->pn_kid, f, true);
1096      }      }
1097      Stream_write_string(f, ";\n");      Stream_write_string(f, ";\n");
1098      break;      break;
# Line 1153  Line 1100 
1100      assert(node->pn_arity == PN_UNARY);      assert(node->pn_arity == PN_UNARY);
1101      Stream_printf(f, "%*s", indent, "");      Stream_printf(f, "%*s", indent, "");
1102      if (node->pn_kid != NULL) {      if (node->pn_kid != NULL) {
1103        instrument_expression(node->pn_kid, f);        output_expression(node->pn_kid, f, true);
1104      }      }
1105      Stream_write_string(f, ";\n");      Stream_write_string(f, ";\n");
1106      break;      break;
# Line 1227  Line 1174 
1174      case PN_LIST:      case PN_LIST:
1175        /* let definition */        /* let definition */
1176        Stream_printf(f, "%*s", indent, "");        Stream_printf(f, "%*s", indent, "");
1177        instrument_expression(node, f);        output_expression(node, f, false);
1178        Stream_write_string(f, ";\n");        Stream_write_string(f, ";\n");
1179        break;        break;
1180      default:      default:

Legend:
Removed from v.378  
changed lines
  Added in v.379

  ViewVC Help
Powered by ViewVC 1.1.24