Changeset 11814


Ignore:
Timestamp:
Oct 31, 2018 2:45:13 PM (14 months ago)
Author:
Jonathan Kämpe
Message:

#5670 Merging refactoring to trunk

Location:
trunk
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/Compiler/ModelicaCBackEnd/src/jastadd/CCodeGen/CCodeGenExternalCeval.jrag

    r11676 r11814  
    246246     */
    247247    syn Collection<ExternalArgument> FExternalStmt.varsToSerialize() {
    248         if (!hasArg() && !hasReturnVar())
    249             return new ArrayList<ExternalArgument>(myCommonVarDecls());
    250        
    251248        Collection<ExternalArgument> res = new LinkedHashSet<>();
    252249        if (hasReturnVar()) {
     
    305302        }
    306303        return res;
    307     }
    308    
    309     /**
    310      * CommonVariableDecls from enclosing function
    311      */
    312     private ArrayList<CommonVariableDecl> FExternalStmt.myCommonVarDecls() {
    313         FFunctionDecl decl = containingFFunctionDecl();
    314         if (decl != null) {
    315             return new ArrayList<CommonVariableDecl>(decl.getFFunctionVariables().toArrayList());
    316         } else {
    317             ArrayList<CommonVariableDecl> res = new ArrayList<>();
    318             for (CommonVariableDecl cvd : enclosingInstClassDecl().allInstComponentDecls()) {
    319                 if (!cvd.variability().constantVariability()) {
    320                     res.add(cvd);
    321                 }
    322             }
    323             return res;
    324         }
    325304    }
    326305
  • trunk/Compiler/ModelicaCBackEnd/src/jastadd/CCodeGen/CCodeGenTypes.jrag

    r11676 r11814  
    195195        protected boolean external = false;
    196196        protected boolean subDecls = false; // Used in CAD
    197         boolean forceDynamic = false;
    198197       
    199198        private Stack<Level> levels   = new Stack<Level>();
     
    207206            this(p, str);
    208207            reset(name, src, s, external, indent);
    209         }
    210        
    211         public TypePrinter_C forceDynamic() {
    212             forceDynamic = true;
    213             return this;
    214208        }
    215209       
     
    261255       
    262256        protected String dynStr(FType type) {
    263             return (forceDynamic || dynamic() ? "DYNA" : "STAT");
     257            return (dynamic() ? "DYNA" : "STAT");
    264258        }
    265259       
  • trunk/Compiler/ModelicaFlatTree/src/jastadd/PrettyPrint.jrag

    r11728 r11814  
    10521052        }
    10531053        if (getNumFGlobalVariable() > 0) {
    1054             str.println(indent, "package constant");
     1054            str.println(indent, "global variables");
    10551055            for (FVariable fv : getFGlobalVariables()) {
    10561056                p.print(fv, str, nextInd);
  • trunk/Compiler/ModelicaFlatTree/src/jastadd/ast/FlatModelica.ast

    r11676 r11814  
    134134abstract FTypePrefix : BaseNode;
    135135
     136/**
     137 * Variables accessed in a global scope separate from the normal lookup scope
     138 * (in the flat tree). Can be looked up from functions and equations. For example
     139 * package constants that can't be inlined during flattening. Referenced by FGlobalAccessExp.
     140 */
    136141FGlobalVariable : FVariable ::= FType;
    137142
  • trunk/Compiler/ModelicaFrontEnd/test/modelica/ArrayTests.mo

    r11639 r11814  
    90099009 constant Real c[2] = 3;
    90109010 Real x;
    9011 package constant
     9011global variables
    90129012 constant Real ArrayTests.Other.ArrayConst3.c[2] = {2, 3};
    90139013equation
  • trunk/Compiler/ModelicaFrontEnd/test/modelica/FunctionTests.mo

    r11785 r11814  
    482482 Real z[1];
    483483 Real z[2];
    484 package constant
     484global variables
    485485 constant Real FunctionTests.FunctionFlatten9.a[3] = {1, 2, 3};
    486486equation
     
    10021002fclass FunctionTests.FunctionFlatten21
    10031003 Real x = FunctionTests.FunctionFlatten21.f();
    1004 package constant
     1004global variables
    10051005 constant Real FunctionTests.FunctionFlatten21.f.x; // TODO: Compilation error?
    10061006
     
    10811081fclass FunctionTests.FunctionFlatten23
    10821082 Real y;
    1083 package constant
     1083global variables
    10841084 constant FunctionTests.FunctionFlatten23.R FunctionTests.FunctionFlatten23.f.r = FunctionTests.FunctionFlatten23.R(1, {3.14});
    10851085equation
     
    1030210302 constant Real a[3] = 3;
    1030310303 Real x;
    10304 package constant
     10304global variables
    1030510305 constant Real FunctionTests.UnknownArray29.a[3] = {1, 2, 3};
    1030610306equation
     
    1248112481 constant Real d[2] = {1, 2};
    1248212482 Real x = FunctionTests.ExtendFunc2.f2(1, 2);
    12483 package constant
     12483global variables
    1248412484 constant Real FunctionTests.ExtendFunc2.d[2] = {1, 2};
    1248512485
  • trunk/Compiler/ModelicaFrontEnd/test/modelica/FunctionTestsExternal.mo

    r11785 r11814  
    1717
    1818package FunctionTestsExternal
     19
     20model ExternalFuncEmpty1
     21 function f
     22 external;
     23 end f;
     24equation
     25 f();
     26
     27    annotation(__JModelica(UnitTesting(tests={
     28        FlatteningTestCase(
     29            name="ExternalFuncEmpty1",
     30            description="External functions: No IO",
     31            flatModel="
     32fclass FunctionTestsExternal.ExternalFuncEmpty1
     33equation
     34 FunctionTestsExternal.ExternalFuncEmpty1.f();
     35
     36public
     37 function FunctionTestsExternal.ExternalFuncEmpty1.f
     38 algorithm
     39  external \"C\" f();
     40  return;
     41 end FunctionTestsExternal.ExternalFuncEmpty1.f;
     42
     43end FunctionTestsExternal.ExternalFuncEmpty1;
     44")})));
     45end ExternalFuncEmpty1;
    1946
    2047model ExternalFunc1
  • trunk/Compiler/ModelicaFrontEnd/test/modelica/NameTests.mo

    r11639 r11814  
    17111711 parameter Integer j = 1 /* 1 */;
    17121712 Real y = NameTests.ConstantLookup32.f(j);
    1713 package constant
     1713global variables
    17141714 constant NameTests.ConstantLookup32.A NameTests.ConstantLookup32.C.d[2] = {NameTests.ConstantLookup32.A(3), NameTests.ConstantLookup32.A(4)};
    17151715
     
    17681768 parameter Integer j = 1 /* 1 */;
    17691769 Real y = NameTests.ConstantLookup33.f(j);
    1770 package constant
     1770global variables
    17711771 constant NameTests.ConstantLookup33.D.A NameTests.ConstantLookup33.C.d[2] = {NameTests.ConstantLookup33.D.A(3), NameTests.ConstantLookup33.D.A(4)};
    17721772
     
    18171817 parameter Integer j = 1 /* 1 */;
    18181818 parameter Real z;
    1819 package constant
     1819global variables
    18201820 constant NameTests.ConstantLookup34.A.B NameTests.ConstantLookup34.A.x[2] = {NameTests.ConstantLookup34.A.B({1, 2}), NameTests.ConstantLookup34.A.B({3, 4})};
    18211821parameter equation
     
    18991899 parameter Integer b.j = 1 /* 1 */;
    19001900 parameter Real b.z;
    1901 package constant
     1901global variables
    19021902 constant Real NameTests.ConstantLookup35.L.a[2] = {1, 2};
    19031903parameter equation
     
    19461946 parameter Integer j = 1 /* 1 */;
    19471947 parameter Real z;
    1948 package constant
     1948global variables
    19491949 constant NameTests.ConstantLookup36.B NameTests.ConstantLookup36.f.a[2] = {NameTests.ConstantLookup36.B({1, 2}), NameTests.ConstantLookup36.B({3, 4})};
    19501950parameter equation
  • trunk/Compiler/ModelicaFrontEnd/test/modelica/RecordTests.mo

    r11770 r11814  
    20872087 Real w;
    20882088 discrete Integer i;
    2089 package constant
     2089global variables
    20902090 constant RecordTests.UnmodifiableComponent5.R RecordTests.UnmodifiableComponent5.r[2] = {RecordTests.UnmodifiableComponent5.R(1), RecordTests.UnmodifiableComponent5.R(2)};
    20912091initial equation
  • trunk/Compiler/ModelicaFrontEnd/test/modelica/VariabilityTests.mo

    r11639 r11814  
    12111211 constant Real x = 1;
    12121212 Real y = VariabilityTests.ExternalObjectConstant1.f(global(VariabilityTests.ExternalObjectConstant1.eo1));
    1213 package constant
     1213global variables
    12141214 constant VariabilityTests.ExternalObjectConstant1.EO VariabilityTests.ExternalObjectConstant1.eo = VariabilityTests.ExternalObjectConstant1.EO.constructor(1.0);
    12151215 constant VariabilityTests.ExternalObjectConstant1.EO VariabilityTests.ExternalObjectConstant1.eo1 = global(VariabilityTests.ExternalObjectConstant1.eo);
     
    12851285 constant Real x = 1;
    12861286 Real y = VariabilityTests.ExternalObjectConstant2.f(global(VariabilityTests.ExternalObjectConstant2.eo1));
    1287 package constant
     1287global variables
    12881288 constant VariabilityTests.ExternalObjectConstant2.EO VariabilityTests.ExternalObjectConstant2.eo = VariabilityTests.ExternalObjectConstant2.EO.constructor(1.0);
    12891289 constant VariabilityTests.ExternalObjectConstant2.EO VariabilityTests.ExternalObjectConstant2.eo1 = VariabilityTests.ExternalObjectConstant2.g(global(VariabilityTests.ExternalObjectConstant2.eo));
     
    13681368fclass VariabilityTests.ExternalObjectGlobalConstant1
    13691369 Real y = VariabilityTests.ExternalObjectGlobalConstant1.f(time);
    1370 package constant
     1370global variables
    13711371 constant VariabilityTests.ExternalObjectGlobalConstant1.P.EO VariabilityTests.ExternalObjectGlobalConstant1.P.eo = VariabilityTests.ExternalObjectGlobalConstant1.P.EO.constructor(1.0);
    13721372 constant VariabilityTests.ExternalObjectGlobalConstant1.P.EO VariabilityTests.ExternalObjectGlobalConstant1.P.eo1 = global(VariabilityTests.ExternalObjectGlobalConstant1.P.eo);
  • trunk/Compiler/ModelicaMiddleEnd/src/jastadd/Globals.jrag

    r11676 r11814  
    235235        if (global().update(type)) {
    236236            markUsedGlobals(type);
    237             //type().markUsedGlobals(type);
    238237        }
    239238    }
  • trunk/Compiler/ModelicaMiddleEnd/test/modelica/FunctionInlining.mo

    r11733 r11814  
    51265126 parameter Integer temp_2;
    51275127 parameter Real y.x;
    5128 package constant
     5128global variables
    51295129 constant FunctionInlining.GlobalConst2.R2 FunctionInlining.GlobalConst2.f.a = FunctionInlining.GlobalConst2.R2({FunctionInlining.GlobalConst2.R1(2), FunctionInlining.GlobalConst2.R1(3)});
    51305130parameter equation
     
    51685168 Real y;
    51695169 discrete Integer temp_1;
    5170 package constant
     5170global variables
    51715171 constant FunctionInlining.GlobalConst3.R1 FunctionInlining.GlobalConst3.r[1] = {FunctionInlining.GlobalConst3.R1(2)};
    51725172initial equation
     
    52295229fclass FunctionInlining.GlobalConstExtObj1
    52305230 Real y;
    5231 package constant
     5231global variables
    52325232 constant FunctionInlining.GlobalConstExtObj1.P.EO FunctionInlining.GlobalConstExtObj1.P.eo = FunctionInlining.GlobalConstExtObj1.P.EO.constructor({1.0});
    52335233 constant FunctionInlining.GlobalConstExtObj1.P.EO FunctionInlining.GlobalConstExtObj1.P.eo1 = global(FunctionInlining.GlobalConstExtObj1.P.eo);
  • trunk/Compiler/ModelicaMiddleEnd/test/modelica/VariabilityPropagationTests.mo

    r11759 r11814  
    26702670        TransformCanonicalTestCase(
    26712671            name="ExternalObjectConstant1",
    2672             description="",
     2672            description="Test behavior when variability propagation tries to evaluate an equation with global constant external object reference",
    26732673            flatModel="
    26742674           
     
    26762676 constant Real x = 1;
    26772677 parameter Real y;
    2678 package constant
     2678global variables
    26792679 constant VariabilityPropagationTests.ExternalObjectConstant1.EO VariabilityPropagationTests.ExternalObjectConstant1.eo = VariabilityPropagationTests.ExternalObjectConstant1.EO.constructor(1.0);
    26802680parameter equation
     
    27442744        TransformCanonicalTestCase(
    27452745            name="ExternalObjectConstant2",
    2746             description="",
     2746            description="Test behavior when variability propagation tries to evaluate an equation with global constant external object reference",
    27472747            flatModel="
    27482748fclass VariabilityPropagationTests.ExternalObjectConstant2
    27492749 constant Real x = 1;
    27502750 parameter Real y;
    2751 package constant
     2751global variables
    27522752 constant VariabilityPropagationTests.ExternalObjectConstant2.EO VariabilityPropagationTests.ExternalObjectConstant2.eo = VariabilityPropagationTests.ExternalObjectConstant2.EO.constructor(1.0);
    27532753parameter equation
Note: See TracChangeset for help on using the changeset viewer.