Changeset ef124e4 in OpenModelica


Ignore:
Timestamp:
2024-02-06T17:11:03+01:00 (3 months ago)
Author:
GitHub <noreply@…>
Branches:
maintenance/v1.23, master
Children:
f5281322
Parents:
2ab36e87
git-author:
kabdelhak <38032125+kabdelhak@…> (02/06/24 17:11:03)
git-committer:
GitHub <noreply@…> (02/06/24 17:11:03)
Message:

[NB] remove useless function (#11958)

  • remove function Equation.fromLHSandRHS because Equation.makeAssignment does the same but better
    • also creates correct sizes
Location:
OMCompiler/Compiler/NBackEnd
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • OMCompiler/Compiler/NBackEnd/Classes/NBEquation.mo

    rcfdfeb87 ref124e4  
    12291229    end setRHS;
    12301230
    1231     function fromLHSandRHS
    1232       input Expression lhs;
    1233       input Expression rhs;
    1234       input Pointer<Integer> idx;
    1235       input String context;
    1236       input EquationAttributes attr = EquationAttributes.default(EquationKind.UNKNOWN, false);
    1237       input DAE.ElementSource src = DAE.emptyElementSource;
    1238       output Pointer<Equation> eqn_ptr;
    1239     protected
    1240       Type ty;
    1241       Equation eqn;
    1242       Option<Integer> opt_rec_size;
    1243       Integer rec_size;
    1244     algorithm
    1245       ty := Expression.typeOf(lhs);
    1246       opt_rec_size := Type.complexSize(ty);
    1247       eqn := match (ty, opt_rec_size)
    1248         case (Type.ARRAY(), _)                then ARRAY_EQUATION(ty, lhs, rhs, src, attr, opt_rec_size);
    1249         case (Type.COMPLEX(), SOME(rec_size)) then RECORD_EQUATION(ty, lhs, rhs, src, attr, rec_size);
    1250                                               else SCALAR_EQUATION(ty, lhs, rhs, src, attr);
    1251       end match;
    1252       eqn_ptr := Pointer.create(eqn);
    1253       Equation.createName(eqn_ptr, idx, context);
    1254     end fromLHSandRHS;
    1255 
    12561231    function updateLHSandRHS
    12571232      input output Equation eqn;
     
    17681743      if Iterator.isEmpty(iter) then
    17691744        lhs := Expression.fromCref(var.name);
    1770         eqn := Equation.fromLHSandRHS(lhs, rhs, idx, context, eqnAttr);
     1745        eqn := Equation.makeAssignment(lhs, rhs, idx, context, Iterator.EMPTY(), eqnAttr);
    17711746      else
    17721747        rhs := Expression.map(rhs, Expression.repairOperator);
     
    17741749        subs := list(Subscript.fromTypedExp(Expression.fromCref(cref)) for cref in sub_crefs);
    17751750        lhs := Expression.fromCref(ComponentRef.mergeSubscripts(subs, var.name, true, true));
    1776         eqn := Equation.fromLHSandRHS(lhs, rhs, idx, context, eqnAttr);
    1777         eqn := Pointer.create(Equation.FOR_EQUATION(
    1778           size = ComponentRef.size(var.name),
    1779           iter = iter,
    1780           body = {Pointer.access(eqn)},
    1781           source = DAE.emptyElementSource,
    1782           attr = eqnAttr));
    1783         Equation.createName(eqn, idx, context);
     1751        eqn := Equation.makeAssignment(lhs, rhs, idx, context, iter, eqnAttr);
    17841752        // this could lead to non existing variables, should not be a problem though
    17851753        Equation.renameIterators(eqn, "$i");
  • OMCompiler/Compiler/NBackEnd/Modules/2_Pre/NBDetectStates.mo

    refc4e90 ref124e4  
    5959  import BVariable = NBVariable;
    6060  import Differentiate = NBDifferentiate;
    61   import NBEquation.{Equation, EquationPointers, EqData, WhenEquationBody, WhenStatement, IfEquationBody};
     61  import NBEquation.{Equation, EquationPointers, EqData, EquationAttributes, EquationKind, Iterator, WhenEquationBody, WhenStatement, IfEquationBody};
    6262  import NBVariable.{VariablePointers, VarData};
    6363
     
    266266            // more than one algebraic variable > create auxiliary state
    267267            (state_var, state_cref, der_var, der_cref) := BVariable.makeAuxStateVar(Pointer.access(uniqueIndex), SOME(arg));
    268             aux_equation := Equation.fromLHSandRHS(Expression.fromCref(state_cref), arg, uniqueIndex, NBVariable.AUXILIARY_STR);
     268            aux_equation := Equation.makeAssignment(Expression.fromCref(state_cref), arg, uniqueIndex, NBVariable.AUXILIARY_STR, Iterator.EMPTY(), EquationAttributes.default(EquationKind.CONTINUOUS, false));
    269269            returnExp := Expression.fromCref(der_cref);
    270270
  • OMCompiler/Compiler/NBackEnd/Modules/2_Pre/NBEvents.mo

    r638e4828 ref124e4  
    212212        (cond, cev) := tpl;
    213213        if not BVariable.isDummyVariable(cev.auxiliary) then
    214           aux_eqn := Equation.fromLHSandRHS(Expression.fromCref(BVariable.getVarName(cev.auxiliary)), cond.exp, idx, context, EquationAttributes.default(EquationKind.DISCRETE, false));
     214          aux_eqn := Equation.makeAssignment(Expression.fromCref(BVariable.getVarName(cev.auxiliary)), cond.exp, idx, context, Iterator.EMPTY(), EquationAttributes.default(EquationKind.DISCRETE, false));
    215215          auxiliary_vars := cev.auxiliary :: auxiliary_vars;
    216216          auxiliary_eqns := aux_eqn :: auxiliary_eqns;
     
    414414          algorithm
    415415            // create auxiliary equation and solve for TIME
    416             tmpEqn := Pointer.access(Equation.fromLHSandRHS(exp.exp1, exp.exp2, Pointer.create(0), "TMP"));
     416            tmpEqn := Pointer.access(Equation.makeAssignment(exp.exp1, exp.exp2, Pointer.create(0), "TMP", Iterator.EMPTY(), EquationAttributes.default(EquationKind.UNKNOWN, false)));
    417417            _ := Equation.map(tmpEqn, function containsTimeTraverseExp(b = containsTime), SOME(function containsTimeTraverseCref(b = containsTime)));
    418418            if Pointer.access(containsTime) then
Note: See TracChangeset for help on using the changeset viewer.