Changeset 1490b4f in OpenModelica


Ignore:
Timestamp:
2024-06-11T11:43:13+02:00 (6 weeks ago)
Author:
GitHub <noreply@…>
Branches:
master
Children:
06c815a0, 9e58230, dc62d8ef
Parents:
c4fa787
git-author:
kabdelhak <38032125+kabdelhak@…> (06/11/24 11:43:13)
git-committer:
GitHub <noreply@…> (06/11/24 11:43:13)
Message:

[NB] support array event variables (#12551)

  • use type of condition when creating event variable to have correct size
Location:
OMCompiler/Compiler/NBackEnd
Files:
2 edited

Legend:

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

    r91a15b1d r1490b4f  
    10201020    input String name                           "context name e.g. §WHEN";
    10211021    input Integer uniqueIndex                   "unique identifier index";
     1022    input Type var_ty                           "variable type";
    10221023    input Iterator iterator = Iterator.EMPTY()  "optional for-loop iterator";
    10231024    output Pointer<Variable> var_ptr            "pointer to new variable";
     
    10361037    iter_subs := list(Subscript.fromTypedExp(Expression.fromCref(iter)) for iter in iter_crefs);
    10371038    if listEmpty(iter_subs) then
    1038       ty := Type.BOOLEAN();
     1039      ty := var_ty;
    10391040    else
    10401041      sub_sizes := Iterator.sizes(iterator);
    1041       ty := Type.ARRAY(Type.BOOLEAN(), list(Dimension.fromInteger(sub_size) for sub_size in sub_sizes));
     1042      ty := Type.liftArrayLeftList(var_ty, list(Dimension.fromInteger(sub_size) for sub_size in sub_sizes));
    10421043    end if;
    10431044    // create inst node with dummy variable pointer and create cref from it
  • OMCompiler/Compiler/NBackEnd/Modules/2_Pre/NBEvents.mo

    r6ba1f8ee r1490b4f  
    645645        if createAux then
    646646          // make a new auxiliary variable and return the expression which replaces the zero crossing
    647           (aux_var, aux_cref) := BVariable.makeEventVar(NBVariable.STATE_EVENT_STR, bucket.auxiliaryStateEventIndex, iter);
     647          (aux_var, aux_cref) := BVariable.makeEventVar(NBVariable.STATE_EVENT_STR, bucket.auxiliaryStateEventIndex, Expression.typeOf(exp), iter);
    648648          exp := Expression.fromCref(aux_cref);
    649649        else
     
    829829          // make a new auxiliary variable and return the expression which replaces the zero crossing
    830830          (iter, range) := Equation.Iterator.getFrames(condition.iter);
    831           (aux_var, aux_cref) := BVariable.makeEventVar(NBVariable.TIME_EVENT_STR, bucket.auxiliaryTimeEventIndex, Iterator.fromFrames(List.zip(iter, range)));
     831          (aux_var, aux_cref) := BVariable.makeEventVar(NBVariable.TIME_EVENT_STR, bucket.auxiliaryTimeEventIndex, Expression.typeOf(condition.exp), Iterator.fromFrames(List.zip(iter, range)));
    832832          exp := Expression.fromCref(aux_cref);
    833833        else
Note: See TracChangeset for help on using the changeset viewer.