/[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 346 by siliconforks, Fri Oct 24 16:16:24 2008 UTC revision 350 by siliconforks, Fri Oct 24 16:17:39 2008 UTC
# Line 583  Line 583 
583      assert(ATOM_IS_STRING(node->pn_atom));      assert(ATOM_IS_STRING(node->pn_atom));
584      {      {
585        JSString * s = ATOM_TO_STRING(node->pn_atom);        JSString * s = ATOM_TO_STRING(node->pn_atom);
586        bool is_keyword = (js_CheckKeyword(JSSTRING_CHARS(s), JSSTRING_LENGTH(s)) != TOK_EOF);        bool must_quote;
587        if (! is_keyword && js_IsIdentifier(s)) {        if (JSSTRING_LENGTH(s) == 0) {
588          Stream_write_char(f, '.');          must_quote = true;
589          print_string_atom(node->pn_atom, f);        }
590          else if (js_CheckKeyword(JSSTRING_CHARS(s), JSSTRING_LENGTH(s)) != TOK_EOF) {
591            must_quote = true;
592          }
593          else if (! js_IsIdentifier(s)) {
594            must_quote = true;
595        }        }
596        else {        else {
597            must_quote = false;
598          }
599          if (must_quote) {
600          Stream_write_char(f, '[');          Stream_write_char(f, '[');
601          print_quoted_string_atom(node->pn_atom, f);          print_quoted_string_atom(node->pn_atom, f);
602          Stream_write_char(f, ']');          Stream_write_char(f, ']');
603        }        }
604          else {
605            Stream_write_char(f, '.');
606            print_string_atom(node->pn_atom, f);
607          }
608      }      }
609      break;      break;
610    case TOK_LB:    case TOK_LB:
# Line 868  Line 880 
880      Stream_write_string(f, "switch (");      Stream_write_string(f, "switch (");
881      instrument_expression(node->pn_left, f);      instrument_expression(node->pn_left, f);
882      Stream_write_string(f, ") {\n");      Stream_write_string(f, ") {\n");
883      for (struct JSParseNode * p = node->pn_right->pn_head; p != NULL; p = p->pn_next) {      {
884        Stream_printf(f, "%*s", indent, "");        JSParseNode * list = node->pn_right;
885        switch (p->pn_type) {        if (list->pn_type == TOK_LEXICALSCOPE) {
886        case TOK_CASE:          list = list->pn_expr;
887          Stream_write_string(f, "case ");        }
888          instrument_expression(p->pn_left, f);        for (struct JSParseNode * p = list->pn_head; p != NULL; p = p->pn_next) {
889          Stream_write_string(f, ":\n");          Stream_printf(f, "%*s", indent, "");
890          break;          switch (p->pn_type) {
891        case TOK_DEFAULT:          case TOK_CASE:
892          Stream_write_string(f, "default:\n");            Stream_write_string(f, "case ");
893          break;            instrument_expression(p->pn_left, f);
894        default:            Stream_write_string(f, ":\n");
895          abort();            break;
896          break;          case TOK_DEFAULT:
897              Stream_write_string(f, "default:\n");
898              break;
899            default:
900              abort();
901              break;
902            }
903            instrument_statement(p->pn_right, f, indent + 2, false);
904        }        }
       instrument_statement(p->pn_right, f, indent + 2, false);  
905      }      }
906      Stream_printf(f, "%*s", indent, "");      Stream_printf(f, "%*s", indent, "");
907      Stream_write_string(f, "}\n");      Stream_write_string(f, "}\n");
# Line 1105  Line 1123 
1123        break;        break;
1124      }      }
1125      break;      break;
1126      case TOK_DEBUGGER:
1127        Stream_printf(f, "%*s", indent, "");
1128        Stream_write_string(f, "debugger;\n");
1129        break;
1130    default:    default:
1131      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);
1132    }    }

Legend:
Removed from v.346  
changed lines
  Added in v.350

  ViewVC Help
Powered by ViewVC 1.1.24