Changeset 14265


Ignore:
Timestamp:
Dec 3, 2019 5:27:11 PM (8 days ago)
Author:
amartensen
Message:

#5879 updated myEnvironment() equations for InstGeneratedInners, added python test.

Location:
branches/dev-2559
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • branches/dev-2559/Compiler/ModelicaFrontEnd/src/jastadd/instance/InnerOuter.jrag

    r14237 r14265  
    105105    }
    106106
    107     eq InstClassDecl.getInstGeneratedInners().myEnvironment()            = new Environment().mergeInnerClone(getGeneratedInnerModificationsList());
    108     eq InstClassDecl.getInstGeneratedInners().myEnvironment(String name) = new Environment().mergeInnerClone(getGeneratedInnerModificationsList()).filter(name);
     107    eq InstClassDecl.getInstGeneratedInners().myEnvironment()            = myEnvironment().mergeInnerClone(getGeneratedInnerModificationsList());
     108    eq InstClassDecl.getInstGeneratedInners().myEnvironment(String name) = myEnvironment(name).mergeInnerClone(getGeneratedInnerModificationsList()).filter(name);
    109109   
    110110    syn lazy List<InstModification> InstClassDecl.getGeneratedInnerModificationsList() {
    111111        List<InstModification> res = new List<>();
    112         for(AnnotationNode an : annotation().vendorNode().forPath("inners")) {
     112        for(AnnotationNode an : innersAnnotation()) {
    113113            if (!an.exists()) {
    114114                continue;
     
    123123        return res;
    124124    }
    125    
     125
     126    syn AnnotationNode InstClassDecl.innersAnnotation() = annotation().vendorNode().forPath("inners");
     127    syn boolean InstClassDecl.hasInnersAnnotation() = innersAnnotation().exists();
     128
    126129    public InstGeneratedInner.InstGeneratedInner(InstClassDecl parent, InstComponentDecl outer, InstComponentDecl nonInner) {
    127130        this(parent.createInstComponentDecl(outer.getSrcComponentDecl()), outer, nonInner);
  • branches/dev-2559/Compiler/ModelicaFrontEnd/src/jastadd/instance/InstanceTree.jrag

    r14252 r14265  
    17711771        hasFArraySubscripts() ||
    17721772        hasInstClassModification() ||
     1773        hasInnersAnnotation() ||
    17731774        getSrcClassDecl().hasSrcTypePrefix() ||
    17741775        !filteredEnvironment().isEmpty() ||
  • branches/dev-2559/Compiler/ModelicaFrontEnd/test/modelica/InnerOuterTests.mo

    r14253 r14265  
    14761476end SetOuterComposite;
    14771477
     1478model AnnotationModifier
     1479    model S
     1480        parameter Integer n = 1;
     1481    end S;
     1482    outer S s;
     1483annotation(
     1484__JModelica(UnitTesting(tests={
     1485    FlatteningTestCase(
     1486        name="AnnotationModifier",
     1487        description="modifiers set on outers from an annotation(_Modelon(inners(..))) on the command line are applied",
     1488        modification=" annotation(__Modelon(inners(s(n=2))))",
     1489        flatModel="
     1490fclass InnerOuterTests.AnnotationModifier
     1491 parameter Integer s.n = 2 /* 2 */;
     1492end InnerOuterTests.AnnotationModifier;
     1493")})));
     1494end AnnotationModifier;
     1495
    14781496model SetOuterError
    14791497    outer parameter Real x;
  • branches/dev-2559/Python/src/tests_jmodelica/test_compiler.py

    r14056 r14265  
    400400        os.remove(fmuname)
    401401        shutil.rmtree(diag_name)
     402
     403    @testattr(stddist_base = True)
     404    def test_outer_modifiers(self):
     405        """Test that it is possible to set modifiers on outers from an annotation(_Modelon(inners(..))) added to the compile_fmu call"""
     406        fmu = compile_fmu("OuterModifiers annotation(__Modelon(inners(s(n=2, i={3,2}))))", file_name=os.path.join(get_files_path(), "Modelica", "OuterModifiers.mo"))
     407        model = load_fmu(fmu)
     408       
     409        # Simulate
     410        opts = model.simulate_options()
     411        opts['ncp'] = 10
     412        model.simulate(final_time=1.0, options=opts)
     413        model.terminate()
     414       
     415        # Verify results
     416        nose.tools.assert_almost_equal(50, model.get("y")[0])
    402417
    403418    @testattr(stddist_base = True)
Note: See TracChangeset for help on using the changeset viewer.