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

Diff of /trunk/instrument-js.cpp

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

revision 336 by siliconforks, Thu Oct 23 20:08:29 2008 UTC revision 361 by siliconforks, Sun Oct 26 05:28:03 2008 UTC
# Line 28  Line 28 
28  #include <jsapi.h>  #include <jsapi.h>
29  #include <jsarena.h>  #include <jsarena.h>
30  #include <jsatom.h>  #include <jsatom.h>
31    #include <jsemit.h>
32  #include <jsexn.h>  #include <jsexn.h>
33  #include <jsfun.h>  #include <jsfun.h>
34  #include <jsinterp.h>  #include <jsinterp.h>
35    #include <jsiter.h>
36  #include <jsparse.h>  #include <jsparse.h>
37  #include <jsregexp.h>  #include <jsregexp.h>
38  #include <jsscope.h>  #include <jsscope.h>
# Line 50  Line 52 
52    struct IfDirective * next;    struct IfDirective * next;
53  };  };
54    
55    bool jscoverage_mozilla = false;
56    
57  static bool * exclusive_directives = NULL;  static bool * exclusive_directives = NULL;
58    
59  static JSRuntime * runtime = NULL;  static JSRuntime * runtime = NULL;
60  static JSContext * context = NULL;  static JSContext * context = NULL;
61  static JSObject * global = NULL;  static JSObject * global = NULL;
62    static JSVersion js_version = JSVERSION_ECMA_3;
63    
64  /*  /*
65  JSParseNode objects store line numbers starting from 1.  JSParseNode objects store line numbers starting from 1.
# Line 64  Line 69 
69  static char * lines = NULL;  static char * lines = NULL;
70  static uint16_t num_lines = 0;  static uint16_t num_lines = 0;
71    
72    void jscoverage_set_js_version(const char * version) {
73      js_version = atoi(version);
74    }
75    
76  void jscoverage_init(void) {  void jscoverage_init(void) {
77    runtime = JS_NewRuntime(8L * 1024L * 1024L);    runtime = JS_NewRuntime(8L * 1024L * 1024L);
78    if (runtime == NULL) {    if (runtime == NULL) {
# Line 75  Line 84 
84      fatal("cannot create context");      fatal("cannot create context");
85    }    }
86    
87      JS_SetVersion(context, js_version);
88    
89    global = JS_NewObject(context, NULL, NULL, NULL);    global = JS_NewObject(context, NULL, NULL, NULL);
90    if (global == NULL) {    if (global == NULL) {
91      fatal("cannot create global object");      fatal("cannot create global object");
# Line 249  Line 260 
260    
261  static void instrument_expression(JSParseNode * node, Stream * f);  static void instrument_expression(JSParseNode * node, Stream * f);
262  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);
263    static void output_statement(JSParseNode * node, Stream * f, int indent, bool is_jscoverage_if);
264    
265  enum FunctionType {  enum FunctionType {
266    FUNCTION_NORMAL,    FUNCTION_NORMAL,
267    FUNCTION_GETTER_OR_SETTER    FUNCTION_GETTER_OR_SETTER
268  };  };
269    
270    static void output_for_in(JSParseNode * node, Stream * f) {
271      assert(node->pn_type == TOK_FOR);
272      assert(node->pn_arity == PN_BINARY);
273      Stream_write_string(f, "for ");
274      if (node->pn_iflags & JSITER_FOREACH) {
275        Stream_write_string(f, "each ");
276      }
277      Stream_write_char(f, '(');
278      instrument_expression(node->pn_left, f);
279      Stream_write_char(f, ')');
280    }
281    
282    static void output_array_comprehension_or_generator_expression(JSParseNode * node, Stream * f) {
283      assert(node->pn_type == TOK_LEXICALSCOPE);
284      assert(node->pn_arity == PN_NAME);
285      JSParseNode * for_node = node->pn_expr;
286      assert(for_node->pn_type == TOK_FOR);
287      assert(for_node->pn_arity == PN_BINARY);
288      JSParseNode * p = for_node;
289      while (p->pn_type == TOK_FOR) {
290        p = p->pn_right;
291      }
292      JSParseNode * if_node = NULL;
293      if (p->pn_type == TOK_IF) {
294        if_node = p;
295        assert(if_node->pn_arity == PN_TERNARY);
296        p = if_node->pn_kid2;
297      }
298      assert(p->pn_arity == PN_UNARY);
299      p = p->pn_kid;
300      if (p->pn_type == TOK_YIELD) {
301        /* for generator expressions */
302        p = p->pn_kid;
303      }
304    
305      instrument_expression(p, f);
306      p = for_node;
307      while (p->pn_type == TOK_FOR) {
308        Stream_write_char(f, ' ');
309        output_for_in(p, f);
310        p = p->pn_right;
311      }
312      if (if_node) {
313        Stream_write_string(f, " if (");
314        instrument_expression(if_node->pn_kid1, f);
315        Stream_write_char(f, ')');
316      }
317    }
318    
319  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) {
320    assert(node->pn_type == TOK_FUNCTION);    assert(node->pn_type == TOK_FUNCTION);
321    assert(node->pn_arity == PN_FUNC);    assert(node->pn_arity == PN_FUNC);
# Line 293  Line 354 
354        Stream_write_string(f, ", ");        Stream_write_string(f, ", ");
355      }      }
356      JSAtom * param = JS_LOCAL_NAME_TO_ATOM(local_names[i]);      JSAtom * param = JS_LOCAL_NAME_TO_ATOM(local_names[i]);
357        if (param == NULL) {
358          fatal("unsupported parameter type for function: %s", file_id);
359        }
360      print_string_atom(param, f);      print_string_atom(param, f);
361    }    }
362    JS_FinishArenaPool(&pool);    JS_FinishArenaPool(&pool);
363    Stream_write_string(f, ") {\n");    Stream_write_string(f, ") {\n");
364    
365    /* function body */    /* function body */
366    instrument_statement(node->pn_body, f, indent + 2, false);    if (function->flags & JSFUN_EXPR_CLOSURE) {
367        /* expression closure */
368        output_statement(node->pn_body, f, indent + 2, false);
369      }
370      else {
371        instrument_statement(node->pn_body, f, indent + 2, false);
372      }
373    
374    Stream_write_string(f, "}\n");    Stream_write_string(f, "}\n");
375  }  }
376    
377  static void instrument_function_call(JSParseNode * node, Stream * f) {  static void instrument_function_call(JSParseNode * node, Stream * f) {
378    instrument_expression(node->pn_head, f);    JSParseNode * function_node = node->pn_head;
379      if (function_node->pn_type == TOK_FUNCTION) {
380        JSObject * object = function_node->pn_funpob->object;
381        assert(JS_ObjectIsFunction(context, object));
382        JSFunction * function = (JSFunction *) JS_GetPrivate(context, object);
383        assert(function);
384        assert(object == &function->object);
385    
386        if (function_node->pn_flags & TCF_GENEXP_LAMBDA) {
387          /* it's a generator expression */
388          Stream_write_char(f, '(');
389          output_array_comprehension_or_generator_expression(function_node->pn_body, f);
390          Stream_write_char(f, ')');
391          return;
392        }
393        else {
394          Stream_write_char(f, '(');
395          instrument_expression(function_node, f);
396          Stream_write_char(f, ')');
397        }
398      }
399      else {
400        instrument_expression(function_node, f);
401      }
402    Stream_write_char(f, '(');    Stream_write_char(f, '(');
403    for (struct JSParseNode * p = node->pn_head->pn_next; p != NULL; p = p->pn_next) {    for (struct JSParseNode * p = function_node->pn_next; p != NULL; p = p->pn_next) {
404      if (p != node->pn_head->pn_next) {      if (p != node->pn_head->pn_next) {
405        Stream_write_string(f, ", ");        Stream_write_string(f, ", ");
406      }      }
# Line 316  Line 409 
409    Stream_write_char(f, ')');    Stream_write_char(f, ')');
410  }  }
411    
412    static void instrument_declarations(JSParseNode * list, Stream * f) {
413      assert(list->pn_arity == PN_LIST);
414      for (JSParseNode * p = list->pn_head; p != NULL; p = p->pn_next) {
415        switch (p->pn_type) {
416        case TOK_NAME:
417          assert(p->pn_arity == PN_NAME);
418          if (p != list->pn_head) {
419            Stream_write_string(f, ", ");
420          }
421          print_string_atom(p->pn_atom, f);
422          if (p->pn_expr != NULL) {
423            Stream_write_string(f, " = ");
424            instrument_expression(p->pn_expr, f);
425          }
426          break;
427        case TOK_ASSIGN:
428        case TOK_RB:
429        case TOK_RC:
430          /* destructuring */
431          instrument_expression(p, f);
432          break;
433        default:
434          abort();
435          break;
436        }
437      }
438    }
439    
440  /*  /*
441  See <Expressions> in jsparse.h.  See <Expressions> in jsparse.h.
442  TOK_FUNCTION is handled as a statement and as an expression.  TOK_FUNCTION is handled as a statement and as an expression.
# Line 430  Line 551 
551        instrument_expression(node->pn_kid, f);        instrument_expression(node->pn_kid, f);
552        break;        break;
553      default:      default:
554        abort();        fatal("%s: unknown operator (%d) in file", file_id, node->pn_op);
555        break;        break;
556      }      }
557      break;      break;
# Line 487  Line 608 
608      assert(ATOM_IS_STRING(node->pn_atom));      assert(ATOM_IS_STRING(node->pn_atom));
609      {      {
610        JSString * s = ATOM_TO_STRING(node->pn_atom);        JSString * s = ATOM_TO_STRING(node->pn_atom);
611        bool is_keyword = (js_CheckKeyword(JSSTRING_CHARS(s), JSSTRING_LENGTH(s)) != TOK_EOF);        bool must_quote;
612        if (! is_keyword && js_IsIdentifier(s)) {        if (JSSTRING_LENGTH(s) == 0) {
613          Stream_write_char(f, '.');          must_quote = true;
614          print_string_atom(node->pn_atom, f);        }
615          else if (js_CheckKeyword(JSSTRING_CHARS(s), JSSTRING_LENGTH(s)) != TOK_EOF) {
616            must_quote = true;
617          }
618          else if (! js_IsIdentifier(s)) {
619            must_quote = true;
620        }        }
621        else {        else {
622            must_quote = false;
623          }
624          if (must_quote) {
625          Stream_write_char(f, '[');          Stream_write_char(f, '[');
626          print_quoted_string_atom(node->pn_atom, f);          print_quoted_string_atom(node->pn_atom, f);
627          Stream_write_char(f, ']');          Stream_write_char(f, ']');
628        }        }
629          else {
630            Stream_write_char(f, '.');
631            print_string_atom(node->pn_atom, f);
632          }
633      }      }
634      break;      break;
635    case TOK_LB:    case TOK_LB:
# Line 527  Line 660 
660    case TOK_RC:    case TOK_RC:
661      Stream_write_char(f, '{');      Stream_write_char(f, '{');
662      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) {
663        assert(p->pn_type == TOK_COLON);        if (p->pn_type != TOK_COLON) {
664            fatal("unsupported node type in file %s: %d", file_id, p->pn_type);
665          }
666        if (p != node->pn_head) {        if (p != node->pn_head) {
667          Stream_write_string(f, ", ");          Stream_write_string(f, ", ");
668        }        }
# Line 620  Line 755 
755      Stream_write_string(f, " in ");      Stream_write_string(f, " in ");
756      instrument_expression(node->pn_right, f);      instrument_expression(node->pn_right, f);
757      break;      break;
758    default:    case TOK_LEXICALSCOPE:
759      fatal("unsupported node type in file %s: %d", file_id, node->pn_type);      assert(node->pn_arity == PN_NAME);
760    }      assert(node->pn_expr->pn_type == TOK_LET);
761  }      assert(node->pn_expr->pn_arity == PN_BINARY);
762        Stream_write_string(f, "let(");
763  static void instrument_var_statement(JSParseNode * node, Stream * f, int indent) {      assert(node->pn_expr->pn_left->pn_type == TOK_LP);
764    assert(node->pn_arity == PN_LIST);      assert(node->pn_expr->pn_left->pn_arity == PN_LIST);
765    Stream_printf(f, "%*s", indent, "");      instrument_declarations(node->pn_expr->pn_left, f);
766    Stream_write_string(f, "var ");      Stream_write_string(f, ") ");
767    for (struct JSParseNode * p = node->pn_u.list.head; p != NULL; p = p->pn_next) {      instrument_expression(node->pn_expr->pn_right, f);
768      assert(p->pn_type == TOK_NAME);      break;
769      assert(p->pn_arity == PN_NAME);    case TOK_YIELD:
770      if (p != node->pn_head) {      assert(node->pn_arity == PN_UNARY);
771        Stream_write_string(f, ", ");      Stream_write_string(f, "yield");
772        if (node->pn_kid != NULL) {
773          Stream_write_char(f, ' ');
774          instrument_expression(node->pn_kid, f);
775      }      }
776      print_string_atom(p->pn_atom, f);      break;
777      if (p->pn_expr != NULL) {    case TOK_ARRAYCOMP:
778        Stream_write_string(f, " = ");      assert(node->pn_arity == PN_LIST);
779        instrument_expression(p->pn_expr, f);      {
780          JSParseNode * block_node;
781          switch (node->pn_count) {
782          case 1:
783            block_node = node->pn_head;
784            break;
785          case 2:
786            block_node = node->pn_head->pn_next;
787            break;
788          default:
789            abort();
790            break;
791          }
792          Stream_write_char(f, '[');
793          output_array_comprehension_or_generator_expression(block_node, f);
794          Stream_write_char(f, ']');
795      }      }
796        break;
797      case TOK_VAR:
798        assert(node->pn_arity == PN_LIST);
799        Stream_write_string(f, "var ");
800        instrument_declarations(node, f);
801        break;
802      case TOK_LET:
803        assert(node->pn_arity == PN_LIST);
804        Stream_write_string(f, "let ");
805        instrument_declarations(node, f);
806        break;
807      default:
808        fatal("unsupported node type in file %s: %d", file_id, node->pn_type);
809    }    }
810  }  }
811    
# Line 716  Line 882 
882      Stream_write_string(f, "switch (");      Stream_write_string(f, "switch (");
883      instrument_expression(node->pn_left, f);      instrument_expression(node->pn_left, f);
884      Stream_write_string(f, ") {\n");      Stream_write_string(f, ") {\n");
885      for (struct JSParseNode * p = node->pn_right->pn_head; p != NULL; p = p->pn_next) {      {
886        Stream_printf(f, "%*s", indent, "");        JSParseNode * list = node->pn_right;
887        switch (p->pn_type) {        if (list->pn_type == TOK_LEXICALSCOPE) {
888        case TOK_CASE:          list = list->pn_expr;
889          Stream_write_string(f, "case ");        }
890          instrument_expression(p->pn_left, f);        for (struct JSParseNode * p = list->pn_head; p != NULL; p = p->pn_next) {
891          Stream_write_string(f, ":\n");          Stream_printf(f, "%*s", indent, "");
892          break;          switch (p->pn_type) {
893        case TOK_DEFAULT:          case TOK_CASE:
894          Stream_write_string(f, "default:\n");            Stream_write_string(f, "case ");
895          break;            instrument_expression(p->pn_left, f);
896        default:            Stream_write_string(f, ":\n");
897          abort();            break;
898          break;          case TOK_DEFAULT:
899              Stream_write_string(f, "default:\n");
900              break;
901            default:
902              abort();
903              break;
904            }
905            instrument_statement(p->pn_right, f, indent + 2, false);
906        }        }
       instrument_statement(p->pn_right, f, indent + 2, false);  
907      }      }
908      Stream_printf(f, "%*s", indent, "");      Stream_printf(f, "%*s", indent, "");
909      Stream_write_string(f, "}\n");      Stream_write_string(f, "}\n");
# Line 763  Line 935 
935    case TOK_FOR:    case TOK_FOR:
936      assert(node->pn_arity == PN_BINARY);      assert(node->pn_arity == PN_BINARY);
937      Stream_printf(f, "%*s", indent, "");      Stream_printf(f, "%*s", indent, "");
     Stream_write_string(f, "for (");  
938      switch (node->pn_left->pn_type) {      switch (node->pn_left->pn_type) {
939      case TOK_IN:      case TOK_IN:
940        /* for/in */        /* for/in */
941        assert(node->pn_left->pn_arity == PN_BINARY);        assert(node->pn_left->pn_arity == PN_BINARY);
942        switch (node->pn_left->pn_left->pn_type) {        output_for_in(node, f);
       case TOK_VAR:  
         instrument_var_statement(node->pn_left->pn_left, f, 0);  
         break;  
       case TOK_NAME:  
         instrument_expression(node->pn_left->pn_left, f);  
         break;  
       default:  
         /* this is undocumented: for (x.value in y) */  
         instrument_expression(node->pn_left->pn_left, f);  
         break;  
 /*  
       default:  
         fprintf(stderr, "unexpected node type: %d\n", node->pn_left->pn_left->pn_type);  
         abort();  
         break;  
 */  
       }  
       Stream_write_string(f, " in ");  
       instrument_expression(node->pn_left->pn_right, f);  
943        break;        break;
944      case TOK_RESERVED:      case TOK_RESERVED:
945        /* for (;;) */        /* for (;;) */
946        assert(node->pn_left->pn_arity == PN_TERNARY);        assert(node->pn_left->pn_arity == PN_TERNARY);
947          Stream_write_string(f, "for (");
948        if (node->pn_left->pn_kid1) {        if (node->pn_left->pn_kid1) {
949          if (node->pn_left->pn_kid1->pn_type == TOK_VAR) {          instrument_expression(node->pn_left->pn_kid1, f);
           instrument_var_statement(node->pn_left->pn_kid1, f, 0);  
         }  
         else {  
           instrument_expression(node->pn_left->pn_kid1, f);  
         }  
950        }        }
951        Stream_write_string(f, ";");        Stream_write_string(f, ";");
952        if (node->pn_left->pn_kid2) {        if (node->pn_left->pn_kid2) {
# Line 810  Line 958 
958          Stream_write_char(f, ' ');          Stream_write_char(f, ' ');
959          instrument_expression(node->pn_left->pn_kid3, f);          instrument_expression(node->pn_left->pn_kid3, f);
960        }        }
961          Stream_write_char(f, ')');
962        break;        break;
963      default:      default:
964        abort();        abort();
965        break;        break;
966      }      }
967      Stream_write_string(f, ") {\n");      Stream_write_string(f, " {\n");
968      instrument_statement(node->pn_right, f, indent + 2, false);      instrument_statement(node->pn_right, f, indent + 2, false);
969      Stream_write_string(f, "}\n");      Stream_write_string(f, "}\n");
970      break;      break;
# Line 840  Line 989 
989          assert(catch->pn_type == TOK_CATCH);          assert(catch->pn_type == TOK_CATCH);
990          Stream_printf(f, "%*s", indent, "");          Stream_printf(f, "%*s", indent, "");
991          Stream_write_string(f, "catch (");          Stream_write_string(f, "catch (");
992            /* this may not be a name - destructuring assignment */
993            /*
994          assert(catch->pn_kid1->pn_arity == PN_NAME);          assert(catch->pn_kid1->pn_arity == PN_NAME);
995          print_string_atom(catch->pn_kid1->pn_atom, f);          print_string_atom(catch->pn_kid1->pn_atom, f);
996            */
997            instrument_expression(catch->pn_kid1, f);
998          if (catch->pn_kid2) {          if (catch->pn_kid2) {
999            Stream_write_string(f, " if ");            Stream_write_string(f, " if ");
1000            instrument_expression(catch->pn_kid2, f);            instrument_expression(catch->pn_kid2, f);
# Line 886  Line 1039 
1039      Stream_write_string(f, "}\n");      Stream_write_string(f, "}\n");
1040      break;      break;
1041    case TOK_VAR:    case TOK_VAR:
1042      instrument_var_statement(node, f, indent);      Stream_printf(f, "%*s", indent, "");
1043        instrument_expression(node, f);
1044      Stream_write_string(f, ";\n");      Stream_write_string(f, ";\n");
1045      break;      break;
1046    case TOK_RETURN:    case TOK_RETURN:
# Line 921  Line 1075 
1075      */      */
1076      output_statement(node->pn_expr, f, indent, false);      output_statement(node->pn_expr, f, indent, false);
1077      break;      break;
1078      case TOK_LEXICALSCOPE:
1079        /* let statement */
1080        assert(node->pn_arity == PN_NAME);
1081        switch (node->pn_expr->pn_type) {
1082        case TOK_LET:
1083          /* let statement */
1084          assert(node->pn_expr->pn_arity == PN_BINARY);
1085          instrument_statement(node->pn_expr, f, indent, false);
1086          break;
1087        case TOK_LC:
1088          /* block */
1089          Stream_printf(f, "%*s", indent, "");
1090          Stream_write_string(f, "{\n");
1091          instrument_statement(node->pn_expr, f, indent + 2, false);
1092          Stream_printf(f, "%*s", indent, "");
1093          Stream_write_string(f, "}\n");
1094          break;
1095        case TOK_FOR:
1096          instrument_statement(node->pn_expr, f, indent, false);
1097          break;
1098        default:
1099          abort();
1100          break;
1101        }
1102        break;
1103      case TOK_LET:
1104        switch (node->pn_arity) {
1105        case PN_BINARY:
1106          /* let statement */
1107          Stream_printf(f, "%*s", indent, "");
1108          Stream_write_string(f, "let (");
1109          assert(node->pn_left->pn_type == TOK_LP);
1110          assert(node->pn_left->pn_arity == PN_LIST);
1111          instrument_declarations(node->pn_left, f);
1112          Stream_write_string(f, ") {\n");
1113          instrument_statement(node->pn_right, f, indent + 2, false);
1114          Stream_printf(f, "%*s", indent, "");
1115          Stream_write_string(f, "}\n");
1116          break;
1117        case PN_LIST:
1118          /* let definition */
1119          Stream_printf(f, "%*s", indent, "");
1120          instrument_expression(node, f);
1121          Stream_write_string(f, ";\n");
1122          break;
1123        default:
1124          abort();
1125          break;
1126        }
1127        break;
1128      case TOK_DEBUGGER:
1129        Stream_printf(f, "%*s", indent, "");
1130        Stream_write_string(f, "debugger;\n");
1131        break;
1132    default:    default:
1133      fatal("unsupported node type in file %s: %d", file_id, node->pn_type);      fatal("unsupported node type in file %s: %d", file_id, node->pn_type);
1134    }    }
# Line 932  Line 1140 
1140  TOK_EXPORT, TOK_IMPORT are not handled.  TOK_EXPORT, TOK_IMPORT are not handled.
1141  */  */
1142  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) {
1143    if (node->pn_type != TOK_LC) {    if (node->pn_type != TOK_LC && node->pn_type != TOK_LEXICALSCOPE) {
1144      uint16_t line = node->pn_pos.begin.lineno;      uint16_t line = node->pn_pos.begin.lineno;
1145      if (line > num_lines) {      if (line > num_lines) {
1146        fatal("%s: script contains more than 65,535 lines", file_id);        fatal("%s: script contains more than 65,535 lines", file_id);
# Line 1086  Line 1294 
1294    
1295    /* write line number info to the output */    /* write line number info to the output */
1296    Stream_write_string(output, "/* automatically generated by JSCoverage - do not edit */\n");    Stream_write_string(output, "/* automatically generated by JSCoverage - do not edit */\n");
1297    Stream_write_string(output, "if (! top._$jscoverage) {\n  top._$jscoverage = {};\n}\n");    if (jscoverage_mozilla) {
1298    Stream_write_string(output, "var _$jscoverage = top._$jscoverage;\n");      Stream_write_string(output, "try {\n");
1299        Stream_write_string(output, "  Components.utils.import('resource://gre/modules/jscoverage.jsm');\n");
1300        Stream_printf(output, "  dump('%s: successfully imported jscoverage module\\n');\n", id);
1301        Stream_write_string(output, "}\n");
1302        Stream_write_string(output, "catch (e) {\n");
1303        Stream_write_string(output, "  _$jscoverage = {};\n");
1304        Stream_printf(output, "  dump('%s: failed to import jscoverage module - coverage not available for this file\\n');\n", id);
1305        Stream_write_string(output, "}\n");
1306      }
1307      else {
1308        Stream_write_string(output, "if (! top._$jscoverage) {\n  top._$jscoverage = {};\n}\n");
1309        Stream_write_string(output, "var _$jscoverage = top._$jscoverage;\n");
1310      }
1311    Stream_printf(output, "if (! _$jscoverage['%s']) {\n", file_id);    Stream_printf(output, "if (! _$jscoverage['%s']) {\n", file_id);
1312    Stream_printf(output, "  _$jscoverage['%s'] = [];\n", file_id);    Stream_printf(output, "  _$jscoverage['%s'] = [];\n", file_id);
1313    for (int i = 0; i < num_lines; i++) {    for (int i = 0; i < num_lines; i++) {

Legend:
Removed from v.336  
changed lines
  Added in v.361

  ViewVC Help
Powered by ViewVC 1.1.24