JavaScript/HTML code generation: follow-up improvements
We are adding JavaScript code generation in #272 (closed). This issue concerns follow-ups:
-
Not/partially supported features (support them or add precondition checks, and document preconditions): -
fmt
does not yet support all format patterns:-
Issue probably covered by other points: riklubking/escet#29 -
First noted problems with fmt
: !686 (comment 1294139) -
General todo about fmt
: !686 (comment 1294137) -
What is still missing: !716 (comment 1518984) -
.
bug: !716 (comment 1519655) (!727 (merged)) -
.Xf
withX
multiple numbers bug: !716 (comment 1519657) (!727 (merged)) -
Hexadecimal format bug: !716 (comment 1519658) (!727 (merged)) -
g
/G
/e
/E
bug: !716 (comment 1519660) -
e
vsE
etc bug: !716 (comment 1519661) -
Capture group for %...f
bug: !716 (comment 1519662) (!727 (merged)) -
Why is bool
handled in special way: !716 (comment 1519659) (!727 (merged)) -
... and other comments in !716 (closed) about the fmt
function in theutils.txt
template.
-
-
SVG copy/move declarations are not yet supported. They are also not removed, no warnings are printed for them, and they may give precondition violations due to unsupported expressions, etc. See !716 (comment 1519931). (!748 (merged)) -
For print declarations the target is ignored and assumed to be stdout. The :stderr
and file targets thus don't work properly. Also, for:stderr
, the output should be in red. See !710 (comment 1474695). (!747 (merged))
-
-
Functionality/correctness: -
Fix print declarations: (!747 (merged)) -
There is now an empty line between state printing and print declaration post prints. Do the empty line after post prints instead. Similarly for initial state and initial prints. It should be clear what belongs to what. -
Too many times pre/post in initial state. See test model: issue715_html_test_print.cif -
Escapes don't work properly ( \"
becomes%22
, for instance). See test model: issue715_html_test_print.cif -
No need for \r
, only\n
is enough, for HTMLtextarea
.
-
-
Check whether equality comparison (tuples, Utils.objEquals
, etc) satisfies CIF semantics. See !710 (comment 1476565). (!725 (merged)) -
Improve exception handling in the generated code / templates, reporting it to the console. See !716 (comment 1519945). -
realToStr
in utilities template does not produce output in CIF syntax. See !686 (comment 1294138) and riklubking/escet#29. -
Synchronous/asynchronous handling of user clicks. To be investigated. See !716 (comment 1520603). -
SVG presentation attributes vs CSS style attributes. How to determine them and set them properly. See !716 (comment 1519943). -
SVG output mapping does not always produce string typed values currently, as it does not use runtimeToString
like the CIF simulator. Is this a problem? See !716 (comment 1519946). -
SVG output mapping for text nodes may be different currently than in the CIF simulator. Check this. See !716 (comment 1519947). -
All variable references are generated in the same way, accessing them as fields of the main class. For state variables, this is fine. For temporary variables, local variables and parameters of functions, etc, this is wrong: -
For temporary variables. See #715 (comment 1525082). (!733 (merged)) -
For local variables and parameters of functions. See !716 (comment 1519651). (!745 (merged)) -
Check all other places where we generate variables. (!745 (merged))
-
-
Event names are not logged, but the indices. (!721 (merged)) -
Something is visible between 'Download log' and 'Hide' buttons. The 'Download log' button does not function correctly. (!723 (merged)) -
Check that click listeners are not re-added when the execution in the browser is reset. -
The code generated for the specific model may use the same names as code that is always present. We need to prevent name conflicts. -
Testing -
Make the CIF code generator tests also test JS/HTML targets. (!1059 (merged)) -
Add additional tests for what is not yet covered.
-
-
Utilities class is missing intToReal
function. (!732 (merged)) -
Calls to functions from JavaScriptRealTypeInfo.STANDARD_FUNCTIONS
don't get a proper prefix, and thus crash. (!738 (merged)) -
JavaScriptCodeGen.performAssign
usesgetReadVarInfo
forcontainerInfo
, while it is writing to the container. May also affect other targets. -
For HTML code generation, input variables have no values, and accessing them leads to crashes. -
Tuples don't work, as shown by this test model: issue715_html_test_tuple.cif (!746 (merged)) -
There is no object equality in JS: -
Search for object equality
in comments. -
Reconsider equalsObj
utility method. -
Check JavaScript*TypeInfo
classes.
-
-
There is no Integer
vsint
difference like in Java:-
Check JavaScriptIntTypeInfo
'sconvertIntNegate
,convertAddition
,convertSubtraction
,convertDiv
,convertMod
,convertMultiplication
. -
Check JavaScript*TypeInfo
classes.
-
-
For SVG input mappings we currently use boolean variables as additional guards for events, to disallow them until clicked. The CIF simulator uses a single queue for all clicks, so that multiple clicks in quick successing can be processed, rather than our boolean toggling, which only allows one click at a time and discards any consecutive clicks until the first is processed, and to preserve the order of the clicks. See !716 (comment 1521660). Also, if objects are clicked, but a guard prevents the event, the click is remembered until the event is enabled later on. This means the order of clicks is not preserved. (!784 (merged)) -
CSS styling in generated HTML pages for hovering over interactive SVG input elements is not specific enough in case multiple SVG images contain an element with the same id. (!784 (merged)) -
Code generated for JS contains HTML/SVG-related parts. At the very least comments of empty sections. Check what should be generated for JS/HTML. -
SVG copy/move issues: -
Moved objects may not be position exactly at the right position. See !748 (comment 1527081). -
Copy and move are missing the runtime error checks.
-
-
Constants defined in terms of other constants give a TypeError
. See #715 (comment 1611585). (!766 (merged)) -
Element IDs need to be escaped when used in CSS selectors. See #715 (comment 2137124). (!869 (merged)) -
CIF 'tank' example model crashes. If we change edge when tank.V <= 2
toedge when tank.V <= 0.2
, generate HTML and run it, it crashes withtank.html:1597 Error: <rect> attribute height: A negative value is not valid. ("-1.824264209557593") / updateUI @ tank.html:1597.
andtank.html:1039 Uncaught tankException message: "Invalid operation: sqrt(-0.24323522794101238)."
-
-
Options: -
JavaScript and HTML targets. For HTML target, generate a single file. See !716 (comment 1522167). (!723 (merged)) -
Empty option category. See riklubking/escet#27 (comment 1219900). (!723 (merged))
-
-
-
Documentation: -
Check and improve documentation (correctness, content, style, etc). (!726 (merged)) -
Explain resizing the lower area. (!730 (merged)) -
Explain default transition/state logging in JS docs. -
Replace final C89 naming by JavaScript in JS docs. (!762 (merged))
-
-
Code cleanup (for generator, generated code and templates): -
Do a pass over !716 (closed) to improve small things. (!716 (closed) / !721 (merged)) -
Improve JavaDoc/comments. (!716 (closed) / !721 (merged)) -
Improve exception handling in code generator. (!716 (closed) / !721 (merged)) -
Move any HTML/CSS/JS generation out of Java code and into templates, where possible. -
Double check that all HTML, CSS, JS in templates is needed. -
The execEvent*
methods use edge indices rather than event indices. Would be better to use event indices. See #715 (comment 1523083). Applies not only to JS/HTML output. -
Inconsistent use of eventId
andeventIdx
inJavaScriptCodeGen
. (!724 (merged)) -
Remove optimized code for empty arrays in JavaScriptArrayTypeInfo
.
-
-
Other improvements / nice to have features: -
Allow disabling state logging in generated HTML pages. (!841 (merged)) -
Don't generate an enum when not needed. See #700. -
Templates have JSDoc type hints, but generated code does not. Could add it. See !710 (comment 1474651). -
Generate trace files that capture a browser execution, for replay in the CIF simulator. See #703, #704 and #705. -
Allow SVGs in the browser to be besides each other rather than under each other. -
Consider making HTML the default target for the code generator. -
Allow to disable log panel scroll-lock. Currently, log scrolls when new entries are added. See #715 (comment 1525016). -
Log state to console after taking an event transition, to ease debugging of the generated JS/HTML code. (!737 (merged)) -
'Eclipse ESCET' is part of the generated HTML page titles. Is that desired? It is generated by Eclipse ESCET, not part of Eclipse ESCET. -
Include the version of the generator in the generated HTML, such that we can trace that back in case of issues. -
Consider coloring the page blue instead of yellow, as it is generated by CIF, not ESCET in general. Probably should use the CIF website blue color, with 12.5% opacity, like on the CIF website. -
The log pane buttons now have text. Instead of the Show/Hide texts, could use Unicode symbols 'U+25B2 BLACK UP-POINTING TRIANGLE' and 'U+25BC BLACK DOWN-POINTING TRIANGLE'. See https://symbl.cc/en/25B2/ and https://symbl.cc/en/25BC/. Could also use Bootstrap icons. Applies to other buttons, like settings and download as well.
-
Edited by Dennis Hendriks