Changeset 13871


Ignore:
Timestamp:
Oct 28, 2019 2:19:27 PM (2 weeks ago)
Author:
Jesper Mattsson
Message:

Updates after review. (#5835)

Location:
branches/dev-mj-5835/Compiler
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/dev-mj-5835/Compiler/ModelicaCBackEnd/src/jastadd/CCodeGen/CCodeGenExpressions.jrag

    r13702 r13871  
    884884    }
    885885
    886     protected Iterable<ASTNode> FStringExp.childrenToGenFor_C() {
     886    private Iterable<ASTNode> FStringExp.childrenToGenFor_C() {
    887887        // We want to generate for NTA CFormat but not for child Format.
    888888        return new TransformerIterable<ASTNode, ASTNode>(this) {
     
    10231023            str.print(", JMI_TRUE, \"true\", \"false\")");
    10241024        } else {
    1025             if (format != null && format.expectedType.isUnsigned()) {
    1026                 str.print("(unsigned int) ");
    1027             } else if ((format == null) ? t.isInteger() : format.expectedType.isInteger()) {
    1028                 str.print("(int) ");
     1025            if (format != null) {
     1026                if (format.expectedType.isUnsigned()) {
     1027                    str.print("(unsigned int) ");
     1028                } else if (format.expectedType.isInteger()) {
     1029                    str.print("(int) ");
     1030                }
     1031            } else {
     1032                if (t.isInteger()) {
     1033                    str.print("(int) ");
     1034                }
    10291035            }
    10301036            p.print(this, str, indent);
     
    10391045            format = formatSpecifier();
    10401046        } catch (ConstantEvaluationException e) {
    1041             // Assume that we don't have a format that converts real -> integer.
     1047            // Assume that we don't have a format that converts real -> integer,
     1048            // and just go by the type.
     1049            format = null;
    10421050        }
    10431051        getValue().genStringParts_C(p, str, indent, format);
  • branches/dev-mj-5835/Compiler/ModelicaFlatTree/src/jastadd/FlatAPI/FlatAPI.jrag

    r13861 r13871  
    44734473        // TODO: To save memory, this could be solved in the C code generation instead.
    44744474        if (hasFormat()) {
    4475             boolean hasPercent = formatSpecifier().initialPercent;
    44764475            FExp fmt = getFormat();
    44774476            FExp exp = fmt.treeCopy();
  • branches/dev-mj-5835/Compiler/ModelicaFrontEnd/src/jastadd/errorcheck/ComplianceCheck.jadd

    r13714 r13871  
    284284    public static final SimpleProblemProducer ASTNode.UNSUPPORTED_NON_FIXED_STRING_ARGUMENT =
    285285            new SimpleErrorProducer("UNSUPPORTED_NON_FIXED_STRING_ARGUMENT", ProblemKind.COMPLIANCE,
    286                     "Argument %s of String operator is only supported as a fixed parameter expression.");
     286                    "Argument format of String operator is only supported as a fixed parameter expression.");
    287287
    288288    public void FStringExp.complianceCheck(ErrorCheckType checkType) {
     
    291291            getFormat().markAsStructuralParameter(checkType);
    292292            if (!getFormat().variability().parameterOrLess())
    293                 UNSUPPORTED_NON_FIXED_STRING_ARGUMENT.invoke(getFormat(), "format");
     293                UNSUPPORTED_NON_FIXED_STRING_ARGUMENT.invoke(getFormat());
    294294        }
    295295    }
  • branches/dev-mj-5835/Compiler/ModelicaFrontEnd/src/java/org/jmodelica/util/values/CFormatSpecifier.java

    r13861 r13871  
    88 * Describes a printf-style format specifier, parsed and separated into fields.
    99 *
    10  * All int fields use a negative value to denote that it was not given.
     10 * For the fields with and precision, a negative value means that is was not given when
     11 * constructing the specifier.
    1112 */
    1213public class CFormatSpecifier {
  • branches/dev-mj-5835/Compiler/ModelicaFrontEnd/test/junit/org/jmodelica/test/common/TestCFormatSpecifier.java

    r13861 r13871  
    44import static org.junit.Assert.assertTrue;
    55import static org.junit.Assert.assertFalse;
     6import static org.junit.Assert.assertNull;
    67
    78import org.jmodelica.util.values.CFormatSpecifier;
     
    3536        assertFalse(fmt.hasError());
    3637        assertFalse(fmt.hasWarning());
    37         assertEquals(fmt.errorMessage(), null);
     38        assertNull(fmt.errorMessage());
    3839    }
    3940
     
    6263        assertFalse(fmt.hasError());
    6364        assertFalse(fmt.hasWarning());
    64         assertEquals(fmt.errorMessage(), null);
     65        assertNull(fmt.errorMessage());
    6566    }
    6667
     
    175176        assertFalse(fmt.hasError());
    176177        assertFalse(fmt.hasWarning());
    177         assertEquals(fmt.errorMessage(), null);
     178        assertNull(fmt.errorMessage());
    178179    }
    179180
     
    202203        assertFalse(fmt.hasError());
    203204        assertFalse(fmt.hasWarning());
    204         assertEquals(fmt.errorMessage(), null);
     205        assertNull(fmt.errorMessage());
    205206    }
    206207
     
    229230        assertFalse(fmt.hasError());
    230231        assertFalse(fmt.hasWarning());
    231         assertEquals(fmt.errorMessage(), null);
     232        assertNull(fmt.errorMessage());
    232233    }
    233234
Note: See TracChangeset for help on using the changeset viewer.