Changeset 13628


Ignore:
Timestamp:
Oct 1, 2019 12:54:19 PM (2 months ago)
Author:
Jonathan Kämpe
Message:

#5844 Merge from trunk

Location:
branches/dev-jk-2471
Files:
19 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/dev-jk-2471

  • branches/dev-jk-2471/Compiler/ModelicaFlatTree/src/jastadd/ConstantEvaluation/ConstantEvaluation.jrag

    r13512 r13628  
    28182818            if (formatChar == 'u') {
    28192819                String formatCorrect = format.substring(0, format.length()-1) + "s";
    2820                 return new CValueString(String.format((Locale) null, formatCorrect, Integer.toUnsignedLong(cval.intValue())));
     2820                long unsigned = ((long) cval.intValue()) & 0xffffffffL; // Java 8 Integer.toUnsignedLong
     2821                return new CValueString(String.format((Locale) null, formatCorrect, unsigned));
    28212822            }
    28222823
     
    49884989    public class VariableEvaluator {
    49894990        public static final VariableEvaluator instance = new VariableEvaluator(true);
    4990         private boolean externalEvaluationEnabled;
     4991        private final boolean externalEvaluationEnabled;
    49914992       
    49924993        public VariableEvaluator(boolean externalEvaluationEnabled) {
  • branches/dev-jk-2471/Compiler/ModelicaFlatTree/src/jastadd/FlatAPI/FlatAPI.jrag

    r13456 r13628  
    23682368    inh FClass FFunctionDecl.myFClass();
    23692369    inh FClass FRecordDecl.myFClass();
     2370    inh FClass FDerivedType.myFClass();
     2371    inh FClass FEnumDecl.myFClass();
    23702372    inh FClass FAlgorithm.myFClass();
    23712373    inh FClass FAbstractEquation.myFClass();
  • branches/dev-jk-2471/Compiler/ModelicaFlatTree/src/jastadd/FlatUtil.jrag

    r13456 r13628  
    16891689     
    16901690
    1691     public String FClass.nextTempFuncName() {
    1692         String name;
    1693         do {
    1694             name = "temp_" + nextTempFuncIndex++;
    1695         } while (lookupFunc(name) != null);
    1696         return name;
    1697     }
    1698     private int FClass.nextTempFuncIndex = 1;
    1699 
    1700 
    17011691    /**
    17021692     * Creates new temporary variables with the given name.
  • branches/dev-jk-2471/Compiler/ModelicaFlatTree/src/jastadd/PrettyPrint.jrag

    r13357 r13628  
    11391139        getParameterEquations().prettyPrintWithFix(p, str, nextInd, "", ";" + str.getLineEnder());
    11401140   
     1141        prettyPrintEquations(p, str, indent);
     1142       
     1143        if (getNumFFunctionDecl() > 0 || getNumFRecordDecl() > 0 ||
     1144                getNumFEnumDecl() > 0 || getNumFDerivedType() > 0) {
     1145            str.println();
     1146            str.formatln("%spublic", indent);
     1147            p.print(getFFunctionDecls(), str, nextInd);
     1148            p.print(getFRecordDecls(), str, nextInd);
     1149            p.print(getFEnumDecls(), str, nextInd);
     1150            p.print(getFDerivedTypes(), str, nextInd);
     1151        }
     1152       
     1153        getFAttributeList().prettyPrintFAnnotationAttributeList(str, p, indent, ";" + str.getLineEnder());
     1154
     1155        str.println(indent, "end ", name(), ";");
     1156    }
     1157   
     1158    public void FClass.prettyPrintEquations(Printer p, CodeStream str, String indent) {
    11411159        boolean wroteEquation = false;
    1142         for (FAbstractEquation e : getFAbstractEquations()) {
     1160        String nextInd = p.indent(indent);
     1161        for (FAbstractEquation e : equationsForPrinting()) {
    11431162            if (e instanceof FAlgorithm) {
    11441163                p.print(e, str, indent);
     
    11551174            }
    11561175        }
    1157        
    1158         if (getNumFFunctionDecl() > 0 || getNumFRecordDecl() > 0 ||
    1159                 getNumFEnumDecl() > 0 || getNumFDerivedType() > 0) {
    1160             str.println();
    1161             str.formatln("%spublic", indent);
    1162             p.print(getFFunctionDecls(), str, nextInd);
    1163             p.print(getFRecordDecls(), str, nextInd);
    1164             p.print(getFEnumDecls(), str, nextInd);
    1165             p.print(getFDerivedTypes(), str, nextInd);
    1166         }
    1167        
    1168         getFAttributeList().prettyPrintFAnnotationAttributeList(str, p, indent, ";" + str.getLineEnder());
    1169 
    1170         str.println(indent, "end ", name(), ";");
     1176    }
     1177   
     1178    public Iterable<FAbstractEquation> FClass.equationsForPrinting() {
     1179        return getFAbstractEquations();
    11711180    }
    11721181
     
    13181327
    13191328    public void FDerivedType.prettyPrint(Printer p, CodeStream str, String indent) {
     1329        prettyPrintWithName(p, str, indent, getName());
     1330    }
     1331   
     1332    private void FDerivedType.prettyPrintWithName(Printer p, CodeStream str, String indent, String name) {
    13201333        if (!getBaseType().isEnum()) {
    1321             str.print(indent, "type ", getName(), " = ", getBaseType());
     1334            str.print(indent, "type ", name, " = ", getBaseType());
    13221335            getFAttributeList().prettyPrintFAttributeList(str, p);
    13231336            str.println(";");
     
    22032216        getParameterEquations().prettyPrintWithFix(p, str, nextInd, "", ";" + str.getLineEnder());
    22042217    */
    2205         boolean wroteEquation = false;
    2206         for (FAbstractEquation e : getFAbstractEquations()) {
    2207             if (e instanceof FAlgorithm) {
    2208                 p.print(e, str, indent);
    2209                 wroteEquation = false;
    2210             } else {
    2211                 if (!e.isIgnored()) {
    2212                     if (!wroteEquation) {
    2213                         str.println(indent, "equation");
    2214                         wroteEquation = true;
    2215                     }
    2216                     p.print(e, str, nextInd);
    2217                     str.println(";");
    2218                 }
    2219             }
    2220         }
     2218        prettyPrintEquations(p, str, indent);
    22212219               
    22222220        str.println(indent, "end ", nameUnderscore(), ";");
  • branches/dev-jk-2471/Compiler/ModelicaFlatTree/src/jastadd/ast/FlatModelica.ast

    r13357 r13628  
    699699 * LibTopPackagePath is the file path of the package file of the library that this external statement originated from.
    700700 */
    701 FExternalStmt : FStatement ::= FExternalLanguage [ReturnVar:CommonAccessExp] <Name> Arg:FExp* <LibTopPackagePath>;
     701FExternalStmt : FStatement ::= FExternalLanguage [ReturnVar:CommonAccessExp] <Name> Arg:FExp* <LibTopPackagePath> FAttribute*;
    702702
    703703/**
  • branches/dev-jk-2471/Compiler/ModelicaFrontEnd/src/jastadd/flattening/Flattening.jrag

    r13491 r13628  
    776776        stmt.setLibTopPackagePath(scd == null ? "" : scd.myLibRootPath().toAbsolutePath().toString()); // scd is null for builtins
    777777        stmt.setFExternalLanguage(hasFExternalLanguage() ?
    778                 (FExternalLanguage) getFExternalLanguage().fullCopy() :
     778                getFExternalLanguage().treeCopy() :
    779779                new FCExternalLanguage());
    780780        stmt.extractLibrary(this);
     
    830830                new Opt<CommonAccessExp>();
    831831               
    832         FExternalStmt stmt = new FExternalStmt(getFExternalLanguage().treeCopy(), ret, getName(), args, getLibTopPackagePath());
     832        FExternalStmt stmt = new FExternalStmt(getFExternalLanguage().treeCopy(), ret, getName(), args, getLibTopPackagePath(), new List<FAttribute>());
    833833        stmt.extractLibrary(this);
    834834        sl.add(stmt);
     
    21582158            List<FAttribute> attrs, AttributeExpRetriever aer, boolean cls) {}
    21592159
    2160     syn boolean InstComponentDecl.isBuiltIn() = false;
    2161     eq InstBuiltIn.isBuiltIn()                = true;
    2162     syn boolean InstBuiltInClassDecl.isBuiltIn()                = true;
    2163     syn boolean SrcBuiltInClassDecl.isBuiltIn()       = true;
    2164     syn boolean SrcClassDecl.isBuiltIn() = ((SourceRoot) root()).getProgram().getBuiltInTypes().hasChild(this)
    2165             || ((SourceRoot) root()).getProgram().getBuiltInFunctions().hasChild(this);
    2166    
    2167     public boolean List.hasChild(ASTNode node) {
    2168         for(ASTNode child : children) {
    2169             if(child == node) {
    2170                 return true;
    2171             }
    2172         }
    2173         return false;
    2174     }
    2175    
    2176 
     2160    syn boolean InstComponentDecl.isBuiltIn()    = false;
     2161    eq InstBuiltIn.isBuiltIn()                   = true;
     2162    syn boolean InstBuiltInClassDecl.isBuiltIn() = true;
     2163    syn boolean SrcBuiltInClassDecl.isBuiltIn()  = true;
     2164    inh boolean SrcClassDecl.isBuiltIn();
     2165    eq Root.getChild().isBuiltIn() = false;
     2166    eq Program.getBuiltInType().isBuiltIn() = true;
     2167    eq Program.getBuiltInFunction().isBuiltIn() = true;
     2168   
     2169    syn SourceRoot Root.asSourceRoot() {
     2170        throw new UnsupportedOperationException("Method not implemented for class " + getClass().getSimpleName() + "!");
     2171    }
     2172    eq SourceRoot.asSourceRoot() = this;
     2173   
    21772174    public void InstComponentModification.collectAttributes(Flattener f,
    21782175            List<FAttribute> attrs, AttributeExpRetriever aer, boolean cls) {
     
    34023399    /**
    34033400     * Class used during instantiation of equations and flattening of variables
    3404      * to delecate to different contributors. This class is subtyped for each
    3405      * contributor!
     3401     * to delegate to different contributors. This class is subtyped for each
     3402     * contributor.
    34063403     */
    34073404    public abstract class AttributeContributor {
  • branches/dev-jk-2471/Compiler/ModelicaFrontEnd/src/jastadd/instance/InstLookupClasses.jrag

    r13317 r13628  
    258258
    259259    syn lazy HashMap<String,SrcLibNode> InstProgramRoot.libraryMap() {
    260         Program prog = ((SourceRoot) root()).getProgram();
     260        Program prog = root().asSourceRoot().getProgram();
    261261        HashMap<String,SrcLibNode> map = new HashMap<String,SrcLibNode>(prog.getNumSrcLibNode() * 4 / 3 + 1);
    262262        for (SrcLibNode ln : prog.getSrcLibNodes()) {
  • branches/dev-jk-2471/Compiler/ModelicaFrontEnd/src/jastadd/instance/InstLookupComponents.jrag

    r13476 r13628  
    2727         */
    2828        public static <T extends Item> InstLookupResult<T> InstLookupResult.notFound() {
    29             return (InstLookupResult<T>) NOT_FOUND;
     29            return NOT_FOUND;
    3030        }
    3131
  • branches/dev-jk-2471/Compiler/ModelicaFrontEnd/src/jastadd/instance/InstanceTree.jrag

    r13491 r13628  
    18071807    }
    18081808    public List<InstComponentDecl> InstLibNode.getInstComponentDeclList() {
    1809         throw new UnsupportedOperationException();
     1809        return resolveLib().getInstComponentDeclList();
    18101810    }
    18111811
     
    18141814    }
    18151815    public List<InstClassDecl> InstLibNode.getInstClassDeclList() {
    1816         throw new UnsupportedOperationException();
     1816        return resolveLib().getInstClassDeclList();
    18171817    }
    18181818
     
    18211821    }
    18221822    public List<InstExtends> InstLibNode.getInstExtendsList() {
    1823         throw new UnsupportedOperationException();
     1823        return resolveLib().getInstExtendsList();
    18241824    }
    18251825
     
    18281828    }
    18291829    public List<InstImport> InstLibNode.getInstImportList() {
    1830         throw new UnsupportedOperationException();
     1830        return resolveLib().getInstImportList();
    18311831    }
    18321832
     
    18351835    }
    18361836    public List<InstClassDecl> InstLibNode.getRedeclaredInstClassDeclList() {
    1837         throw new UnsupportedOperationException();
     1837        return actualInstClass().getRedeclaredInstClassDeclList();
    18381838    }
    18391839
  • branches/dev-jk-2471/Compiler/ModelicaFrontEnd/src/jastadd/instance/Types.jrag

    r13476 r13628  
    6868   
    6969    syn boolean SrcBaseNode.isPrimitiveType() = false;
    70     eq SrcClassDecl.isPrimitiveType() = isPrimitive();
     70    eq SrcClassDecl.isPrimitiveType()         = isPrimitive();
    7171
    7272    public static String InstNode.subTypeMessage(String name, String message) {
  • branches/dev-jk-2471/Compiler/ModelicaFrontEnd/src/jastadd/source/Library.jrag

    r13354 r13628  
    475475        // We should figure out if using a non-file name is really needed as load description,
    476476        // and if not - get rid of otherDesc.
    477         private Path path;
     477        private final Path path;
    478478        private final String otherDesc;
    479479
  • branches/dev-jk-2471/Compiler/ModelicaFrontEnd/src/jastadd/source/PredefinedTypes.jrag

    r12975 r13628  
    4141     * Some differences apply however. The types of predefined types must
    4242     * be looked up only amongst the built-in types. Also, there are no
    43      * component accesses that needs to be looked up predefined types.
     43     * component accesses that need to be looked up for predefined types.
    4444     * The predefined types are defined in the (list) non terminal attribute
    4545     * PredefinedType.
  • branches/dev-jk-2471/Compiler/ModelicaFrontEnd/src/jastadd/source/SourceTraversal.jrag

    r13294 r13628  
    9090    syn Iterable<SrcComponentDecl> SrcEnumClassDecl.componentsIterable() = super.components();
    9191    syn SrcEnumClassDecl SrcEnumClassDecl.enumBase() =
    92         ((SourceRoot) root()).getProgram().getEnumBaseDecl();
     92        root().asSourceRoot().getProgram().getEnumBaseDecl();
    9393   
    9494    syn Iterable<SrcModificationOrRedeclareElement> SrcClassDecl.elementModifications();
  • branches/dev-jk-2471/Compiler/ModelicaFrontEnd/src/jastadd/util/Annotations.jrag

    r13294 r13628  
    9191    public class FClass            implements FAttributeListAnnotationNode.FAttributeList {}
    9292    public class FAttribute        implements FAttributeListAnnotationNode.FAttributeList {}
     93    public class FExternalStmt     implements FAttributeListAnnotationNode.FAttributeList {}
    9394   
    9495    eq FFunctionDecl.annotation(InstContext instContext)     = new FAttributeListAnnotationNode(this, instContext);
     
    9697    eq FAbstractEquation.annotation(InstContext instContext) = new FAttributeListAnnotationNode(this, instContext);
    9798    eq FClass.annotation(InstContext instContext)            = new FAttributeListAnnotationNode(this, instContext);
     99    eq FExternalStmt.annotation(InstContext instContext)     = new FAttributeListAnnotationNode(this, instContext);
    98100
    99101    eq InstExternal.annotation() = annotation(annotationExpEvaluator());
     
    236238        myTargetInstClassDecl().addAnnotationToEvaluator(list, this);
    237239        return list;
     240    }
     241    eq InstLibNode.annotations() {
     242        return resolveLib().annotations();
    238243    }
    239244
  • branches/dev-jk-2471/Compiler/ModelicaMiddleEnd/src/jastadd/structural/Symbolic.jrag

    r13612 r13628  
    121121                }
    122122            }
     123           
     124            if (activeTerms.isEmpty()) {
     125                return new FNoExp();
     126            }
     127               
    123128           
    124129            // Compute new expressions for the inactive and active terms
  • branches/dev-jk-2471/Compiler/TestFramework/src/jastadd/TestAnnotationizer.jrag

    r13294 r13628  
    11791179            checkData(data);
    11801180            methodName = data[0].toString();
    1181             arguments = (data.length == 1) ? new Object[0] : (Object[]) data[1];
     1181            arguments = arguments();
    11821182            Method method = o.getClass().getMethod(methodName, TestCase.unwrapClasses(arguments));
    11831183            methodResult = method.invoke(o, arguments).toString();
     1184        }
     1185       
     1186        private Object[] arguments() {
     1187            if (data.length > 1) {
     1188                if (data[1] != null) {
     1189                    return (Object[]) data[1];
     1190                }
     1191            }
     1192            return new Object[0];
    11841193        }
    11851194       
  • branches/dev-jk-2471/Compiler/build-base.xml

    r13488 r13628  
    636636            <isset property="javadoc.packages"/>
    637637            <then>
     638
     639                <!-- We need to add this to builds with Java v9 or greater -->
     640                <condition property="javadoc_additional_params" value="" else="--no-module-directories">
     641                    <or>
     642                        <equals arg1="${ant.java.version}" arg2="1.7" />
     643                        <equals arg1="${ant.java.version}" arg2="1.8" />
     644                    </or>
     645                </condition>
     646
    638647                <!-- The javadoc directory is sometimes unusable, unclear why.
    639648                     It is recreated by the javadoc task. -->
     
    646655                    excludepackagenames="${test_helper_packages}"
    647656                    classpath="${thirdparty_jars_build}"
     657                    additionalparam="${javadoc_additional_params}"
    648658                    failonerror="true" />
    649659            </then>
  • branches/dev-jk-2471/Python/src/tests_jmodelica/test_compiler.py

    r12127 r13628  
    391391        """
    392392        fmuname = compile_fmu(Test_Compiler_functions.cpath_mc, Test_Compiler_functions.fpath_mc, compiler_options={'generate_html_diagnostics':True})
     393        (diag_name, _) = os.path.splitext(fmuname)
     394        diag_name += '_html_diagnostics'
     395
     396        assert os.access(fmuname, os.F_OK) == True, \
     397               fmuname+" was not created."
     398        assert os.access(diag_name, os.F_OK) == True, \
     399               diag_name+" was not created."
     400        os.remove(fmuname)
     401        shutil.rmtree(diag_name)
     402
     403    @testattr(stddist_base = True)
     404    def test_dynamic_state_html_diagnostics(self):
     405        """
     406        Test that generate_html_diagnostics works with a model with dynamic states, see #5839
     407        """
     408
     409        fmuname = compile_fmu("ThreeDSOneEq", os.path.join(get_files_path(), 'Modelica', 'ThreeDSOneEq.mo'), compiler_options={'generate_html_diagnostics':True})
    393410        (diag_name, _) = os.path.splitext(fmuname)
    394411        diag_name += '_html_diagnostics'
Note: See TracChangeset for help on using the changeset viewer.