72 |
} |
} |
73 |
|
|
74 |
static void print_string(JSString * s, Stream * f) { |
static void print_string(JSString * s, Stream * f) { |
75 |
for (int i = 0; i < s->length; i++) { |
for (size_t i = 0; i < s->length; i++) { |
76 |
char c = s->chars[i]; |
char c = s->chars[i]; |
77 |
Stream_write_char(f, c); |
Stream_write_char(f, c); |
78 |
} |
} |
853 |
|
|
854 |
/* copy the instrumented source code to the output */ |
/* copy the instrumented source code to the output */ |
855 |
Stream_write(output, instrumented->data, instrumented->length); |
Stream_write(output, instrumented->data, instrumented->length); |
856 |
|
Stream_write_char(output, '\n'); |
857 |
|
|
858 |
|
/* copy the original source to the output */ |
859 |
|
size_t i = 0; |
860 |
|
while (i < input_length) { |
861 |
|
Stream_write_string(output, "// "); |
862 |
|
size_t line_start = i; |
863 |
|
while (i < input_length && base[i] != '\r' && base[i] != '\n') { |
864 |
|
i++; |
865 |
|
} |
866 |
|
|
867 |
|
size_t line_end = i; |
868 |
|
if (i < input_length) { |
869 |
|
if (base[i] == '\r') { |
870 |
|
line_end = i; |
871 |
|
i++; |
872 |
|
if (i < input_length && base[i] == '\n') { |
873 |
|
i++; |
874 |
|
} |
875 |
|
} |
876 |
|
else if (base[i] == '\n') { |
877 |
|
line_end = i; |
878 |
|
i++; |
879 |
|
} |
880 |
|
else { |
881 |
|
abort(); |
882 |
|
} |
883 |
|
} |
884 |
|
|
885 |
|
char * line = js_DeflateString(context, base + line_start, line_end - line_start); |
886 |
|
Stream_write_string(output, line); |
887 |
|
Stream_write_char(output, '\n'); |
888 |
|
JS_free(context, line); |
889 |
|
} |
890 |
|
|
891 |
Stream_delete(instrumented); |
Stream_delete(instrumented); |
892 |
|
|