summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ast-to-instr/src/Functions.java11
-rw-r--r--ast-to-instr/src/Main.java22
-rw-r--r--ast-to-instr/src/Outputs.java4
-rw-r--r--ast-to-instr/src/Predicates.java11
-rw-r--r--ast-to-instr/src/Strings.java3
-rw-r--r--ast-to-instr/src/VHDLArchitecture.java267
-rw-r--r--ast-to-instr/src/VHDLComponent.java131
-rw-r--r--ast-to-instr/src/VHDLEntity.java253
-rw-r--r--ast-to-instr/src/VHDLFile.java85
-rw-r--r--ast-to-instr/src/VHDLGeneric.java277
-rw-r--r--ast-to-instr/src/VHDLPort.java366
-rw-r--r--ast-to-instr/src/VHDLProcess.java400
-rw-r--r--ast-to-instr/src/VHDLSignal.java310
-rw-r--r--ast-to-instr/src/XMLManager.java22
14 files changed, 1359 insertions, 803 deletions
diff --git a/ast-to-instr/src/Functions.java b/ast-to-instr/src/Functions.java
new file mode 100644
index 0000000..602c798
--- /dev/null
+++ b/ast-to-instr/src/Functions.java
@@ -0,0 +1,11 @@
+public class Functions
+{
+ public static void add_entry
+ (
+ final String function_name,
+ final IDs... params
+ )
+ {
+ /* TODO */
+ }
+}
diff --git a/ast-to-instr/src/Main.java b/ast-to-instr/src/Main.java
index 1193f52..52c3a8e 100644
--- a/ast-to-instr/src/Main.java
+++ b/ast-to-instr/src/Main.java
@@ -16,25 +16,11 @@ public class Main
static
{
- XPathExpression xpe;
-
- try
- {
- xpe = XMLManager.compile("./*/*/el[@kind=\"design_file\"][@file]");
- }
- catch (final XPathExpressionException xpee)
- {
- xpe = null;
-
- System.err.println
- (
- "[P] Invalid XPath expression (report as bug):"
+ XPE_FIND_ALL_VHDL_FILES =
+ XMLManager.compile_or_die
+ (
+ "./*/*/el[@kind=\"design_file\"][@file]"
);
-
- xpee.printStackTrace();
- }
-
- XPE_FIND_ALL_VHDL_FILES = xpe;
}
public static void main (final String... args)
diff --git a/ast-to-instr/src/Outputs.java b/ast-to-instr/src/Outputs.java
new file mode 100644
index 0000000..0878d93
--- /dev/null
+++ b/ast-to-instr/src/Outputs.java
@@ -0,0 +1,4 @@
+public class Outputs
+{
+ /* TODO */
+}
diff --git a/ast-to-instr/src/Predicates.java b/ast-to-instr/src/Predicates.java
new file mode 100644
index 0000000..9e45cac
--- /dev/null
+++ b/ast-to-instr/src/Predicates.java
@@ -0,0 +1,11 @@
+public class Predicates
+{
+ public static void add_entry
+ (
+ final String predicate_name,
+ final IDs... params
+ )
+ {
+ /* TODO */
+ }
+}
diff --git a/ast-to-instr/src/Strings.java b/ast-to-instr/src/Strings.java
index bc1778f..2c81b70 100644
--- a/ast-to-instr/src/Strings.java
+++ b/ast-to-instr/src/Strings.java
@@ -12,10 +12,11 @@ public class Strings
private Strings () {} /* Utility class. */
- public static IDs get_id_from_string (final String string)
+ public static IDs get_id_from_string (String string)
{
IDs result;
+ string = string.toLowerCase();
result = TO_ID.get(string);
if (result == null)
diff --git a/ast-to-instr/src/VHDLArchitecture.java b/ast-to-instr/src/VHDLArchitecture.java
index ec8aa2a..1865e7a 100644
--- a/ast-to-instr/src/VHDLArchitecture.java
+++ b/ast-to-instr/src/VHDLArchitecture.java
@@ -10,17 +10,29 @@ import java.util.Collection;
public class VHDLArchitecture extends ParsableXML
{
- private static final XPathExpression GET_ENTITIES;
+ private static final XPathExpression XPE_FIND_SIGNALS;
+ private static final XPathExpression XPE_FIND_PROCESSES;
+ private static final XPathExpression XPE_FIND_COMPONENTS;
static
{
- GET_ENTITIES = null;
- /* TODO
- Main.get_xpath().compile
+ XPE_FIND_SIGNALS =
+ XMLManager.compile_or_die
(
+ "./*/el[@kind=\"signal_declaration\"]"
+ );
+
+ XPE_FIND_PROCESSES =
+ XMLManager.compile_or_die
+ (
+ "./*/el[@kind=\"sensitized_process_statement\"]"
+ );
+
+ XPE_FIND_COMPONENTS =
+ XMLManager.compile_or_die
+ (
+ "./*/el[@kind=\"component_instantiation_statement\"]"
);
- */
- // "./*/*/library_unit[@kind=\"entity_declaration\"]"
}
public VHDLArchitecture
@@ -42,7 +54,7 @@ public class VHDLArchitecture extends ParsableXML
result = new ArrayList<ParsableXML>();
- xml_id = null; /* TODO: elem.attrib.get("id") */
+ xml_id = XMLManager.get_attribute(xml_node, "id");
local_id = IDs.get_id_from_xml_id(xml_id, "architecture");
@@ -67,7 +79,7 @@ public class VHDLArchitecture extends ParsableXML
result.addAll(handle_child_processes(local_id));
result.addAll(handle_child_components(local_id));
- return null;
+ return result;
}
/***************************************************************************/
@@ -78,16 +90,7 @@ public class VHDLArchitecture extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- parent_id
- };
-
- /* TODO */
+ Predicates.add_entry("is_in_file", local_id, parent_id);
}
private void handle_link_to_entity
@@ -95,8 +98,6 @@ public class VHDLArchitecture extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
/* TODO */
}
@@ -109,19 +110,15 @@ public class VHDLArchitecture extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- Strings.get_id_from_string
- (
- null /* TODO: get attribute */
- )
- };
-
- /* Functions.add_entry("filename", params); */
+ Functions.add_entry
+ (
+ "line",
+ local_id,
+ Strings.get_id_from_string
+ (
+ XMLManager.get_attribute(xml_node, "line")
+ )
+ );
}
private void handle_function_column
@@ -129,19 +126,15 @@ public class VHDLArchitecture extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- Strings.get_id_from_string
- (
- null /* TODO: get attribute */
- )
- };
-
- /* Functions.add_entry("filename", params); */
+ Functions.add_entry
+ (
+ "column",
+ local_id,
+ Strings.get_id_from_string
+ (
+ XMLManager.get_attribute(xml_node, "col")
+ )
+ );
}
private void handle_function_identifier
@@ -149,19 +142,15 @@ public class VHDLArchitecture extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- Strings.get_id_from_string
- (
- null /* TODO: get attribute */
- )
- };
-
- /* Functions.add_entry("filename", params); */
+ Functions.add_entry
+ (
+ "identifier",
+ local_id,
+ Strings.get_id_from_string
+ (
+ XMLManager.get_attribute(xml_node, "identifier")
+ )
+ );
}
/***************************************************************************/
@@ -172,19 +161,10 @@ public class VHDLArchitecture extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- Strings.get_id_from_string
- (
- null /* TODO: get attribute */
- )
- };
-
- /* Functions.add_entry("filename", params); */
+ if (XMLManager.get_attribute(xml_node, "foreign_flag").equals("true"))
+ {
+ Predicates.add_entry("has_foreign_flag", local_id);
+ }
}
private void handle_predicate_has_visible_flag
@@ -192,19 +172,10 @@ public class VHDLArchitecture extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- Strings.get_id_from_string
- (
- null /* TODO: get attribute */
- )
- };
-
- /* Functions.add_entry("filename", params); */
+ if (XMLManager.get_attribute(xml_node, "visible_flag").equals("true"))
+ {
+ Predicates.add_entry("has_visible_flag", local_id);
+ }
}
private void handle_predicate_is_withing_flag
@@ -212,19 +183,10 @@ public class VHDLArchitecture extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- Strings.get_id_from_string
- (
- null /* TODO: get attribute */
- )
- };
-
- /* Functions.add_entry("filename", params); */
+ if (XMLManager.get_attribute(xml_node, "is_within_flag").equals("true"))
+ {
+ Predicates.add_entry("is_within_flag", local_id);
+ }
}
private void handle_predicate_end_has_reserved_id
@@ -232,19 +194,17 @@ public class VHDLArchitecture extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- Strings.get_id_from_string
- (
- null /* TODO: get attribute */
- )
- };
-
- /* Functions.add_entry("filename", params); */
+ if
+ (
+ XMLManager.get_attribute
+ (
+ xml_node,
+ "end_has_reserved_id"
+ ).equals("true")
+ )
+ {
+ Predicates.add_entry("end_has_reserved_id", local_id);
+ }
}
private void handle_predicate_end_has_identifier
@@ -252,19 +212,17 @@ public class VHDLArchitecture extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- Strings.get_id_from_string
- (
- null /* TODO: get attribute */
- )
- };
-
- /* Functions.add_entry("filename", params); */
+ if
+ (
+ XMLManager.get_attribute
+ (
+ xml_node,
+ "end_has_identifier"
+ ).equals("true")
+ )
+ {
+ Predicates.add_entry("end_has_identifier", local_id);
+ }
}
/***************************************************************************/
@@ -277,17 +235,26 @@ public class VHDLArchitecture extends ParsableXML
throws XPathExpressionException
{
final Collection<ParsableXML> result;
- final NodeList entities;
+ final NodeList signals;
+ final int childrens_count;
+
+ result = new ArrayList<ParsableXML>();
- entities =
- (NodeList) GET_ENTITIES.evaluate
+ signals =
+ (NodeList) XPE_FIND_SIGNALS.evaluate
(
xml_node,
XPathConstants.NODESET
);
- /* TODO */
- return null;
+ childrens_count = signals.getLength();
+
+ for (int i = 0; i < childrens_count; ++i)
+ {
+ result.add(new VHDLSignal(local_id, signals.item(i)));
+ }
+
+ return result;
}
private Collection<ParsableXML> handle_child_processes
@@ -297,9 +264,26 @@ public class VHDLArchitecture extends ParsableXML
throws XPathExpressionException
{
final Collection<ParsableXML> result;
+ final NodeList processes;
+ final int childrens_count;
- /* TODO */
- return null;
+ result = new ArrayList<ParsableXML>();
+
+ processes =
+ (NodeList) XPE_FIND_PROCESSES.evaluate
+ (
+ xml_node,
+ XPathConstants.NODESET
+ );
+
+ childrens_count = processes.getLength();
+
+ for (int i = 0; i < childrens_count; ++i)
+ {
+ result.add(new VHDLProcess(local_id, processes.item(i)));
+ }
+
+ return result;
}
private Collection<ParsableXML> handle_child_components
@@ -309,8 +293,25 @@ public class VHDLArchitecture extends ParsableXML
throws XPathExpressionException
{
final Collection<ParsableXML> result;
+ final NodeList components;
+ final int childrens_count;
- /* TODO */
- return null;
+ result = new ArrayList<ParsableXML>();
+
+ components =
+ (NodeList) XPE_FIND_COMPONENTS.evaluate
+ (
+ xml_node,
+ XPathConstants.NODESET
+ );
+
+ childrens_count = components.getLength();
+
+ for (int i = 0; i < childrens_count; ++i)
+ {
+ result.add(new VHDLComponent(local_id, components.item(i)));
+ }
+
+ return result;
}
}
diff --git a/ast-to-instr/src/VHDLComponent.java b/ast-to-instr/src/VHDLComponent.java
index e22abe9..116b0b8 100644
--- a/ast-to-instr/src/VHDLComponent.java
+++ b/ast-to-instr/src/VHDLComponent.java
@@ -10,17 +10,13 @@ import java.util.Collection;
public class VHDLComponent extends ParsableXML
{
- private static final XPathExpression GET_ENTITIES;
+ private static final XPathExpression XPE_FIND_PORT_MAPS;
+ private static final XPathExpression XPE_FIND_GENERIC_MAPS;
static
{
- GET_ENTITIES = null;
- /* TODO
- Main.get_xpath().compile
- (
- );
- */
- // "./*/*/library_unit[@kind=\"entity_declaration\"]"
+ XPE_FIND_PORT_MAPS = null; /* TODO */
+ XPE_FIND_GENERIC_MAPS = null; /* TODO */
}
public VHDLComponent
@@ -42,7 +38,7 @@ public class VHDLComponent extends ParsableXML
result = new ArrayList<ParsableXML>();
- xml_id = null; /* TODO: elem.attrib.get("id") */
+ xml_id = XMLManager.get_attribute(xml_node, "id");
local_id = IDs.get_id_from_xml_id(xml_id, "component");
@@ -59,7 +55,7 @@ public class VHDLComponent extends ParsableXML
handle_predicate_port_maps(local_id);
handle_predicate_generic_maps(local_id);
- return null;
+ return result;
}
/***************************************************************************/
@@ -70,16 +66,7 @@ public class VHDLComponent extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- parent_id
- };
-
- /* TODO */
+ Predicates.add_entry("belongs_to_architecture", local_id, parent_id);
}
private void handle_link_to_entity
@@ -87,19 +74,9 @@ public class VHDLComponent extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- parent_id
- };
-
/* TODO */
}
-
/***************************************************************************/
/** Functions **************************************************************/
/***************************************************************************/
@@ -108,19 +85,15 @@ public class VHDLComponent extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- Strings.get_id_from_string
- (
- null /* TODO: get attribute */
- )
- };
-
- /* Functions.add_entry("filename", params); */
+ Functions.add_entry
+ (
+ "line",
+ local_id,
+ Strings.get_id_from_string
+ (
+ XMLManager.get_attribute(xml_node, "line")
+ )
+ );
}
private void handle_function_column
@@ -128,19 +101,15 @@ public class VHDLComponent extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- Strings.get_id_from_string
- (
- null /* TODO: get attribute */
- )
- };
-
- /* Functions.add_entry("filename", params); */
+ Functions.add_entry
+ (
+ "column",
+ local_id,
+ Strings.get_id_from_string
+ (
+ XMLManager.get_attribute(xml_node, "col")
+ )
+ );
}
private void handle_function_label
@@ -148,19 +117,15 @@ public class VHDLComponent extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- Strings.get_id_from_string
- (
- null /* TODO: get attribute */
- )
- };
-
- /* Functions.add_entry("filename", params); */
+ Functions.add_entry
+ (
+ "label",
+ local_id,
+ Strings.get_id_from_string
+ (
+ XMLManager.get_attribute(xml_node, "label")
+ )
+ );
}
/***************************************************************************/
@@ -171,19 +136,7 @@ public class VHDLComponent extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- Strings.get_id_from_string
- (
- null /* TODO: get attribute */
- )
- };
-
- /* Functions.add_entry("filename", params); */
+ /* TODO */
}
private void handle_predicate_generic_maps
@@ -191,18 +144,6 @@ public class VHDLComponent extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- Strings.get_id_from_string
- (
- null /* TODO: get attribute */
- )
- };
-
- /* Functions.add_entry("filename", params); */
+ /* TODO */
}
}
diff --git a/ast-to-instr/src/VHDLEntity.java b/ast-to-instr/src/VHDLEntity.java
index f56355c..66e041d 100644
--- a/ast-to-instr/src/VHDLEntity.java
+++ b/ast-to-instr/src/VHDLEntity.java
@@ -10,17 +10,13 @@ import java.util.Collection;
public class VHDLEntity extends ParsableXML
{
- private static final XPathExpression GET_ENTITIES;
+ private static final XPathExpression XPE_FIND_PORTS;
+ private static final XPathExpression XPE_FIND_GENERICS;
static
{
- GET_ENTITIES = null;
- /* TODO
- Main.get_xpath().compile
- (
- );
- */
- // "./*/*/library_unit[@kind=\"entity_declaration\"]"
+ XPE_FIND_PORTS = null; /* TODO */
+ XPE_FIND_GENERICS = null; /* TODO */
}
public VHDLEntity
@@ -42,7 +38,7 @@ public class VHDLEntity extends ParsableXML
result = new ArrayList<ParsableXML>();
- xml_id = null; /* TODO: elem.attrib.get("id") */
+ xml_id = XMLManager.get_attribute(xml_node, "id");
local_id = IDs.get_id_from_xml_id(xml_id, "entity");
@@ -65,7 +61,7 @@ public class VHDLEntity extends ParsableXML
result.addAll(handle_child_ports(local_id));
result.addAll(handle_child_generics(local_id));
- return null;
+ return result;
}
/***************************************************************************/
@@ -76,16 +72,7 @@ public class VHDLEntity extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- parent_id
- };
-
- /* TODO */
+ Predicates.add_entry("is_in_file", local_id, parent_id);
}
@@ -97,19 +84,15 @@ public class VHDLEntity extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- Strings.get_id_from_string
- (
- null /* TODO: get attribute */
- )
- };
-
- /* Functions.add_entry("filename", params); */
+ Functions.add_entry
+ (
+ "line",
+ local_id,
+ Strings.get_id_from_string
+ (
+ XMLManager.get_attribute(xml_node, "line")
+ )
+ );
}
private void handle_function_column
@@ -117,19 +100,15 @@ public class VHDLEntity extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- Strings.get_id_from_string
- (
- null /* TODO: get attribute */
- )
- };
-
- /* Functions.add_entry("filename", params); */
+ Functions.add_entry
+ (
+ "column",
+ local_id,
+ Strings.get_id_from_string
+ (
+ XMLManager.get_attribute(xml_node, "col")
+ )
+ );
}
private void handle_function_identifier
@@ -137,19 +116,15 @@ public class VHDLEntity extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- Strings.get_id_from_string
- (
- null /* TODO: get attribute */
- )
- };
-
- /* Functions.add_entry("filename", params); */
+ Functions.add_entry
+ (
+ "identifier",
+ local_id,
+ Strings.get_id_from_string
+ (
+ XMLManager.get_attribute(xml_node, "col")
+ )
+ );
}
/***************************************************************************/
@@ -160,19 +135,17 @@ public class VHDLEntity extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- Strings.get_id_from_string
- (
- null /* TODO: get attribute */
- )
- };
-
- /* Functions.add_entry("filename", params); */
+ if
+ (
+ XMLManager.get_attribute
+ (
+ xml_node,
+ "has_begin"
+ ).equals("true")
+ )
+ {
+ Predicates.add_entry("has_begin", local_id);
+ }
}
private void handle_predicate_has_visible_flag
@@ -180,19 +153,17 @@ public class VHDLEntity extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- Strings.get_id_from_string
- (
- null /* TODO: get attribute */
- )
- };
-
- /* Functions.add_entry("filename", params); */
+ if
+ (
+ XMLManager.get_attribute
+ (
+ xml_node,
+ "visible_flag"
+ ).equals("true")
+ )
+ {
+ Predicates.add_entry("has_visible_flag", local_id);
+ }
}
private void handle_predicate_is_withing_flag
@@ -200,19 +171,17 @@ public class VHDLEntity extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- Strings.get_id_from_string
- (
- null /* TODO: get attribute */
- )
- };
-
- /* Functions.add_entry("filename", params); */
+ if
+ (
+ XMLManager.get_attribute
+ (
+ xml_node,
+ "is_within_flag"
+ ).equals("true")
+ )
+ {
+ Predicates.add_entry("is_within_flag", local_id);
+ }
}
private void handle_predicate_end_has_reserved_id
@@ -220,19 +189,17 @@ public class VHDLEntity extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- Strings.get_id_from_string
- (
- null /* TODO: get attribute */
- )
- };
-
- /* Functions.add_entry("filename", params); */
+ if
+ (
+ XMLManager.get_attribute
+ (
+ xml_node,
+ "end_has_reserved_id"
+ ).equals("true")
+ )
+ {
+ Predicates.add_entry("end_has_reserved_id", local_id);
+ }
}
private void handle_predicate_end_has_identifier
@@ -240,19 +207,17 @@ public class VHDLEntity extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- Strings.get_id_from_string
- (
- null /* TODO: get attribute */
- )
- };
-
- /* Functions.add_entry("filename", params); */
+ if
+ (
+ XMLManager.get_attribute
+ (
+ xml_node,
+ "end_has_identifier"
+ ).equals("true")
+ )
+ {
+ Predicates.add_entry("end_has_identifier", local_id);
+ }
}
/***************************************************************************/
@@ -265,17 +230,26 @@ public class VHDLEntity extends ParsableXML
throws XPathExpressionException
{
final Collection<ParsableXML> result;
- final NodeList entities;
+ final NodeList ports;
+ final int childrens_count;
+
+ result = new ArrayList<ParsableXML>();
- entities =
- (NodeList) GET_ENTITIES.evaluate
+ ports =
+ (NodeList) XPE_FIND_PORTS.evaluate
(
xml_node,
XPathConstants.NODESET
);
- /* TODO */
- return null;
+ childrens_count = ports.getLength();
+
+ for (int i = 0; i < childrens_count; ++i)
+ {
+ result.add(new VHDLPort(local_id, ports.item(i)));
+ }
+
+ return result;
}
private Collection<ParsableXML> handle_child_generics
@@ -285,8 +259,25 @@ public class VHDLEntity extends ParsableXML
throws XPathExpressionException
{
final Collection<ParsableXML> result;
+ final NodeList generics;
+ final int childrens_count;
+
+ result = new ArrayList<ParsableXML>();
+
+ generics =
+ (NodeList) XPE_FIND_PORTS.evaluate
+ (
+ xml_node,
+ XPathConstants.NODESET
+ );
+
+ childrens_count = generics.getLength();
+
+ for (int i = 0; i < childrens_count; ++i)
+ {
+ result.add(new VHDLGeneric(local_id, generics.item(i)));
+ }
- /* TODO */
- return null;
+ return result;
}
}
diff --git a/ast-to-instr/src/VHDLFile.java b/ast-to-instr/src/VHDLFile.java
index beef2fe..6561603 100644
--- a/ast-to-instr/src/VHDLFile.java
+++ b/ast-to-instr/src/VHDLFile.java
@@ -10,17 +10,22 @@ import java.util.Collection;
public class VHDLFile extends ParsableXML
{
- private static final XPathExpression GET_ENTITIES;
+ private static final XPathExpression XPE_FIND_ENTITIES;
+ private static final XPathExpression XPE_FIND_ARCHITECTURES;
static
{
- GET_ENTITIES = null;
- /* TODO
- Main.get_xpath().compile
+ XPE_FIND_ENTITIES =
+ XMLManager.compile_or_die
(
+ "./*/*/library_unit[@kind=\"entity_declaration\"]"
+ );
+
+ XPE_FIND_ARCHITECTURES =
+ XMLManager.compile_or_die
+ (
+ "./*/*/library_unit[@kind=\"entity_declaration\"]"
);
- */
- // "./*/*/library_unit[@kind=\"entity_declaration\"]"
}
public VHDLFile
@@ -42,7 +47,7 @@ public class VHDLFile extends ParsableXML
result = new ArrayList<ParsableXML>();
- xml_id = null; /* TODO: elem.attrib.get("id") */
+ xml_id = XMLManager.get_attribute(xml_node, "id");
local_id = IDs.get_id_from_xml_id(xml_id, "file");
@@ -55,29 +60,31 @@ public class VHDLFile extends ParsableXML
result.addAll(handle_child_entities(local_id));
result.addAll(handle_child_architectures(local_id));
- return null;
+ return result;
}
+ /***************************************************************************/
+ /** Functions **************************************************************/
+ /***************************************************************************/
private void handle_function_filename
(
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- Strings.get_id_from_string
- (
- null /* TODO: get attribute */
- )
- };
-
- /* Functions.add_entry("filename", params); */
+ Functions.add_entry
+ (
+ "filename",
+ local_id,
+ Strings.get_id_from_string
+ (
+ XMLManager.get_attribute(xml_node, "file")
+ )
+ );
}
+ /***************************************************************************/
+ /** Children ***************************************************************/
+ /***************************************************************************/
private Collection<ParsableXML> handle_child_entities
(
final IDs local_id
@@ -86,16 +93,25 @@ public class VHDLFile extends ParsableXML
{
final Collection<ParsableXML> result;
final NodeList entities;
+ final int childrens_count;
+
+ result = new ArrayList<ParsableXML>();
entities =
- (NodeList) GET_ENTITIES.evaluate
+ (NodeList) XPE_FIND_ENTITIES.evaluate
(
xml_node,
XPathConstants.NODESET
);
- /* TODO */
- return null;
+ childrens_count = entities.getLength();
+
+ for (int i = 0; i < childrens_count; ++i)
+ {
+ result.add(new VHDLEntity(local_id, entities.item(i)));
+ }
+
+ return result;
}
private Collection<ParsableXML> handle_child_architectures
@@ -105,8 +121,25 @@ public class VHDLFile extends ParsableXML
throws XPathExpressionException
{
final Collection<ParsableXML> result;
+ final NodeList architectures;
+ final int childrens_count;
+
+ result = new ArrayList<ParsableXML>();
+
+ architectures =
+ (NodeList) XPE_FIND_ENTITIES.evaluate
+ (
+ xml_node,
+ XPathConstants.NODESET
+ );
+
+ childrens_count = architectures.getLength();
+
+ for (int i = 0; i < childrens_count; ++i)
+ {
+ result.add(new VHDLArchitecture(local_id, architectures.item(i)));
+ }
- /* TODO */
- return null;
+ return result;
}
}
diff --git a/ast-to-instr/src/VHDLGeneric.java b/ast-to-instr/src/VHDLGeneric.java
new file mode 100644
index 0000000..7184f61
--- /dev/null
+++ b/ast-to-instr/src/VHDLGeneric.java
@@ -0,0 +1,277 @@
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpression;
+import javax.xml.xpath.XPathExpressionException;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+public class VHDLGeneric extends ParsableXML
+{
+ private static final XPathExpression GET_ENTITIES;
+
+ static
+ {
+ /* TODO */
+ GET_ENTITIES = null;
+ }
+
+ public VHDLGeneric
+ (
+ final IDs parent_id,
+ final Node xml_node
+ )
+ {
+ super(parent_id, xml_node);
+ }
+
+ @Override
+ public Collection<ParsableXML> parse ()
+ throws XPathExpressionException
+ {
+ final Collection<ParsableXML> result;
+ final String xml_id;
+ final IDs local_id;
+
+ result = new ArrayList<ParsableXML>();
+
+ xml_id = XMLManager.get_attribute(xml_node, "id");
+
+ local_id = IDs.get_id_from_xml_id(xml_id, "generic");
+
+ /** Parent **************************************************************/
+ handle_link_to_entity(local_id);
+
+ /** Functions ***********************************************************/
+ handle_function_line(local_id);
+ handle_function_column(local_id);
+ handle_function_identifier(local_id);
+
+ /** Predicates **********************************************************/
+ handle_predicate_has_class(local_id);
+ handle_predicate_is_ref(local_id);
+ handle_predicate_has_identifier_list(local_id);
+ handle_predicate_has_visible_flag(local_id);
+ handle_predicate_has_after_drivers_flag(local_id);
+ handle_predicate_has_use_flag(local_id);
+ handle_predicate_has_guarded_signal_flag(local_id);
+
+ /** Children ************************************************************/
+ handle_child_waveform(local_id);
+
+ return null;
+ }
+
+ /***************************************************************************/
+ /** Parents ****************************************************************/
+ /***************************************************************************/
+ private void handle_link_to_entity
+ (
+ final IDs local_id
+ )
+ {
+ Predicates.add_entry("is_port_of", local_id, parent_id);
+ }
+
+
+ /***************************************************************************/
+ /** Functions **************************************************************/
+ /***************************************************************************/
+ private void handle_function_line
+ (
+ final IDs local_id
+ )
+ {
+ Functions.add_entry
+ (
+ "line",
+ local_id,
+ Strings.get_id_from_string
+ (
+ XMLManager.get_attribute(xml_node, "line")
+ )
+ );
+ }
+
+ private void handle_function_column
+ (
+ final IDs local_id
+ )
+ {
+ Functions.add_entry
+ (
+ "column",
+ local_id,
+ Strings.get_id_from_string
+ (
+ XMLManager.get_attribute(xml_node, "col")
+ )
+ );
+ }
+
+ private void handle_function_identifier
+ (
+ final IDs local_id
+ )
+ {
+ Functions.add_entry
+ (
+ "identifier",
+ local_id,
+ Strings.get_id_from_string
+ (
+ XMLManager.get_attribute(xml_node, "identifier")
+ )
+ );
+ }
+
+ /***************************************************************************/
+ /** Predicates *************************************************************/
+ /***************************************************************************/
+ private void handle_predicate_has_class
+ (
+ final IDs local_id
+ )
+ {
+ if
+ (
+ XMLManager.get_attribute
+ (
+ xml_node,
+ "has_class"
+ ).equals("true")
+ )
+ {
+ Predicates.add_entry("has_class", local_id);
+ }
+ }
+
+ private void handle_predicate_is_ref
+ (
+ final IDs local_id
+ )
+ {
+ if
+ (
+ XMLManager.get_attribute
+ (
+ xml_node,
+ "is_ref"
+ ).equals("true")
+ )
+ {
+ Predicates.add_entry("is_ref", local_id);
+ }
+ }
+
+ private void handle_predicate_has_identifier_list
+ (
+ final IDs local_id
+ )
+ {
+ if
+ (
+ XMLManager.get_attribute
+ (
+ xml_node,
+ "has_identifier_list"
+ ).equals("true")
+ )
+ {
+ Predicates.add_entry("has_identifier_list", local_id);
+ }
+ }
+
+ private void handle_predicate_has_visible_flag
+ (
+ final IDs local_id
+ )
+ {
+ if
+ (
+ XMLManager.get_attribute
+ (
+ xml_node,
+ "visible_flag"
+ ).equals("true")
+ )
+ {
+ Predicates.add_entry("has_visible_flag", local_id);
+ }
+ }
+
+ private void handle_predicate_has_after_drivers_flag
+ (
+ final IDs local_id
+ )
+ {
+ if
+ (
+ XMLManager.get_attribute
+ (
+ xml_node,
+ "after_drivers_flag"
+ ).equals("true")
+ )
+ {
+ Predicates.add_entry("has_after_drivers_flag", local_id);
+ }
+ }
+
+ private void handle_predicate_has_use_flag
+ (
+ final IDs local_id
+ )
+ {
+ if
+ (
+ XMLManager.get_attribute
+ (
+ xml_node,
+ "use_flag"
+ ).equals("true")
+ )
+ {
+ Predicates.add_entry("has_use_flag", local_id);
+ }
+ }
+
+ private void handle_predicate_has_guarded_signal_flag
+ (
+ final IDs local_id
+ )
+ {
+ if
+ (
+ XMLManager.get_attribute
+ (
+ xml_node,
+ "guarded_signal_flag"
+ ).equals("true")
+ )
+ {
+ Predicates.add_entry("has_guarded_signal_flag", local_id);
+ }
+ }
+
+ /***************************************************************************/
+ /** Children ***************************************************************/
+ /***************************************************************************/
+ private void handle_child_waveform
+ (
+ final IDs local_id
+ )
+ {
+ Predicates.add_entry
+ (
+ "is_waveform_of",
+ Waveforms.get_associated_waveform_id
+ (
+ local_id
+ ),
+ local_id
+ );
+ }
+}
diff --git a/ast-to-instr/src/VHDLPort.java b/ast-to-instr/src/VHDLPort.java
new file mode 100644
index 0000000..062159c
--- /dev/null
+++ b/ast-to-instr/src/VHDLPort.java
@@ -0,0 +1,366 @@
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpression;
+import javax.xml.xpath.XPathExpressionException;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+public class VHDLPort extends ParsableXML
+{
+ private static final XPathExpression GET_ENTITIES;
+
+ static
+ {
+ /* TODO */
+ GET_ENTITIES = null;
+ }
+
+ public VHDLPort
+ (
+ final IDs parent_id,
+ final Node xml_node
+ )
+ {
+ super(parent_id, xml_node);
+ }
+
+ @Override
+ public Collection<ParsableXML> parse ()
+ throws XPathExpressionException
+ {
+ final Collection<ParsableXML> result;
+ final String xml_id;
+ final IDs local_id;
+
+ result = new ArrayList<ParsableXML>();
+
+ xml_id = XMLManager.get_attribute(xml_node, "id");
+
+ local_id = IDs.get_id_from_xml_id(xml_id, "port");
+
+ /** Parent **************************************************************/
+ handle_link_to_entity(local_id);
+
+ /** Functions ***********************************************************/
+ handle_function_line(local_id);
+ handle_function_column(local_id);
+ handle_function_identifier(local_id);
+
+ /** Predicates **********************************************************/
+ handle_predicate_has_disconnect_flag(local_id);
+ handle_predicate_has_class(local_id);
+ handle_predicate_is_ref(local_id);
+ handle_predicate_has_active_flag(local_id);
+ handle_predicate_has_identifier_list(local_id);
+ handle_predicate_has_visible_flag(local_id);
+ handle_predicate_has_after_drivers_flag(local_id);
+ handle_predicate_has_use_flag(local_id);
+ handle_predicate_has_open_flag(local_id);
+ handle_predicate_has_guarded_signal_flag(local_id);
+
+ handle_predicate_has_mode(local_id);
+
+ /** Children ************************************************************/
+ handle_child_waveform(local_id);
+
+ return null;
+ }
+
+ /***************************************************************************/
+ /** Parents ****************************************************************/
+ /***************************************************************************/
+ private void handle_link_to_entity
+ (
+ final IDs local_id
+ )
+ {
+ Predicates.add_entry("is_port_of", local_id, parent_id);
+ }
+
+
+ /***************************************************************************/
+ /** Functions **************************************************************/
+ /***************************************************************************/
+ private void handle_function_line
+ (
+ final IDs local_id
+ )
+ {
+ Functions.add_entry
+ (
+ "line",
+ local_id,
+ Strings.get_id_from_string
+ (
+ XMLManager.get_attribute(xml_node, "line")
+ )
+ );
+ }
+
+ private void handle_function_column
+ (
+ final IDs local_id
+ )
+ {
+ Functions.add_entry
+ (
+ "column",
+ local_id,
+ Strings.get_id_from_string
+ (
+ XMLManager.get_attribute(xml_node, "col")
+ )
+ );
+ }
+
+ private void handle_function_identifier
+ (
+ final IDs local_id
+ )
+ {
+ Functions.add_entry
+ (
+ "identifier",
+ local_id,
+ Strings.get_id_from_string
+ (
+ XMLManager.get_attribute(xml_node, "identifier")
+ )
+ );
+ }
+
+ /***************************************************************************/
+ /** Predicates *************************************************************/
+ /***************************************************************************/
+ private void handle_predicate_has_disconnect_flag
+ (
+ final IDs local_id
+ )
+ {
+ if
+ (
+ XMLManager.get_attribute
+ (
+ xml_node,
+ "has_disconnect_flag"
+ ).equals("true")
+ )
+ {
+ Predicates.add_entry("has_disconnect_flag", local_id);
+ }
+ }
+
+ private void handle_predicate_has_class
+ (
+ final IDs local_id
+ )
+ {
+ if
+ (
+ XMLManager.get_attribute
+ (
+ xml_node,
+ "has_class"
+ ).equals("true")
+ )
+ {
+ Predicates.add_entry("has_class", local_id);
+ }
+ }
+
+ private void handle_predicate_is_ref
+ (
+ final IDs local_id
+ )
+ {
+ if
+ (
+ XMLManager.get_attribute
+ (
+ xml_node,
+ "is_ref"
+ ).equals("true")
+ )
+ {
+ Predicates.add_entry("is_ref", local_id);
+ }
+ }
+
+ private void handle_predicate_has_active_flag
+ (
+ final IDs local_id
+ )
+ {
+ if
+ (
+ XMLManager.get_attribute
+ (
+ xml_node,
+ "has_active_flag"
+ ).equals("true")
+ )
+ {
+ Predicates.add_entry("has_active_flag", local_id);
+ }
+ }
+
+ private void handle_predicate_has_identifier_list
+ (
+ final IDs local_id
+ )
+ {
+ if
+ (
+ XMLManager.get_attribute
+ (
+ xml_node,
+ "has_identifier_list"
+ ).equals("true")
+ )
+ {
+ Predicates.add_entry("has_identifier_list", local_id);
+ }
+ }
+
+ private void handle_predicate_has_visible_flag
+ (
+ final IDs local_id
+ )
+ {
+ if
+ (
+ XMLManager.get_attribute
+ (
+ xml_node,
+ "visible_flag"
+ ).equals("true")
+ )
+ {
+ Predicates.add_entry("has_visible_flag", local_id);
+ }
+ }
+
+ private void handle_predicate_has_after_drivers_flag
+ (
+ final IDs local_id
+ )
+ {
+ if
+ (
+ XMLManager.get_attribute
+ (
+ xml_node,
+ "after_drivers_flag"
+ ).equals("true")
+ )
+ {
+ Predicates.add_entry("has_after_drivers_flag", local_id);
+ }
+ }
+
+ private void handle_predicate_has_use_flag
+ (
+ final IDs local_id
+ )
+ {
+ if
+ (
+ XMLManager.get_attribute
+ (
+ xml_node,
+ "use_flag"
+ ).equals("true")
+ )
+ {
+ Predicates.add_entry("has_use_flag", local_id);
+ }
+ }
+
+ private void handle_predicate_has_open_flag
+ (
+ final IDs local_id
+ )
+ {
+ if
+ (
+ XMLManager.get_attribute
+ (
+ xml_node,
+ "open_flag"
+ ).equals("true")
+ )
+ {
+ Predicates.add_entry("has_open_flag", local_id);
+ }
+ }
+
+ private void handle_predicate_has_guarded_signal_flag
+ (
+ final IDs local_id
+ )
+ {
+ if
+ (
+ XMLManager.get_attribute
+ (
+ xml_node,
+ "guarded_signal_flag"
+ ).equals("true")
+ )
+ {
+ Predicates.add_entry("has_guarded_signal_flag", local_id);
+ }
+ }
+
+ private void handle_predicate_has_mode
+ (
+ final IDs local_id
+ )
+ {
+ if
+ (
+ XMLManager.get_attribute
+ (
+ xml_node,
+ "has_mode"
+ ).equals("true")
+ )
+ {
+ Predicates.add_entry
+ (
+ "has_mode",
+ local_id,
+ Strings.get_id_from_string
+ (
+ XMLManager.get_attribute
+ (
+ xml_node,
+ "mode"
+ )
+ )
+ );
+ }
+ }
+
+ /***************************************************************************/
+ /** Children ***************************************************************/
+ /***************************************************************************/
+ private void handle_child_waveform
+ (
+ final IDs local_id
+ )
+ {
+ Predicates.add_entry
+ (
+ "is_waveform_of",
+ Waveforms.get_associated_waveform_id
+ (
+ local_id
+ ),
+ local_id
+ );
+ }
+}
diff --git a/ast-to-instr/src/VHDLProcess.java b/ast-to-instr/src/VHDLProcess.java
index 1979424..a51816c 100644
--- a/ast-to-instr/src/VHDLProcess.java
+++ b/ast-to-instr/src/VHDLProcess.java
@@ -14,13 +14,8 @@ public class VHDLProcess extends ParsableXML
static
{
+ /* TODO */
GET_ENTITIES = null;
- /* TODO
- Main.get_xpath().compile
- (
- );
- */
- // "./*/*/library_unit[@kind=\"entity_declaration\"]"
}
public VHDLProcess
@@ -42,7 +37,7 @@ public class VHDLProcess extends ParsableXML
result = new ArrayList<ParsableXML>();
- xml_id = null; /* TODO: elem.attrib.get("id") */
+ xml_id = XMLManager.get_attribute(xml_node, "id");
local_id = IDs.get_id_from_xml_id(xml_id, "process");
@@ -61,6 +56,7 @@ public class VHDLProcess extends ParsableXML
handle_predicate_has_passive_flag(local_id);
handle_predicate_has_postponed_flag(local_id);
handle_predicate_has_visible_flag(local_id);
+ handle_predicate_is_within_flag(local_id);
handle_predicate_has_label(local_id);
handle_predicate_has_is(local_id);
handle_predicate_end_has_reserved_id(local_id);
@@ -73,7 +69,7 @@ public class VHDLProcess extends ParsableXML
/** Children ************************************************************/
result.addAll(handle_child_nodes(local_id));
- return null;
+ return result;
}
/***************************************************************************/
@@ -84,19 +80,9 @@ public class VHDLProcess extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- parent_id
- };
-
- /* TODO */
+ Predicates.add_entry("belongs_to_architecture", local_id, parent_id);
}
-
/***************************************************************************/
/** Functions **************************************************************/
/***************************************************************************/
@@ -105,19 +91,15 @@ public class VHDLProcess extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- Strings.get_id_from_string
- (
- null /* TODO: get attribute */
- )
- };
-
- /* Functions.add_entry("filename", params); */
+ Functions.add_entry
+ (
+ "line",
+ local_id,
+ Strings.get_id_from_string
+ (
+ XMLManager.get_attribute(xml_node, "line")
+ )
+ );
}
private void handle_function_column
@@ -125,19 +107,15 @@ public class VHDLProcess extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- Strings.get_id_from_string
- (
- null /* TODO: get attribute */
- )
- };
-
- /* Functions.add_entry("filename", params); */
+ Functions.add_entry
+ (
+ "column",
+ local_id,
+ Strings.get_id_from_string
+ (
+ XMLManager.get_attribute(xml_node, "col")
+ )
+ );
}
private void handle_function_label
@@ -145,19 +123,15 @@ public class VHDLProcess extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- Strings.get_id_from_string
- (
- null /* TODO: get attribute */
- )
- };
-
- /* Functions.add_entry("filename", params); */
+ Functions.add_entry
+ (
+ "label",
+ local_id,
+ Strings.get_id_from_string
+ (
+ XMLManager.get_attribute(xml_node, "label")
+ )
+ );
}
/***************************************************************************/
@@ -168,19 +142,17 @@ public class VHDLProcess extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- Strings.get_id_from_string
- (
- null /* TODO: get attribute */
- )
- };
-
- /* Functions.add_entry("filename", params); */
+ if
+ (
+ XMLManager.get_attribute
+ (
+ xml_node,
+ "seen_flag"
+ ).equals("true")
+ )
+ {
+ Predicates.add_entry("has_seen_flag", local_id);
+ }
}
private void handle_predicate_end_has_postponed
@@ -188,19 +160,17 @@ public class VHDLProcess extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- Strings.get_id_from_string
- (
- null /* TODO: get attribute */
- )
- };
-
- /* Functions.add_entry("filename", params); */
+ if
+ (
+ XMLManager.get_attribute
+ (
+ xml_node,
+ "end_has_postponed"
+ ).equals("true")
+ )
+ {
+ Predicates.add_entry("end_has_postponed", local_id);
+ }
}
private void handle_predicate_is_ref
@@ -208,19 +178,17 @@ public class VHDLProcess extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- Strings.get_id_from_string
- (
- null /* TODO: get attribute */
- )
- };
-
- /* Functions.add_entry("filename", params); */
+ if
+ (
+ XMLManager.get_attribute
+ (
+ xml_node,
+ "is_ref"
+ ).equals("true")
+ )
+ {
+ Predicates.add_entry("is_ref", local_id);
+ }
}
private void handle_predicate_has_passive_flag
@@ -228,19 +196,17 @@ public class VHDLProcess extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- Strings.get_id_from_string
- (
- null /* TODO: get attribute */
- )
- };
-
- /* Functions.add_entry("filename", params); */
+ if
+ (
+ XMLManager.get_attribute
+ (
+ xml_node,
+ "passive_flag"
+ ).equals("true")
+ )
+ {
+ Predicates.add_entry("has_passive_flag", local_id);
+ }
}
private void handle_predicate_has_postponed_flag
@@ -248,19 +214,17 @@ public class VHDLProcess extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- Strings.get_id_from_string
- (
- null /* TODO: get attribute */
- )
- };
-
- /* Functions.add_entry("filename", params); */
+ if
+ (
+ XMLManager.get_attribute
+ (
+ xml_node,
+ "postponed_flag"
+ ).equals("true")
+ )
+ {
+ Predicates.add_entry("has_postponed_flag", local_id);
+ }
}
private void handle_predicate_has_visible_flag
@@ -268,19 +232,35 @@ public class VHDLProcess extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- Strings.get_id_from_string
- (
- null /* TODO: get attribute */
- )
- };
-
- /* Functions.add_entry("filename", params); */
+ if
+ (
+ XMLManager.get_attribute
+ (
+ xml_node,
+ "visible_flag"
+ ).equals("true")
+ )
+ {
+ Predicates.add_entry("has_visible_flag", local_id);
+ }
+ }
+
+ private void handle_predicate_is_within_flag
+ (
+ final IDs local_id
+ )
+ {
+ if
+ (
+ XMLManager.get_attribute
+ (
+ xml_node,
+ "is_within_flag"
+ ).equals("true")
+ )
+ {
+ Predicates.add_entry("is_within_flag", local_id);
+ }
}
private void handle_predicate_has_label
@@ -288,19 +268,17 @@ public class VHDLProcess extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- Strings.get_id_from_string
- (
- null /* TODO: get attribute */
- )
- };
-
- /* Functions.add_entry("filename", params); */
+ if
+ (
+ XMLManager.get_attribute
+ (
+ xml_node,
+ "has_label"
+ ).equals("true")
+ )
+ {
+ Predicates.add_entry("has_label", local_id);
+ }
}
private void handle_predicate_has_is
@@ -308,19 +286,17 @@ public class VHDLProcess extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- Strings.get_id_from_string
- (
- null /* TODO: get attribute */
- )
- };
-
- /* Functions.add_entry("filename", params); */
+ if
+ (
+ XMLManager.get_attribute
+ (
+ xml_node,
+ "has_is"
+ ).equals("true")
+ )
+ {
+ Predicates.add_entry("has_is", local_id);
+ }
}
private void handle_predicate_end_has_reserved_id
@@ -328,19 +304,17 @@ public class VHDLProcess extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- Strings.get_id_from_string
- (
- null /* TODO: get attribute */
- )
- };
-
- /* Functions.add_entry("filename", params); */
+ if
+ (
+ XMLManager.get_attribute
+ (
+ xml_node,
+ "end_has_reserved_id"
+ ).equals("true")
+ )
+ {
+ Predicates.add_entry("end_has_reserved_id", local_id);
+ }
}
private void handle_predicate_end_has_identifier
@@ -348,19 +322,17 @@ public class VHDLProcess extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- Strings.get_id_from_string
- (
- null /* TODO: get attribute */
- )
- };
-
- /* Functions.add_entry("filename", params); */
+ if
+ (
+ XMLManager.get_attribute
+ (
+ xml_node,
+ "end_has_identifier"
+ ).equals("true")
+ )
+ {
+ Predicates.add_entry("end_has_identifier", local_id);
+ }
}
private void handle_predicate_is_explicit_process
@@ -368,19 +340,17 @@ public class VHDLProcess extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- Strings.get_id_from_string
- (
- null /* TODO: get attribute */
- )
- };
-
- /* Functions.add_entry("filename", params); */
+ if
+ (
+ XMLManager.get_attribute
+ (
+ xml_node,
+ "is_ref"
+ ).equals("false")
+ )
+ {
+ Predicates.add_entry("is_explicit_process", local_id);
+ }
}
private void handle_predicate_is_in_sensitivity_list
@@ -388,19 +358,7 @@ public class VHDLProcess extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- Strings.get_id_from_string
- (
- null /* TODO: get attribute */
- )
- };
-
- /* Functions.add_entry("filename", params); */
+ /* TODO */
}
private void handle_predicate_is_accessed_by
@@ -408,19 +366,7 @@ public class VHDLProcess extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- Strings.get_id_from_string
- (
- null /* TODO: get attribute */
- )
- };
-
- /* Functions.add_entry("filename", params); */
+ /* TODO */
}
/***************************************************************************/
diff --git a/ast-to-instr/src/VHDLSignal.java b/ast-to-instr/src/VHDLSignal.java
index 9dffe73..1ea12d6 100644
--- a/ast-to-instr/src/VHDLSignal.java
+++ b/ast-to-instr/src/VHDLSignal.java
@@ -14,13 +14,8 @@ public class VHDLSignal extends ParsableXML
static
{
+ /* TODO */
GET_ENTITIES = null;
- /* TODO
- Main.get_xpath().compile
- (
- );
- */
- // "./*/*/library_unit[@kind=\"entity_declaration\"]"
}
public VHDLSignal
@@ -42,7 +37,7 @@ public class VHDLSignal extends ParsableXML
result = new ArrayList<ParsableXML>();
- xml_id = null; /* TODO: elem.attrib.get("id") */
+ xml_id = XMLManager.get_attribute(xml_node, "id");
local_id = IDs.get_id_from_xml_id(xml_id, "signal");
@@ -80,16 +75,7 @@ public class VHDLSignal extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- parent_id
- };
-
- /* TODO */
+ Predicates.add_entry("belongs_to_architecture", local_id, parent_id);
}
@@ -101,19 +87,15 @@ public class VHDLSignal extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- Strings.get_id_from_string
- (
- null /* TODO: get attribute */
- )
- };
-
- /* Functions.add_entry("filename", params); */
+ Functions.add_entry
+ (
+ "line",
+ local_id,
+ Strings.get_id_from_string
+ (
+ XMLManager.get_attribute(xml_node, "line")
+ )
+ );
}
private void handle_function_column
@@ -121,19 +103,15 @@ public class VHDLSignal extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- Strings.get_id_from_string
- (
- null /* TODO: get attribute */
- )
- };
-
- /* Functions.add_entry("filename", params); */
+ Functions.add_entry
+ (
+ "column",
+ local_id,
+ Strings.get_id_from_string
+ (
+ XMLManager.get_attribute(xml_node, "col")
+ )
+ );
}
private void handle_function_identifier
@@ -141,19 +119,15 @@ public class VHDLSignal extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- Strings.get_id_from_string
- (
- null /* TODO: get attribute */
- )
- };
-
- /* Functions.add_entry("filename", params); */
+ Functions.add_entry
+ (
+ "identifier",
+ local_id,
+ Strings.get_id_from_string
+ (
+ XMLManager.get_attribute(xml_node, "identifier")
+ )
+ );
}
/***************************************************************************/
@@ -164,19 +138,17 @@ public class VHDLSignal extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- Strings.get_id_from_string
- (
- null /* TODO: get attribute */
- )
- };
-
- /* Functions.add_entry("filename", params); */
+ if
+ (
+ XMLManager.get_attribute
+ (
+ xml_node,
+ "has_disconnect_flag"
+ ).equals("true")
+ )
+ {
+ Predicates.add_entry("has_disconnect_flag", local_id);
+ }
}
private void handle_predicate_is_ref
@@ -184,19 +156,17 @@ public class VHDLSignal extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- Strings.get_id_from_string
- (
- null /* TODO: get attribute */
- )
- };
-
- /* Functions.add_entry("filename", params); */
+ if
+ (
+ XMLManager.get_attribute
+ (
+ xml_node,
+ "is_ref"
+ ).equals("true")
+ )
+ {
+ Predicates.add_entry("is_ref", local_id);
+ }
}
private void handle_predicate_has_active_flag
@@ -204,19 +174,17 @@ public class VHDLSignal extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- Strings.get_id_from_string
- (
- null /* TODO: get attribute */
- )
- };
-
- /* Functions.add_entry("filename", params); */
+ if
+ (
+ XMLManager.get_attribute
+ (
+ xml_node,
+ "has_active_flag"
+ ).equals("true")
+ )
+ {
+ Predicates.add_entry("has_active_flag", local_id);
+ }
}
private void handle_predicate_has_identifier_list
@@ -224,19 +192,17 @@ public class VHDLSignal extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- Strings.get_id_from_string
- (
- null /* TODO: get attribute */
- )
- };
-
- /* Functions.add_entry("filename", params); */
+ if
+ (
+ XMLManager.get_attribute
+ (
+ xml_node,
+ "has_identifier_list"
+ ).equals("true")
+ )
+ {
+ Predicates.add_entry("has_identifier_list", local_id);
+ }
}
private void handle_predicate_has_visible_flag
@@ -244,19 +210,17 @@ public class VHDLSignal extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- Strings.get_id_from_string
- (
- null /* TODO: get attribute */
- )
- };
-
- /* Functions.add_entry("filename", params); */
+ if
+ (
+ XMLManager.get_attribute
+ (
+ xml_node,
+ "visible_flag"
+ ).equals("true")
+ )
+ {
+ Predicates.add_entry("has_visible_flag", local_id);
+ }
}
private void handle_predicate_has_after_drivers_flag
@@ -264,19 +228,17 @@ public class VHDLSignal extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- Strings.get_id_from_string
- (
- null /* TODO: get attribute */
- )
- };
-
- /* Functions.add_entry("filename", params); */
+ if
+ (
+ XMLManager.get_attribute
+ (
+ xml_node,
+ "after_drivers_flag"
+ ).equals("true")
+ )
+ {
+ Predicates.add_entry("has_after_drivers_flag", local_id);
+ }
}
private void handle_predicate_has_use_flag
@@ -284,19 +246,17 @@ public class VHDLSignal extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- Strings.get_id_from_string
- (
- null /* TODO: get attribute */
- )
- };
-
- /* Functions.add_entry("filename", params); */
+ if
+ (
+ XMLManager.get_attribute
+ (
+ xml_node,
+ "use_flag"
+ ).equals("true")
+ )
+ {
+ Predicates.add_entry("has_use_flag", local_id);
+ }
}
private void handle_predicate_has_guarded_signal_flag
@@ -304,19 +264,17 @@ public class VHDLSignal extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- Strings.get_id_from_string
- (
- null /* TODO: get attribute */
- )
- };
-
- /* Functions.add_entry("filename", params); */
+ if
+ (
+ XMLManager.get_attribute
+ (
+ xml_node,
+ "guarded_signal_flag"
+ ).equals("true")
+ )
+ {
+ Predicates.add_entry("has_guarded_signal_flag", local_id);
+ }
}
private void handle_predicate_is_of_kind
@@ -324,19 +282,19 @@ public class VHDLSignal extends ParsableXML
final IDs local_id
)
{
- final IDs params[];
-
- params =
- new IDs[]
- {
- local_id,
- Strings.get_id_from_string
+ Predicates.add_entry
+ (
+ "is_of_kind",
+ local_id,
+ Strings.get_id_from_string
+ (
+ XMLManager.get_attribute
(
- null /* TODO: get attribute */
+ xml_node,
+ "signal_kind"
)
- };
-
- /* Functions.add_entry("filename", params); */
+ )
+ );
}
/***************************************************************************/
@@ -347,6 +305,14 @@ public class VHDLSignal extends ParsableXML
final IDs local_id
)
{
- /* TODO */
+ Predicates.add_entry
+ (
+ "is_waveform_of",
+ Waveforms.get_associated_waveform_id
+ (
+ local_id
+ ),
+ local_id
+ );
}
}
diff --git a/ast-to-instr/src/XMLManager.java b/ast-to-instr/src/XMLManager.java
index 03fbe6d..dc3eef1 100644
--- a/ast-to-instr/src/XMLManager.java
+++ b/ast-to-instr/src/XMLManager.java
@@ -82,6 +82,23 @@ public class XMLManager
return XPATH.compile(expression);
}
+ public static XPathExpression compile_or_die (final String expression)
+ {
+ try
+ {
+ return XPATH.compile(expression);
+ }
+ catch (final XPathExpressionException xpee)
+ {
+ System.err.println("[P] Invalid XPathExpression (report as bug):");
+ xpee.printStackTrace();
+
+ System.exit(-1);
+ }
+
+ return null; /* Because Java. */
+ }
+
public static Collection<Node> node_list_to_node_collection
(
final NodeList nl
@@ -101,4 +118,9 @@ public class XMLManager
return result;
}
+
+ public static String get_attribute (final Node n, final String attr)
+ {
+ return n.getAttributes().getNamedItem(attr).getNodeValue();
+ }
}