Opened 2 months ago

Closed 2 weeks ago

#5835 closed defect (fixed)

Constant eval of String() operator

Reported by: Jesper Mattsson Owned by: Jesper Mattsson
Priority: major Milestone:
Component: Modelica/FrontEnd Version: trunk
Keywords: Cc:

Description (last modified by Jesper Mattsson)

Constant evaluation of the String() operator has several problems:

  • There are no tests of it.
  • It does not take the "format" argument into account.
  • It does not use the VariableEvaluator argument when evaluating the other formatting arguments.

Fix all of those.

Edit:
During the course of this ticket, we discovered that there were additional problems with using the format argument of String(), so this ticket was expanded to cover that as well.

Change History (18)

comment:1 Changed 2 months ago by Jesper Mattsson

Resolution: fixed
Status: newclosed

r13431:

Fixed constant evaluation of String() operator, and added missing tests.

comment:2 Changed 2 months ago by Jesper Mattsson

Resolution: fixed
Status: closedreopened

comment:3 Changed 2 months ago by amartensen

r13432 Removing tests
r13441 Re-added tests that was removed in ​r13432.

comment:4 Changed 2 months ago by molsson

r13453 Fixed a bug from r13431 in TestAnnotationizer.java when using option -f.

comment:5 Changed 2 months ago by mjohnsson

r13497
Created dev branch for Jenkins test.

r13498
Address the difference between Javas formatter and the c-style like Modelica Formatting rules.
Key difference is the complete lack of converting between types.

Modelica Spec comparing:
Format string: According to ANSI-C the format string specifies one conversion specifier (excluding the leading %), may not contain length modifiers, and may not use "*" for width and/or precision.

For all numeric values the format specifiers f, e, E, g, G are allowed.
!Java: All these only for float or double

For integral values it is also allowed to use the d, i, o, x, X, u, and c-format specifiers (for non-integral values a tool may round, truncate or use a different format if the integer conversion characters are used).
! Java: May not be float or double.

Only s specifier accepts all types.

Last edited 2 months ago by mjohnsson (previous) (diff)

comment:6 Changed 2 months ago by mjohnsson

r13502
Fixes for Format specifiers in Error messages.

r13503
Improving the error check and error messages slightly.

comment:7 Changed 2 months ago by mjohnsson

r13512 Added needed type casts needed for Java Formatter to match Modelica spec (ASCI C) formats handling. Handling Format specifiers.

comment:8 Changed 6 weeks ago by Jesper Mattsson

r13702:

  • Added formalized parsing of format strings to allow error checking and required casts.
  • Fixed errors in C code gen for String() operator.
  • Made format string structural parameter.

comment:9 Changed 6 weeks ago by Jesper Mattsson

r13714:

Updated error message for variability of format argument of String, and added additional tests.

comment:10 Changed 4 weeks ago by Jesper Mattsson

Resolution: fixed
Status: reopenedclosed

r13861:

Allowed format strings including the initial % (with a warning), and added unit tests of CFormatSpecifier.

comment:11 Changed 4 weeks ago by Jesper Mattsson

Description: modified (diff)

comment:12 Changed 4 weeks ago by Jesper Mattsson

Resolution: fixed
Status: closedreopened

Still needs merge to trunk after review.

comment:13 Changed 3 weeks ago by Jesper Mattsson

r13871:

Updates after review.

comment:14 Changed 3 weeks ago by Jesper Mattsson

r13896:

Catch-up merge from trunk.

comment:15 Changed 3 weeks ago by Jesper Mattsson

r13897:

Merged to trunk.

comment:16 Changed 2 weeks ago by Jesper Mattsson

r13944:

Added a try-catch for a missed possible ConstantEvaluationException.

comment:17 Changed 2 weeks ago by Jesper Mattsson

r13945:

Removed old working branch.

comment:18 Changed 2 weeks ago by Jesper Mattsson

Resolution: fixed
Status: reopenedclosed
Note: See TracTickets for help on using tickets.