summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'ast-to-instr/src')
-rw-r--r--ast-to-instr/src/Depths.java72
-rw-r--r--ast-to-instr/src/Main.java2
-rw-r--r--ast-to-instr/src/Strings.java2
-rw-r--r--ast-to-instr/src/VHDLCSNode.java5
-rw-r--r--ast-to-instr/src/VHDLISNode.java5
-rw-r--r--ast-to-instr/src/VHDLSSASNode.java5
-rw-r--r--ast-to-instr/src/VHDLWNode.java5
7 files changed, 79 insertions, 17 deletions
diff --git a/ast-to-instr/src/Depths.java b/ast-to-instr/src/Depths.java
new file mode 100644
index 0000000..ade01c8
--- /dev/null
+++ b/ast-to-instr/src/Depths.java
@@ -0,0 +1,72 @@
+import java.util.Map;
+import java.util.HashMap;
+
+public class Depths
+{
+ private static final Map<Integer, IDs> TO_ID;
+ private static final OutputFile DEPTHS_OUTPUT;
+ private static int highest_depth;
+
+ static
+ {
+ highest_depth = -1;
+
+ TO_ID = new HashMap<Integer, IDs>();
+
+ /* TODO: filename as a param? */
+ DEPTHS_OUTPUT = OutputFile.new_output_file("depths.mod");
+ }
+
+ private Depths () {} /* Utility class. */
+
+ public static IDs get_id_from_depth
+ (
+ final String depth
+ )
+ {
+ return get_id_from_depth(Integer.valueOf(depth));
+ }
+
+ public static IDs get_id_from_depth
+ (
+ final Integer depth
+ )
+ {
+ IDs result;
+
+ result = TO_ID.get(depth);
+
+ if (result == null)
+ {
+ result = IDs.generate_new_id(DEPTHS_OUTPUT, "depth");
+
+ TO_ID.put(depth, result);
+ }
+
+ if (depth.intValue() > highest_depth)
+ {
+ highest_depth = depth.intValue();
+ }
+
+ return result;
+ }
+
+ public static void generate_predicates ()
+ {
+ for
+ (
+ int current_depth = highest_depth;
+ current_depth > 0;
+ --current_depth
+ )
+ {
+ Predicates.add_entry
+ (
+ DEPTHS_OUTPUT,
+ "is_lower_than",
+ get_id_from_depth(new Integer(current_depth - 1)),
+ get_id_from_depth(new Integer(current_depth))
+ );
+ }
+ }
+}
diff --git a/ast-to-instr/src/Main.java b/ast-to-instr/src/Main.java
index 5bc45a0..0e24f57 100644
--- a/ast-to-instr/src/Main.java
+++ b/ast-to-instr/src/Main.java
@@ -87,6 +87,8 @@ public class Main
parse_content(vhdl_files);
+ Depths.generate_predicates();
+
OutputFile.close_all();
}
diff --git a/ast-to-instr/src/Strings.java b/ast-to-instr/src/Strings.java
index 67189ad..a03070b 100644
--- a/ast-to-instr/src/Strings.java
+++ b/ast-to-instr/src/Strings.java
@@ -18,7 +18,7 @@ public class Strings
public static IDs get_id_from_string
(
- String string
+ final String string
)
{
return get_id_from_string(Main.get_main_output(), string);
diff --git a/ast-to-instr/src/VHDLCSNode.java b/ast-to-instr/src/VHDLCSNode.java
index f500345..6682613 100644
--- a/ast-to-instr/src/VHDLCSNode.java
+++ b/ast-to-instr/src/VHDLCSNode.java
@@ -130,10 +130,7 @@ public class VHDLCSNode extends VHDLNode
output,
"depth",
local_id,
- Strings.get_id_from_string
- (
- Integer.toString(depth)
- )
+ Depths.get_id_from_depth(new Integer(depth))
);
}
diff --git a/ast-to-instr/src/VHDLISNode.java b/ast-to-instr/src/VHDLISNode.java
index 3c293cd..4883080 100644
--- a/ast-to-instr/src/VHDLISNode.java
+++ b/ast-to-instr/src/VHDLISNode.java
@@ -128,10 +128,7 @@ public class VHDLISNode extends VHDLNode
output,
"depth",
local_id,
- Strings.get_id_from_string
- (
- Integer.toString(depth)
- )
+ Depths.get_id_from_depth(new Integer(depth))
);
}
diff --git a/ast-to-instr/src/VHDLSSASNode.java b/ast-to-instr/src/VHDLSSASNode.java
index b638f81..944ad18 100644
--- a/ast-to-instr/src/VHDLSSASNode.java
+++ b/ast-to-instr/src/VHDLSSASNode.java
@@ -122,10 +122,7 @@ public class VHDLSSASNode extends VHDLNode
output,
"depth",
local_id,
- Strings.get_id_from_string
- (
- Integer.toString(depth)
- )
+ Depths.get_id_from_depth(new Integer(depth))
);
}
diff --git a/ast-to-instr/src/VHDLWNode.java b/ast-to-instr/src/VHDLWNode.java
index 4052229..b893c7a 100644
--- a/ast-to-instr/src/VHDLWNode.java
+++ b/ast-to-instr/src/VHDLWNode.java
@@ -117,10 +117,7 @@ public class VHDLWNode extends VHDLNode
output,
"depth",
local_id,
- Strings.get_id_from_string
- (
- Integer.toString(depth)
- )
+ Depths.get_id_from_depth(new Integer(depth))
);
}