summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2017-07-22 21:05:57 +0200
committerNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2017-07-22 21:05:57 +0200
commit2b3f20d89c7d500842869d3316bee9c7457ba6d4 (patch)
treeb0429993666b252748e4c22bc230a5beaea1c3c6
parentd05bd3592050a9496dd87bcd8a49f8fdc8b6b58d (diff)
Adds the "is_terminal" predicate.
-rw-r--r--ast-to-instr/src/VHDLCSNode.java2
-rw-r--r--ast-to-instr/src/VHDLISNode.java2
-rw-r--r--ast-to-instr/src/VHDLSSASNode.java2
-rw-r--r--cfg-to-paths/src/ControlFlow.java21
-rw-r--r--cfg-to-paths/src/Node.java73
-rw-r--r--cfg-to-paths/src/Parameters.java2
-rw-r--r--cfg-to-paths/src/Path.java48
-rw-r--r--data/level/control_flow_level.lvl1
8 files changed, 105 insertions, 46 deletions
diff --git a/ast-to-instr/src/VHDLCSNode.java b/ast-to-instr/src/VHDLCSNode.java
index 4ba6631..ebc1b52 100644
--- a/ast-to-instr/src/VHDLCSNode.java
+++ b/ast-to-instr/src/VHDLCSNode.java
@@ -268,7 +268,7 @@ public class VHDLCSNode extends VHDLNode
Predicates.add_entry
(
output,
- "is_final",
+ "is_terminal",
local_id
);
}
diff --git a/ast-to-instr/src/VHDLISNode.java b/ast-to-instr/src/VHDLISNode.java
index 3819153..f9f8eb3 100644
--- a/ast-to-instr/src/VHDLISNode.java
+++ b/ast-to-instr/src/VHDLISNode.java
@@ -261,7 +261,7 @@ public class VHDLISNode extends VHDLNode
Predicates.add_entry
(
output,
- "is_final",
+ "is_terminal",
local_id
);
}
diff --git a/ast-to-instr/src/VHDLSSASNode.java b/ast-to-instr/src/VHDLSSASNode.java
index 2ee2fda..76d56af 100644
--- a/ast-to-instr/src/VHDLSSASNode.java
+++ b/ast-to-instr/src/VHDLSSASNode.java
@@ -284,7 +284,7 @@ public class VHDLSSASNode extends VHDLNode
Predicates.add_entry
(
output,
- "is_final",
+ "is_terminal",
local_id
);
}
diff --git a/cfg-to-paths/src/ControlFlow.java b/cfg-to-paths/src/ControlFlow.java
index bca72d5..93d20ba 100644
--- a/cfg-to-paths/src/ControlFlow.java
+++ b/cfg-to-paths/src/ControlFlow.java
@@ -55,6 +55,10 @@ public class ControlFlow
{
success = handle_add_connect_to(input);
}
+ else if (input[0].equals("is_terminal"))
+ {
+ success = handle_is_terminal(input);
+ }
else
{
continue;
@@ -106,6 +110,21 @@ public class ControlFlow
return true;
}
+ private static boolean handle_is_terminal
+ (
+ final String[] input
+ )
+ {
+ if (input.length != 2)
+ {
+ return false;
+ }
+
+ Node.handle_is_terminal(input[1]);
+
+ return true;
+ }
+
private static boolean handle_add_connect_to
(
final String[] input
@@ -118,4 +137,6 @@ public class ControlFlow
return Node.handle_connect_to(input[1], input[2]);
}
+
+ private ControlFlow () {} /* Utility Class */
}
diff --git a/cfg-to-paths/src/Node.java b/cfg-to-paths/src/Node.java
index 5f82f64..3b6f2c1 100644
--- a/cfg-to-paths/src/Node.java
+++ b/cfg-to-paths/src/Node.java
@@ -2,33 +2,14 @@ import java.util.*;
public class Node
{
+ /** Static *****************************************************************/
private static final Map<String, Node> NODE_FROM_STRING;
- private final Collection<Node> next_nodes;
-
- private final String name;
static
{
NODE_FROM_STRING = new HashMap<String, Node>();
}
- private Node (final String name)
- {
- this.name = name;
- next_nodes = new ArrayList<Node>();
- }
-
- public Collection<Node> next_nodes ()
- {
- return next_nodes;
- }
-
- @Override
- public String toString ()
- {
- return name;
- }
-
public static Node get_node (final String s)
{
return NODE_FROM_STRING.get(s);
@@ -44,6 +25,24 @@ public class Node
return true;
}
+ public static boolean handle_is_terminal (final String a)
+ {
+ Node n;
+
+ n = NODE_FROM_STRING.get(a);
+
+ if (n == (Node) null)
+ {
+ n = new Node(a);
+
+ NODE_FROM_STRING.put(a, n);
+ }
+
+ n.set_as_terminal();
+
+ return true;
+ }
+
public static boolean handle_connect_to (final String a, final String b)
{
final Node n_a, n_b;
@@ -68,4 +67,38 @@ public class Node
return true;
}
+
+ /** Non-Static *************************************************************/
+ private final Collection<Node> next_nodes;
+ private final String name;
+ private boolean is_terminal;
+
+ private Node (final String name)
+ {
+ this.name = name;
+
+ next_nodes = new ArrayList<Node>();
+ is_terminal = false;
+ }
+
+ private void set_as_terminal ()
+ {
+ is_terminal = true;
+ }
+
+ public Collection<Node> next_nodes ()
+ {
+ return next_nodes;
+ }
+
+ public boolean is_terminal ()
+ {
+ return is_terminal;
+ }
+
+ @Override
+ public String toString ()
+ {
+ return name;
+ }
}
diff --git a/cfg-to-paths/src/Parameters.java b/cfg-to-paths/src/Parameters.java
index 710b1f7..91303d2 100644
--- a/cfg-to-paths/src/Parameters.java
+++ b/cfg-to-paths/src/Parameters.java
@@ -22,7 +22,7 @@ public class Parameters
);
}
- public Parameters (String... args)
+ public Parameters (final String... args)
{
if (args.length != 4)
{
diff --git a/cfg-to-paths/src/Path.java b/cfg-to-paths/src/Path.java
index 76ba28a..6015d53 100644
--- a/cfg-to-paths/src/Path.java
+++ b/cfg-to-paths/src/Path.java
@@ -5,28 +5,6 @@ public class Path
private final ArrayList<Node> nodes;
private final Node last_node;
- private Path (final Node start)
- {
- nodes = new ArrayList<Node>();
-
- nodes.add(start);
-
- last_node = start;
- }
-
- private Path (final ArrayList<Node> nodes, final Node last_node)
- {
- this.nodes = nodes;
- this.last_node = last_node;
-
- this.nodes.add(last_node);
- }
-
- private Path add_step (final Node n)
- {
- return new Path((ArrayList<Node>) nodes.clone(), n);
- }
-
public static Collection<Path> get_all_paths_from (final String root)
{
final Collection<Path> result;
@@ -68,6 +46,10 @@ public class Path
}
else
{
+ if (current_node.is_terminal())
+ {
+ result.add(current_path);
+ }
for (final Node next: next_nodes)
{
waiting_list.push(current_path.add_step(next));
@@ -78,6 +60,28 @@ public class Path
return result;
}
+ private Path (final Node start)
+ {
+ nodes = new ArrayList<Node>();
+
+ nodes.add(start);
+
+ last_node = start;
+ }
+
+ private Path (final ArrayList<Node> nodes, final Node last_node)
+ {
+ this.nodes = nodes;
+ this.last_node = last_node;
+
+ this.nodes.add(last_node);
+ }
+
+ private Path add_step (final Node n)
+ {
+ return new Path((ArrayList<Node>) nodes.clone(), n);
+ }
+
public Collection<List<Node>> get_all_subpaths ()
{
final Collection<List<Node>> result;
diff --git a/data/level/control_flow_level.lvl b/data/level/control_flow_level.lvl
index 516f9ef..4ae7837 100644
--- a/data/level/control_flow_level.lvl
+++ b/data/level/control_flow_level.lvl
@@ -22,3 +22,4 @@
(add_predicate node_connect node node)
(add_predicate expr_writes node waveform)
(add_predicate expr_reads node waveform)
+(add_predicate is_terminal node)