diff --git a/driver.html b/driver.html index 1f8e49db12b62fe93a174af13e0d5ce22f34d3a3..94ef79cf27b28a7c8536f24f882211516a121584 100644 --- a/driver.html +++ b/driver.html @@ -74,7 +74,7 @@ .scroll-pane { width: 100%; - height: 200px; + height: 300px; overflow: auto; } </style> @@ -125,14 +125,14 @@ Reach condition: <table id='main_table'><tr> <td> <div id='file_list'></div> - <textarea id='interpreter_code' class='source' rows='20' cols='60'></textarea> + <textarea id='interpreter_code' class='source' rows='30' cols='60'></textarea> </td> <td width='600'> - <div id='disp_infos'></div> <div id='disp_ctx'>ctx here</div> </td> </tr></table> </div> +<div id='disp_infos'></div> <script src="tools.js"></script> <script src="generator/tests/jsref/displayed_sources.js"></script> diff --git a/esprima-to-ast.js b/esprima-to-ast.js index 44ade7325e0c31ea46c7f850dcfca28f079bd374..4bece2b66eaeb330eaf6e13c9a41a80f5f761522 100644 --- a/esprima-to-ast.js +++ b/esprima-to-ast.js @@ -17,8 +17,9 @@ function esprimaToAST(prog, sourceText) { var toLoc = function (pos) { if (pos === null) {throw "null position in esprima AST";}; return {file: "input.js", - start: {line: pos.start.line, col: pos.start.column}, - stop: {line: pos.end.line, col: pos.end.column}}; + start: {line: pos.start.line, column: pos.start.column}, + end: {line: pos.end.line, column: pos.end.column}}; + // TODO : could reuse the start and end object }; var toOption = function (funcTr, node) { @@ -429,7 +430,7 @@ function esprimaToAST(prog, sourceText) { loc: { file: previousValue.loc.file, start: previousValue.loc.start, - stop: currentValue.loc.stop + end: currentValue.loc.end } }; }); diff --git a/generator/Makefile b/generator/Makefile index 58de204d76a2312697e278f115b613859bc66afd..49ef6e1eb521906d32631f5368642d44bb170b90 100644 --- a/generator/Makefile +++ b/generator/Makefile @@ -162,7 +162,7 @@ tests/jsref/%.log.js: tests/jsref/%.ml ##################################################################### # Short targets -everything: gen assembly lineof +everything: gen assembly lineof display main: main.byte diff --git a/generator/displayed_sources.ml b/generator/displayed_sources.ml index cb84bb16842a3daca4473e5e9d273da3752ca94f..ba5f5126357d888faadc7a45d64451206e104b7a 100644 --- a/generator/displayed_sources.ml +++ b/generator/displayed_sources.ml @@ -147,10 +147,11 @@ let _ = put "var tracer_files = ["; ~~ List.iter !files (fun filename -> + let basename = Filename.chop_suffix (Filename.basename filename) ".unlog.js" in + let showed_filename = basename ^ ".js" in + put (Printf.sprintf "\n/* --------------------- %s --------------------- */" showed_filename); + put_no_endline (Printf.sprintf " { file: '%s', contents: '" showed_filename); let lines = XFile.get_lines filename in - let short_filename = Filename.chop_suffix (Filename.basename filename) ".unlog.js" in - put (Printf.sprintf "\n/* --------------------- %s --------------------- */" short_filename); - put_no_endline (Printf.sprintf " { file: '%s', contents: '" short_filename); ~~ List.iter lines (fun line -> let line = Str.global_replace (Str.regexp "'") "\\'" line in put_no_endline line; @@ -159,7 +160,7 @@ let _ = put "'},"; ); - put "];"; + put "];"; (*---------------------------------------------------*) (* generating output file *) diff --git a/generator/js_of_ast.ml b/generator/js_of_ast.ml index dc802d5b061f3f1f35248aa607e64ccbe8a06391..943ba8b0ea034951735d7cfd0131f3feb3aea140 100644 --- a/generator/js_of_ast.ml +++ b/generator/js_of_ast.ml @@ -439,7 +439,7 @@ let generate_logged_enter arg_ids ctx newctx sbody = | Mode_unlogged -> ("", "", "") in let args = String.concat ", " arg_ids in - Printf.sprintf "%sfunction (%s)%s {@;<1 2>@[<v 0>%s%s@]@,}" shead1 args shead2 sintro sbody + Printf.sprintf "%sfunction (%s)%s {@\n@;<1 2>@[<v 0>%s%s@]@,}" shead1 args shead2 sintro sbody (* diff --git a/generator/lineof.ml b/generator/lineof.ml index 2c9fb3dbc8277d213f694badecbcf1833f454ec1..1834e573dc54cc34ae8008281968641ff05c04a0 100644 --- a/generator/lineof.ml +++ b/generator/lineof.ml @@ -77,7 +77,7 @@ let hashtbl_keys t = The tokens are placed in a list, with entries of the form ( filename , tokens_start , tokens_stop ) where tokens_start is a hashmap that gives for each token id its - opening positions (line and col), and tokens_stop similarly + opening positions (line and column), and tokens_stop similarly gives the closing positions. *) type pos = { pos_line: int; pos_col: int } @@ -134,8 +134,8 @@ let gather_tokens basename input_lines = function lineof(filename, token) { var d = lineof_data[filename][token]; return { file: filename, - start: {line: d[0], col: d[1]}, - stop: {line: d[2], col: d[3]} }; + start: {line: d[0], column: d[1]}, + end: {line: d[2], column: d[3]} }; } *) @@ -159,7 +159,7 @@ let generate_lineof_function put = key pos_start.pos_line pos_start.pos_col pos_stop.pos_line pos_stop.pos_col); ); - put (Printf.sprintf "lineof_data[\"%s\"] = lineof_temp;" basename); + put (Printf.sprintf "lineof_data[\"%s\"] = lineof_temp;" filename); ) diff --git a/navig-driver.js b/navig-driver.js index 53ac4c04311853b727960f9fb8faabf28431e12e..74436a919492aa43bb8bffba32c0761935f0082c 100644 --- a/navig-driver.js +++ b/navig-driver.js @@ -2,7 +2,7 @@ // ----------- Types ---------------- // type loc -// e.g. {file: "foo.js", start: {line: 12, col: 9}, stop: {line: 13, col: 2} }; +// e.g. {file: "foo.js", start: {line: 12, column: 9}, end: {line: 13, column: 2} }; // Locations are generated by the translation from the parser to the AST. // Lines are numbered starting from "1", and columns are numbered starting from "0". @@ -359,14 +359,38 @@ function updateContext(targetid, heap, env) { }); } +// --------------- Debuggin view ---------------- + +function htmlDiv(s) { + return "<div>" + s + "</div>"; +} + +function ctxToHtml(ctx) { + var s = ''; + var a = ctx_to_array(ctx); + for (var i = 0; i < a.length; i++) { + var b = a[i]; + s += "<div style='white-space: nowrap;'><b>" + b.key + "</b>: " + JSON.stringify(b.val) + "</div>"; + } + return s; +} + + +function itemToHtml(item) { + var s = ''; + s += htmlDiv("type: " + item.type); + s += ctxToHtml(item.ctx); + return s; +} + // --------------- Selection view ---------------- function updateSelectionInCodeMirror(codeMirrorObj, loc) { if (loc === undefined) { return; } - var anchor = {line: loc.start.line-1 , ch: loc.start.col }; - var head = {line: loc.stop.line-1, ch: loc.stop.col }; + var anchor = {line: loc.start.line-1 , ch: loc.start.column }; + var head = {line: loc.end.line-1, ch: loc.end.column }; codeMirrorObj.setSelection(anchor, head); } @@ -376,7 +400,8 @@ function updateSelection() { if (item !== undefined) { // console.log(item); - // $("#disp_infos").html(); + $("#disp_infos").html(""); + $("#disp_infos").html(itemToHtml(item)); if (item.source_loc === undefined) { console.log("Error: missing line in log event"); @@ -435,7 +460,7 @@ interpreter = CodeMirror.fromTextArea(document.getElementById('interpreter_code' 'F': function(cm) { finish(); updateSelection(); } }, }); -interpreter.setSize(600,250); +interpreter.setSize(600,400); /* ==> try in new version of codemirror*/ try { @@ -471,7 +496,8 @@ interpreter.focus(); // the corresponding location from the piece of AST that corresponds. // These locations are used for source highlighting. function assignSourceLocInTrace() { - var last = { start: { line: 1, col: 0}, stop: { line: 1, col: 0 } }; + var last = parsedTree.loc; + // { start: { line: 1, column: 0}, end: { line: 1, column: 1 } }; for (var k = 0; k < tracer_items.length; k++) { var item = tracer_items[k]; if (item.ctx !== undefined && item.ctx.bindings !== undefined) { diff --git a/navig.js b/navig.js index cd78ee753bccc54cb7c54b8597dd7e3ab3d3dd30..97e1e476d1dcc3e94f88e947c2c4e08db144280b 100644 --- a/navig.js +++ b/navig.js @@ -311,7 +311,6 @@ function updateSourceSelection() { if (source_select === undefined) { return; } - // TODO: rename column into col var anchor = {line: source_select.start.line-1 , ch: source_select.start.column }; var head = {line: source_select.end.line-1, ch: source_select.end.column }; source.setSelection(anchor, head); diff --git a/tools.js b/tools.js index c87b9d36be3ea18b6987898bfe02b4c5afd9dee2..3945784fb282d3d98dc2b4c331e81dc5a832bff1 100644 --- a/tools.js +++ b/tools.js @@ -5,8 +5,8 @@ function lineof(filename, token) { var d = lineof_data[filename][token]; return { file: filename, - start: {line: d[0], col: d[1]}, - stop: {line: d[2], col: d[3]} }; + start: {line: d[0], column: d[1]}, + end: {line: d[2], column: d[3]} }; };