/[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 336 by siliconforks, Thu Oct 23 20:08:29 2008 UTC revision 339 by siliconforks, Fri Oct 24 16:13:57 2008 UTC
# Line 31  Line 31 
31  #include <jsexn.h>  #include <jsexn.h>
32  #include <jsfun.h>  #include <jsfun.h>
33  #include <jsinterp.h>  #include <jsinterp.h>
34    #include <jsiter.h>
35  #include <jsparse.h>  #include <jsparse.h>
36  #include <jsregexp.h>  #include <jsregexp.h>
37  #include <jsscope.h>  #include <jsscope.h>
# Line 55  Line 56 
56  static JSRuntime * runtime = NULL;  static JSRuntime * runtime = NULL;
57  static JSContext * context = NULL;  static JSContext * context = NULL;
58  static JSObject * global = NULL;  static JSObject * global = NULL;
59    static JSVersion js_version = JSVERSION_ECMA_3;
60    
61  /*  /*
62  JSParseNode objects store line numbers starting from 1.  JSParseNode objects store line numbers starting from 1.
# Line 64  Line 66 
66  static char * lines = NULL;  static char * lines = NULL;
67  static uint16_t num_lines = 0;  static uint16_t num_lines = 0;
68    
69    void jscoverage_set_js_version(const char * version) {
70      js_version = atoi(version);
71    }
72    
73  void jscoverage_init(void) {  void jscoverage_init(void) {
74    runtime = JS_NewRuntime(8L * 1024L * 1024L);    runtime = JS_NewRuntime(8L * 1024L * 1024L);
75    if (runtime == NULL) {    if (runtime == NULL) {
# Line 75  Line 81 
81      fatal("cannot create context");      fatal("cannot create context");
82    }    }
83    
84      JS_SetVersion(context, js_version);
85    
86    global = JS_NewObject(context, NULL, NULL, NULL);    global = JS_NewObject(context, NULL, NULL, NULL);
87    if (global == NULL) {    if (global == NULL) {
88      fatal("cannot create global object");      fatal("cannot create global object");
# Line 763  Line 771 
771    case TOK_FOR:    case TOK_FOR:
772      assert(node->pn_arity == PN_BINARY);      assert(node->pn_arity == PN_BINARY);
773      Stream_printf(f, "%*s", indent, "");      Stream_printf(f, "%*s", indent, "");
774      Stream_write_string(f, "for (");      Stream_write_string(f, "for ");
775        if (node->pn_iflags & JSITER_FOREACH) {
776          Stream_write_string(f, "each ");
777        }
778        Stream_write_char(f, '(');
779      switch (node->pn_left->pn_type) {      switch (node->pn_left->pn_type) {
780      case TOK_IN:      case TOK_IN:
781        /* for/in */        /* for/in */

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

  ViewVC Help
Powered by ViewVC 1.1.24