Skip to content

Commit

Permalink
Added SMDD to MDD transformer
Browse files Browse the repository at this point in the history
  • Loading branch information
mondokm committed Feb 13, 2024
1 parent c295d7e commit 37f4b9b
Showing 1 changed file with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package hu.bme.mit.theta.xsts.cli;

import hu.bme.mit.delta.collections.RecursiveIntObjCursor;
import hu.bme.mit.delta.java.mdd.*;
import hu.bme.mit.delta.java.mdd.impl.MddStructuralTemplate;

public class MddToStructuralTransformer {

public static MddHandle transform(MddHandle mddHandle, MddVariableHandle variableHandle) {
return transform(mddHandle, variableHandle, mddHandle.cursor());
}

public static MddHandle transform(MddHandle node, MddVariableHandle variable, RecursiveIntObjCursor<? extends MddHandle> cursor) {

if (node.isTerminal()) {
if (node.isTerminalZero()) {
return variable.getMddGraph().getTerminalZeroHandle();
} else {
MddGraph<Object> mddGraph = (MddGraph<Object>) variable.getMddGraph();
return mddGraph.getTerminalVariableHandle().getHandleFor(mddGraph.getNodeFor(node.getData()));
}
}

MddUnsafeTemplateBuilder templateBuilder = JavaMddFactory.getDefault().createUnsafeTemplateBuilder();

while (cursor.moveNext()){

try(var valueCursor = cursor.valueCursor()){

MddHandle s = transform(cursor.value(),
variable.getLower().orElse(null), valueCursor
);

templateBuilder.set(cursor.key(), s.getNode());
}
}

return variable.checkInNode(MddStructuralTemplate.of(templateBuilder.buildAndReset()));

}

}

0 comments on commit 37f4b9b

Please sign in to comment.