-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
...cts/xsts/xsts-cli/src/main/java/hu/bme/mit/theta/xsts/cli/MddToStructuralTransformer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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())); | ||
|
||
} | ||
|
||
} |