/[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 246 by siliconforks, Sun Oct 5 18:05:42 2008 UTC revision 284 by siliconforks, Sat Oct 11 22:40:31 2008 UTC
# Line 27  Line 27 
27    
28  #include <jsapi.h>  #include <jsapi.h>
29  #include <jsatom.h>  #include <jsatom.h>
30    #include <jsexn.h>
31  #include <jsfun.h>  #include <jsfun.h>
32  #include <jsinterp.h>  #include <jsinterp.h>
33  #include <jsparse.h>  #include <jsparse.h>
# Line 990  Line 991 
991    return true;    return true;
992  }  }
993    
994    static void error_reporter(JSContext * context, const char * message, JSErrorReport * report) {
995      fprintf(stderr, "jscoverage: parse error: line %u: %s\n", report->lineno, message);
996    }
997    
998  void jscoverage_instrument_js(const char * id, const uint16_t * characters, size_t num_characters, Stream * output) {  void jscoverage_instrument_js(const char * id, const uint16_t * characters, size_t num_characters, Stream * output) {
999    file_id = id;    file_id = id;
1000    
# Line 1000  Line 1005 
1005    }    }
1006    
1007    /* parse the javascript */    /* parse the javascript */
1008      JSErrorReporter old_error_reporter = JS_SetErrorReporter(context, error_reporter);
1009    JSParseNode * node = js_ParseTokenStream(context, global, token_stream);    JSParseNode * node = js_ParseTokenStream(context, global, token_stream);
1010    if (node == NULL) {    if (node == NULL) {
1011        js_ReportUncaughtException(context);
1012      fatal("parse error in file: %s", file_id);      fatal("parse error in file: %s", file_id);
1013    }    }
1014      JS_SetErrorReporter(context, old_error_reporter);
1015    num_lines = node->pn_pos.end.lineno;    num_lines = node->pn_pos.end.lineno;
1016    lines = xmalloc(num_lines);    lines = xmalloc(num_lines);
1017    for (unsigned int i = 0; i < num_lines; i++) {    for (unsigned int i = 0; i < num_lines; i++) {

Legend:
Removed from v.246  
changed lines
  Added in v.284

  ViewVC Help
Powered by ViewVC 1.1.24