| summaryrefslogtreecommitdiff |
diff options
| author | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2017-07-20 16:11:59 +0200 |
|---|---|---|
| committer | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2017-07-20 16:11:59 +0200 |
| commit | 44d19480a10924eac2191308d8842a4df1657167 (patch) | |
| tree | a48dd18ccc613ea9acaabe7de1cca7f2f03c1580 | |
| parent | 1ef39e828479f0d82753f3912b7c5d85e49d708c (diff) | |
Working on the IF nodes + Childrens -> children.
| -rw-r--r-- | ast-to-instr/src/Main.java | 6 | ||||
| -rw-r--r-- | ast-to-instr/src/VHDLArchitecture.java | 18 | ||||
| -rw-r--r-- | ast-to-instr/src/VHDLEntity.java | 12 | ||||
| -rw-r--r-- | ast-to-instr/src/VHDLFile.java | 12 | ||||
| -rw-r--r-- | ast-to-instr/src/VHDLISNode.java | 179 |
5 files changed, 204 insertions, 23 deletions
diff --git a/ast-to-instr/src/Main.java b/ast-to-instr/src/Main.java index 52c3a8e..8f0b766 100644 --- a/ast-to-instr/src/Main.java +++ b/ast-to-instr/src/Main.java @@ -116,4 +116,10 @@ public class Main } } } + + public static boolean node_is_function_or_literal (final String xml_id) + { + /* TODO */ + return false; + } } diff --git a/ast-to-instr/src/VHDLArchitecture.java b/ast-to-instr/src/VHDLArchitecture.java index 1865e7a..5b5f033 100644 --- a/ast-to-instr/src/VHDLArchitecture.java +++ b/ast-to-instr/src/VHDLArchitecture.java @@ -236,7 +236,7 @@ public class VHDLArchitecture extends ParsableXML { final Collection<ParsableXML> result; final NodeList signals; - final int childrens_count; + final int children_count; result = new ArrayList<ParsableXML>(); @@ -247,9 +247,9 @@ public class VHDLArchitecture extends ParsableXML XPathConstants.NODESET ); - childrens_count = signals.getLength(); + children_count = signals.getLength(); - for (int i = 0; i < childrens_count; ++i) + for (int i = 0; i < children_count; ++i) { result.add(new VHDLSignal(local_id, signals.item(i))); } @@ -265,7 +265,7 @@ public class VHDLArchitecture extends ParsableXML { final Collection<ParsableXML> result; final NodeList processes; - final int childrens_count; + final int children_count; result = new ArrayList<ParsableXML>(); @@ -276,9 +276,9 @@ public class VHDLArchitecture extends ParsableXML XPathConstants.NODESET ); - childrens_count = processes.getLength(); + children_count = processes.getLength(); - for (int i = 0; i < childrens_count; ++i) + for (int i = 0; i < children_count; ++i) { result.add(new VHDLProcess(local_id, processes.item(i))); } @@ -294,7 +294,7 @@ public class VHDLArchitecture extends ParsableXML { final Collection<ParsableXML> result; final NodeList components; - final int childrens_count; + final int children_count; result = new ArrayList<ParsableXML>(); @@ -305,9 +305,9 @@ public class VHDLArchitecture extends ParsableXML XPathConstants.NODESET ); - childrens_count = components.getLength(); + children_count = components.getLength(); - for (int i = 0; i < childrens_count; ++i) + for (int i = 0; i < children_count; ++i) { result.add(new VHDLComponent(local_id, components.item(i))); } diff --git a/ast-to-instr/src/VHDLEntity.java b/ast-to-instr/src/VHDLEntity.java index 66e041d..f552d69 100644 --- a/ast-to-instr/src/VHDLEntity.java +++ b/ast-to-instr/src/VHDLEntity.java @@ -231,7 +231,7 @@ public class VHDLEntity extends ParsableXML { final Collection<ParsableXML> result; final NodeList ports; - final int childrens_count; + final int children_count; result = new ArrayList<ParsableXML>(); @@ -242,9 +242,9 @@ public class VHDLEntity extends ParsableXML XPathConstants.NODESET ); - childrens_count = ports.getLength(); + children_count = ports.getLength(); - for (int i = 0; i < childrens_count; ++i) + for (int i = 0; i < children_count; ++i) { result.add(new VHDLPort(local_id, ports.item(i))); } @@ -260,7 +260,7 @@ public class VHDLEntity extends ParsableXML { final Collection<ParsableXML> result; final NodeList generics; - final int childrens_count; + final int children_count; result = new ArrayList<ParsableXML>(); @@ -271,9 +271,9 @@ public class VHDLEntity extends ParsableXML XPathConstants.NODESET ); - childrens_count = generics.getLength(); + children_count = generics.getLength(); - for (int i = 0; i < childrens_count; ++i) + for (int i = 0; i < children_count; ++i) { result.add(new VHDLGeneric(local_id, generics.item(i))); } diff --git a/ast-to-instr/src/VHDLFile.java b/ast-to-instr/src/VHDLFile.java index 6561603..991e54e 100644 --- a/ast-to-instr/src/VHDLFile.java +++ b/ast-to-instr/src/VHDLFile.java @@ -93,7 +93,7 @@ public class VHDLFile extends ParsableXML { final Collection<ParsableXML> result; final NodeList entities; - final int childrens_count; + final int children_count; result = new ArrayList<ParsableXML>(); @@ -104,9 +104,9 @@ public class VHDLFile extends ParsableXML XPathConstants.NODESET ); - childrens_count = entities.getLength(); + children_count = entities.getLength(); - for (int i = 0; i < childrens_count; ++i) + for (int i = 0; i < children_count; ++i) { result.add(new VHDLEntity(local_id, entities.item(i))); } @@ -122,7 +122,7 @@ public class VHDLFile extends ParsableXML { final Collection<ParsableXML> result; final NodeList architectures; - final int childrens_count; + final int children_count; result = new ArrayList<ParsableXML>(); @@ -133,9 +133,9 @@ public class VHDLFile extends ParsableXML XPathConstants.NODESET ); - childrens_count = architectures.getLength(); + children_count = architectures.getLength(); - for (int i = 0; i < childrens_count; ++i) + for (int i = 0; i < children_count; ++i) { result.add(new VHDLArchitecture(local_id, architectures.item(i))); } diff --git a/ast-to-instr/src/VHDLISNode.java b/ast-to-instr/src/VHDLISNode.java index de11c7b..5dedabf 100644 --- a/ast-to-instr/src/VHDLISNode.java +++ b/ast-to-instr/src/VHDLISNode.java @@ -11,11 +11,25 @@ import java.util.Collection; /* If Statement Node */ public class VHDLISNode extends VHDLNode { - private static final XPathExpression XPE_FIND_SUB_NODES; + private static final XPathExpression XPE_FIND_CONDITION; + private static final XPathExpression XPE_FIND_NAMED_ENTITIES; + private static final XPathExpression XPE_FIND_TRUE_BRANCH; + private static final XPathExpression XPE_FIND_ELSE_BRANCH; static { - XPE_FIND_SUB_NODES = XMLManager.compile_or_die("./el"); + XPE_FIND_CONDITION = XMLManager.compile_or_die("./condition"); + XPE_FIND_NAMED_ENTITIES = XMLManager.compile_or_die(".//named_entity"); + + XPE_FIND_TRUE_BRANCH = XMLManager.compile_or_die + ( + "./sequential_statement_chain" + ); + + XPE_FIND_ELSE_BRANCH = XMLManager.compile_or_die + ( + "./else_clause/sequential_statement_chain" + ); } public VHDLISNode @@ -41,7 +55,168 @@ public class VHDLISNode extends VHDLNode 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, "node"); + + /** Functions ***********************************************************/ + handle_function_label(local_id); + handle_function_kind(local_id); + handle_function_depth(local_id); + handle_function_expression(local_id); + + /** Predicates **********************************************************/ + handle_predicate_has_option(local_id); + handle_predicate_expr_reads(local_id); + handle_predicate_is_final(local_id); + + /** Children ************************************************************/ + result.add(handle_true_branch(local_id)); + result.add(handle_else_branch(local_id)); + + return result; + } + + /***************************************************************************/ + /** Functions **************************************************************/ + /***************************************************************************/ + private void handle_function_label + ( + final IDs local_id + ) + { + Functions.add_entry + ( + "label", + local_id, + Strings.get_id_from_string + ( + XMLManager.get_attribute(xml_node, "label") + ) + ); + } + + private void handle_function_kind + ( + final IDs local_id + ) + { + Functions.add_entry + ( + "kind", + local_id, + Strings.get_id_from_string("if") + ); + } + + private void handle_function_depth + ( + final IDs local_id + ) + { + Functions.add_entry + ( + "kind", + local_id, + Strings.get_id_from_string + ( + Integer.toString(depth) + ) + ); + } + + private void handle_function_expression + ( + final IDs local_id + ) + { + /* TODO */ + } + + /***************************************************************************/ + /** Predicates *************************************************************/ + /***************************************************************************/ + private void handle_predicate_has_option + ( + final IDs local_id + ) + { + for (final String s: attributes) + { + Predicates.add_entry + ( + "has_option", + local_id, + Strings.get_id_from_string(s) + ); + } + } + + private void handle_predicate_expr_reads + ( + final IDs local_id + ) + throws XPathExpressionException + { + final NodeList named_entities; + final int named_entities_count; + + named_entities = + (NodeList) XPE_FIND_NAMED_ENTITIES.evaluate + ( + xml_node, + XPathConstants.NODESET + ); + + named_entities_count = named_entities.getLength(); + + for (int i = 0; i < named_entities_count; ++i) + { + final String ref; + + ref = XMLManager.get_attribute(named_entities.item(0), "ref"); + + if (!Main.node_is_function_or_literal(ref)) + { + Predicates.add_entry + ( + "expr_reads", + local_id, + Waveforms.get_associated_waveform_id + ( + IDs.get_id_from_xml_id(ref, null) + ) + ); + } + } + } + + private void handle_predicate_is_final + ( + final IDs local_id + ) + { /* TODO */ + /* ((next_node == null) && !(has_else)) => is_final */ + } + + /***************************************************************************/ + /** Children ***************************************************************/ + /***************************************************************************/ + private Collection<ParsableXML> handle_true_branch + ( + final IDs local_id + ) + { + /* TODO */ + return null; } + } |


