Skip to content
Snippets Groups Projects
Commit e1ae1779 authored by charguer's avatar charguer Committed by Thomas Wood
Browse files

beautified

parent 41d17969
No related branches found
No related tags found
No related merge requests found
javascript >>> op
prevent use of "tag" or "type" as object field name
NEW NEW TODO
- remove _runs0 from arguments
- rename the p' variables
- restore button step into / next
- if switch,return,call,var generate events,
NEW TODO
- utiliser "=" comme comparison primitive? ou supprimer les occurences?
- parse pickage in JsCommon needed for eval
- optimize ML code for
type_compare mutability_compare prim_compare
and test for prim_compare if we can match on pairs of arguments, with a catchall
- move prim_compare and value_compare to a higher file because it is interesting and should be logged
- move same_value_dec from jscommonaux to a higher file
- generate the escaped source code
- LATER: inline the "%able" functions
- LATER: remove useless files such as LibReflect LibString etc...
=========================================================
CURRENT TODO
- BONUS -- generate "type: " in smart constructors [optional until display is needed]
*) Alan: proof read JSNumber
=========================================================
HERE IS HOW TO PRINT BROWSER STACK SIZE LIMIT:
*) Thomas: factorize branches such as:
in the console, execute:
var i=0;
function inc() {
i++;
inc();
}
inc();
| Coq_prim_bool b0 ->
(fun s m -> Debug.impossible_with_heap_because __LOC__ s m; Coq_result_impossible)
s
("[run_object_method] returned a primitive in [object_proto_is_prototype_of_body].")
| Coq_prim_number n ->
(fun s m -> Debug.impossible_with_heap_because __LOC__ s m; Coq_result_impossible)
s
("[run_object_method] returned a primitive in [object_proto_is_prototype_of_body].")
then print value of "i".
=========================================================
*) Arthur: inline let_binding
- Introduce testing functions called:
- test_exec("code") -> parse, convert, build trace, log trace
- Test first "var x = 3".
- Test a compound example, e.g.:
var x = 3;
x = 4;
if (x === 4) {
while (false) {}
}
- Test langage features one by one, using minimal input programs;
these programs should be stored in an "examples/" folder;
for each example, check the AST, check step-by-step the execution.
=> to see if the right things get highlighted
*) Alan/Thomas: test "eval", might need pieces of JsCommon for it (parsePickable)
- display JS values/env/heap/ctx in html
- contexts: essentially as before
- environments: need to follow the list of environment records
- heap: same as before, and do not attempt at first to show
additional information in the heap appart from key/value bindings.
- BONUS in JsInterpreter let append = strappend (* hack for compatibility, to do cleanup *)
*) ?
update the ML code for: type_compare mutability_compare prim_compare
(for prim_compare, we should be able to match on pairs of arguments, with a catch-all)
*)
- move prim_compare and value_compare to JsInterpreter because it is interesting and should be logged
- move same_value_dec from jscommonaux
*) See if we can inline the "%able" functions, e.g. string_comparable
=========================================================
LATER
[thomas]
*) [thomas]
- bigger test262 testing.
- Flat to force esprima to parse in strict mode
[thomas and alan]
- add a combo box above the source textbox for loading in one click
a particular example. The source code for the examples is obtained
by including a JS file that contains an array of source code,
this file being generated from the contents of the "examples" folder.
*) LATER: remove useless files such as LibReflect LibString etc...
*) [thomas]
- put online the tool on the jscert website
- make sure to describe the supported features
(ecma5 minus for-in and a few other things)
......@@ -100,14 +53,17 @@ LATER
from ML files and thus should not be edited,
although this might change in the future.
- assembly.js should have a header
to tell people not to use this file
- full display of heap information
*) Arthur: full display of heap information
add a "+details" button
to show additional information about an object, like the
getter and setter methods, and also for each field we need
to see additional information like enumerable/configurable...
- search by predicate in the trace
*) Arthur: search by predicate in the trace
- remove the "with (obj)" hack that is currently there
- introduce functions
- INTERP_RAW("x") : returns the value bound to "x" in the
......@@ -119,32 +75,22 @@ LATER
- PROG_VAL("x") = JSOF(PROG_RAW("x"))
=========================================================
LATER LATER
- Reactivate the generation of the lines of the form:
default: throw "No matching case for switch";
by having js_of_pattern return an additional boolean
indicating whether there was a default case or not.
This is needed to detect bugs in the spec where the
switch are missing useful cases.
- There is one place where we compute a "substring" in the code;
*) Alan:
There is one place where we compute a "substring" in the code;
need to check whether the argument is always nonnegative.
- Coq extraction has generated cases in the order of the definition
*) Coq extraction has generated cases in the order of the definition
of the constructors in the inductive definition; this is not the
same order as in the original coq files; we should put back in
the right order, i'm afraid we need to do this by hand.
- Investigate generation of english sentences from esprima AST
of the code of the interpreter, with live visualization of
the sentences being executed.
=========================================================
OPTIMIZATIONS
LATER-- OPTIMIZATIONS
- The representation of the heap could be optimized by
having "remove" nodes in the list describing a heap,
......@@ -157,15 +103,34 @@ OPTIMIZATIONS
they are going to be used.
=========================================================
NEVER
LATER-- FOR A BETTER ML TO JS TRANSLATION
- There is an extra tab when closing bracket for fun def
- Js_of_ast prevent use of "tag" or "type" as object field name
- generate "type: " in smart constructors [optional until display is needed]
- Reactivate the generation of the lines of the form:
default: throw "No matching case for switch";
by having js_of_pattern return an additional boolean
indicating whether there was a default case or not.
This is needed to detect bugs in the spec where the
switch are missing useful cases.
=========================================================
TRICK-- HERE IS HOW TO PRINT BROWSER STACK SIZE LIMIT:
in the console, execute:
var i=0;
function inc() {
i++;
inc();
}
inc();
then print value of "i".
=========================================================
......@@ -82,7 +82,7 @@ var source_file = 'var x = { a : 1, b : 2 }; ';
var source_file = 'x = 1;\nx = 2;\nx = 3';
var source_file = 'var x = { a : 1 };\n x.b = 2;\nx';
var source_file = 'var x = { a : { c: 1 } };\n x.a.b = 2;\nx';
var source_file = '(function (x) {\nreturn 1;\n})()';
var source_file = '(function (x) {\nreturn 1;\n})({a:{b:2}})';
// --------------- Initialization ----------------
......@@ -92,12 +92,7 @@ var source_file = '(function (x) {\nreturn 1;\n})()';
$("#source_code").val(source_file);
// --------------- Methods ----------------
function stepTo(step) {
tracer_pos = step;
updateSelection();
}
// --------------- Predicate search ----------------
// Take a predicate in form of a JavaScript code (string) and returns either true or an error message (string).
function goToPred(pred) {
......@@ -152,6 +147,10 @@ function goToPred(pred) {
return "Not found";
}
// --------------- Trace navigation buttons ----------------
function button_reach_handler() {
var pred = $("#text_condition").val();
var res = goToPred(pred);
......@@ -199,6 +198,10 @@ $("#button_finish").click(function() { finish() });
$("#button_cursor").click(function() { cursor() });
// --------------- Trace navigation methods ----------------
// Assumes tracer_files to be an array of objects with two field:
// - file, containing the name of the file,
// - contents, a string containing its source code
......@@ -207,6 +210,14 @@ function tracer_valid_pos(i) {
return (i >= 0 && i < tracer_length);
}
function stepTo(i) {
if (! tracer_valid_pos(i))
return;
tracer_pos = i;
updateSelection();
}
// dir is -1 or +1
function shared_step(dir) {
var i = tracer_pos;
......@@ -247,6 +258,7 @@ function shared_next(dir, target) {
}
}
function reset() { tracer_pos = 0; updateSelection(); }
function forward() { shared_step(+1); }
function backward() { shared_step(-1); }
......@@ -277,16 +289,14 @@ function cursor() {
};
// --------------- Auxiliary ----------------
// --------------- File Display ----------------
function get_file_extension(filename) {
var re = /(?:\.([^.]+))?$/;
return re.exec(filename)[1];
}
// --------------- Methods ----------------
// load files in CodeMirror view
var docs = {};
for (var i = 0; i < tracer_files.length; i++) {
......@@ -469,7 +479,7 @@ function string_of_mutability(mutability) {
function show_object(state, loc, target, depth) {
var t = $("#" + target);
if (depth == 0) {
if (depth < 0) {
t.append("&lt;hidden&gt;");
return;
}
......@@ -553,8 +563,8 @@ function show_decl_env_record(state, env_record_decl, target) {
var mutability = items_array[i][1][0];
var value = items_array[i][1][1];
var value_target = fresh_id();
t.append("<div id='" + value_target + "'>" + html_escape(var_name) + " (" + string_of_mutability(mutability) + "):</div>");
show_value(state, value, value_target, 1);
t.append("<div id='" + value_target + "'> &rarr; " + html_escape(var_name) + " (" + string_of_mutability(mutability) + "):</div>");
show_value(state, value, value_target, 0);
}
}
......@@ -572,16 +582,17 @@ function show_lexical_env(state, lexical_env, target) {
case "Coq_env_record_decl":
var env_record_decl = env_record.value;
var items_target = fresh_id();
t.append("<div id='" + items_target + "'></div>");
t.append("<div><b>&bull; environment-record-declaration</b>: <div style='margin-left: 1em' id='" + items_target + "'></div></div>");
show_decl_env_record(state, env_record_decl, items_target)
break;
case "Coq_env_record_object":
case "Coq_env_record_object":
var object_loc = env_record.value;
var obj_value = { tag: "Coq_value_object", value: object_loc };
var provide_this = env_record.provide_this;
var obj_target = fresh_id();
t.append("with (" + ((provide_this) ? "" : "not ") + "providing 'this'): <div id='" + obj_target + "'></div>");
show_object(state, object_loc, obj_target, 1);
t.append("<div id='" + obj_target + "'><b>&bull; environment-record-object</b> (" + ((provide_this) ? "" : "not ") + "providing 'this'): </div>");
show_value(state, obj_value, obj_target, 0);
// show_object(state, object_loc, obj_target, 1);
break;
default:
throw "invalid env_record.tag";
......@@ -594,22 +605,22 @@ function show_execution_ctx(state, execution_ctx, target) {
var t = $("#" + target);
// strictness
t.append("<div>strictness: " + execution_ctx.execution_ctx_strict + " </div>");
t.append("<div><b>strictness</b>: " + execution_ctx.execution_ctx_strict + " </div>");
// this object
var this_target = fresh_id();
t.append("<div id='" + this_target + "'>this: </div>");
t.append("<div id='" + this_target + "'><b>this:</b> </div>");
//TODO
show_value(state, execution_ctx.execution_ctx_this_binding, this_target, 0);
// lexical env
var lexical_env_target = fresh_id();
t.append("<div><div>lexical-env:</div> <div style='margin-left:0.5em' id='" + lexical_env_target + "'></div></div>");
t.append("<div><b>lexical-env:</b> <div style='margin-left: 1em' id='" + lexical_env_target + "'></div></div>");
show_lexical_env(state, execution_ctx.execution_ctx_lexical_env, lexical_env_target);
// variable env -- TODO, like above
var variable_env_target = fresh_id();
t.append("<div><div>variable-env:</div> <div style='margin-left:0.5em' id='" + variable_env_target + "'></div></div>");
t.append("<div><b>variable-env:</b> <div style='margin-left: 1em' id='" + variable_env_target + "'></div></div>");
show_lexical_env(state, execution_ctx.execution_ctx_variable_env, variable_env_target);
}
......@@ -748,8 +759,6 @@ function show_interp_ctx(state, ctx, target) {
for (var i = 0; i < a.length; i++) {
var key = a[i].key;
var val = a[i].val;
if (val.runs_type_expr !== undefined) // runs0
continue;
var targetsub = fresh_id();
t.append("<div style='margin-left:1em' id='" + targetsub + "'></div>");
$("#" + targetsub).html(html_escape(key) + ": ");
......@@ -1005,14 +1014,14 @@ function assignExtraInfosInTrace() {
function runDebug() {
reset_datalog();
JsInterpreter.run_javascript(JsInterpreter.runs, program);
JsInterpreter.run_javascript(program);
}
function run() {
reset_datalog();
var success = true;
try {
JsInterpreter.run_javascript(JsInterpreter.runs, program);
JsInterpreter.run_javascript(program);
} catch (e) {
success = false;
// alert("Error during the run");
......@@ -1076,7 +1085,7 @@ function testLineof(filename, token) {
// for easy debugging, launch at startup:
readSourceParseAndRun();
stepTo(3772);
stepTo(1700);
function showCurrent() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment