diff --git a/esprima-to-ast.js b/esprima-to-ast.js index 9ea27a006397feca635cfaa0594185e1e40f8d4e..4cfa64d48f57dac715297a80b3d2eabed23affde 100644 --- a/esprima-to-ast.js +++ b/esprima-to-ast.js @@ -1,3 +1,5 @@ +//https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/Parser_API + function esprimaToAST(prog) { var toList = function (array) { var r = {tag: "[]"}; diff --git a/generator/Makefile b/generator/Makefile index b3faa2fbb33b087b21bacab3e05b1a492d11efbb..c30c0e606636ea0970a3d2f4b8b1b83955b89c00 100644 --- a/generator/Makefile +++ b/generator/Makefile @@ -40,14 +40,14 @@ ASSEMBLY_JS := \ JsNumber.log.js \ JsSyntax.log.js \ JsSyntaxAux.log.js \ - Translate_syntax.js \ + Translate_syntax.js \ List0.log.js \ JsSyntaxInfos.log.js \ JsCommon.log.js \ JsCommonAux.log.js \ JsPreliminary.log.js \ JsInit.log.js \ - Prheap.js \ + Prheap.js \ LibTactics.log.js \ LibProd.log.js \ LibFunc.log.js \ diff --git a/generator/TODO b/generator/TODO index ac37fbd4f031b8adb04df7160815813e7e80053f..8aae88fe9b2bd4be2bae3d120429c465717ebdd4 100644 --- a/generator/TODO +++ b/generator/TODO @@ -1,66 +1,88 @@ - - ========================================================= FIRST +[Thomas] - remove intermediate folder "miniml" in "../jsjsref/miniml/.." -- include a local copy of esprima so that one can work offline +- include a local copy of esprima so that we can work offline + +- remove stdlib_js/* => probably drop it ========================================================= ARTHUR +- remove "open JsNumber" to more easily trace occurences + +- generate "type: " in smart contsructors + - generate the escaped source code - control which file should feature logging -========================================================= -NEXT - -- introduce testing functions called: - - test_exec("code") -> parse, convert, build trace, log trace +- lineof_temp["5"] => 5 should be int +[arthur will do a first pass] - clean up stdlib.ml +- implement stdlib.js - remove unused functions - sort out remaining ones - -- implement stdlib.js - need to have one function for each one of stdlib.ml - number related functions are implemented with JS counterpart directly + JsNumber.ml should be replaced by JsNumber.mli (we might want to keep + JsNumber.ml for future use, though), and we implement by hand JsNumber.js, + which would then be included directly in assembly.js. + - Int32 and Int64 implem [alan] directly in JS -- 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. +========================================================= +NEXT + +[thomas, biggest piece, ask if anything problematic] - fill in the "esprima-to-ast.js" file, following the template (throw an exception, caught and displayed as an alert message, in case the source program uses for-in). +- update the code that translates esprima syntax to recognize + "use strict" directives, which come as first statement of + a body, in hte form of a raw expression of raw type "use script". + (look on the web for code that already does this for esprima). + +[alan or thomas] +- figure out what to do for Parser_syntax Parser_main -- 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. -- test a compound example, e.g.: +[our goal is to build trace for] +- 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 (true) {} + 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 + +[second biggest, only once we manage to build the trace] +- 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. ========================================================= LATER -- update the code that translates esprima syntax to recognize - "use strict" directives, which come as first statement of - a body, in hte form of a raw expression of raw type "use script". - (look on the web for code that already does this for esprima). +[thomas] +- bigger test262 testing. +[thomas and alan] - set up the call to the appropriate function for propagating the "strictness" info in the AST. @@ -75,6 +97,7 @@ LATER - explain that currently JS files are generated from ML files and thus should not be edited, although this might change in the future. + - assembly.js should have a header - full display of heap information add a "+details" button @@ -93,6 +116,11 @@ LATER - INTERP_VAL("x") = JSOF(INTERP_RAW("x")) - 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 @@ -100,10 +128,6 @@ LATER This is needed to detect bugs in the spec where the switch are missing useful cases. - -========================================================= -LATER LATER - - There is one place where we compute a "substring" in the code; need to check whether the argument is always nonnegative. diff --git a/generator/stdlib_ml/stdlib.mli b/generator/stdlib_ml/stdlib.mli index 4cf6a3b7568689e2bd7a5b50f3ca8f8dde0f35aa..f34242fb35757c0141540ada1d924b361ddb4187 100644 --- a/generator/stdlib_ml/stdlib.mli +++ b/generator/stdlib_ml/stdlib.mli @@ -54,11 +54,14 @@ val ( > ) : 'a -> 'a -> bool val ( <= ) : 'a -> 'a -> bool val ( >= ) : 'a -> 'a -> bool *) + +(* no need to implement those in stdlib.js because JS has them already *) val ( = ) : float -> float -> bool val ( < ) : float -> float -> bool val ( > ) : float -> float -> bool val ( <= ) : float -> float -> bool val ( >= ) : float -> float -> bool + (*val compare : 'a -> 'a -> int*) val bool_eq : bool -> bool -> bool @@ -103,11 +106,13 @@ val ref : 'a -> 'a ref val (:=) : 'a ref -> 'a -> unit val (!) : 'a ref -> 'a -(* Coq extraction builtins refer directly to Pervasives at times *) + +(* no longer needed it seems *) module Pervasives : sig val succ : int -> int end +(* should not be needed if we do'nt use JsNumber.ml *) module Int32 : sig val logand : int32 -> int32 -> int32 val lognot : int32 -> int32 @@ -120,17 +125,18 @@ module Int32 : sig val to_float : int32 -> float end -module Int64 : sig +(* should not be needed if we do'nt use JsNumber.ml *) +module Int64 : sig val one : int64 val float_of_bits : int64 -> float end -module List : sig +module List : sig (* should rely on List0 instead *) val map : ('a -> 'b) -> 'a list -> 'b list val rev : 'a list -> 'a list end -module String : sig +module String : sig (* should rely on String0 instead *) val length : string -> int val append : string -> string -> string val sub : string -> int -> int -> string @@ -149,7 +155,7 @@ val prerr_newline : unit -> unit val prerr_endline : string -> unit -module Parser_syntax : sig (* ARTHUR: to implement *) +module Parser_syntax : sig (* needed by translate_syntax.mli and by parser_main (below) *) type unary_op type arith_op type bin_op @@ -168,10 +174,12 @@ end *) -module Obj : sig +module Obj : sig (* should not be needed *) type t end -val print_endline : string -> unit +(* only used for debug*) + +val print_endline : string -> unit val __LOC__ : string diff --git a/navig-driver.js b/navig-driver.js index 977622ae84e43c9a989177319682d05a8cdd7dad..105029281311e0322467c6c25f1133f64352cf3c 100644 --- a/navig-driver.js +++ b/navig-driver.js @@ -484,6 +484,7 @@ var parsedTree; } function run() { + // TODO:parse JsInterpreter.run_javascript(JsInterpreter.runs, program); assignSourceLocInTrace(datalog); tracer_items = datalog;