Skip to content

Commit

Permalink
fixed issues related to deserialization of state in fmi2
Browse files Browse the repository at this point in the history
  • Loading branch information
lausdahl committed Aug 15, 2024
1 parent a61f15f commit 416e986
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ public static FmuComponentValue getFmuComponentValue(BufferedOutputStream fmuLog
Value v = fcargs.get(0).deref();
Value sizeValue = fcargs.get(1);

if (v instanceof FmuComponentStateValue && sizeValue.isNumeric()) {
if (v instanceof FmuComponentStateValue && sizeValue.deref().isNumeric()) {
try {
FmuComponentStateValue stateValue = (FmuComponentStateValue) v;
FmuResult<Long> res = component.getSerializedFMUstateSize(stateValue.getModule());
Expand Down Expand Up @@ -567,7 +567,7 @@ public static FmuComponentValue getFmuComponentValue(BufferedOutputStream fmuLog
Value sizeValue = fcargs.get(1).deref();
Value stateValue = fcargs.get(2);

if (stateValue instanceof FmuComponentStateValue && sizeValue.isNumeric()) {
if ( sizeValue.isNumeric()) {
try {
NumericValue size = (NumericValue) sizeValue;
ArrayValue<ByteValue> byteArray = (ArrayValue<ByteValue>) bytesValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public Value caseANotEqualBinaryExp(ANotEqualBinaryExp node, Context question) t

public ArrayValue createArrayValue(List<PExp> sizes, PType type, Context question) throws AnalysisException {
List<Value> arrayValues = new ArrayList<>();
for (int i = 0; i < ((NumericValue) sizes.get(0).apply(this, question)).intValue(); i++) {
for (int i = 0; i < ((NumericValue) sizes.get(0).apply(this, question).deref()).intValue(); i++) {
if (sizes.size() > 1) {
List<PExp> nextSizes = sizes.subList(1, sizes.size());
// Call recursively
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ public int compareTo(Value other) {
if (other instanceof IntegerValue || other instanceof ByteValue || other instanceof ShortValue) {
NumericValue io = (NumericValue) other;
return (value < io.intValue() ? -1 : (value == io.intValue() ? 0 : 1));
}else if( other instanceof LongValue)
{
NumericValue io = (NumericValue) other;
return (value < io.longValue() ? -1 : (value == io.longValue() ? 0 : 1));
}

return super.compareTo(other);
Expand Down

0 comments on commit 416e986

Please sign in to comment.