From 878705688b42837b615067f0a479f31614910f38 Mon Sep 17 00:00:00 2001 From: Nathanael Sensfelder Date: Fri, 21 Jul 2017 11:06:12 +0200 Subject: Optimization pass. --- ast-to-instr/src/VHDLISNode.java | 57 ++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 32 deletions(-) (limited to 'ast-to-instr/src/VHDLISNode.java') diff --git a/ast-to-instr/src/VHDLISNode.java b/ast-to-instr/src/VHDLISNode.java index f38dcf3..bb16e1b 100644 --- a/ast-to-instr/src/VHDLISNode.java +++ b/ast-to-instr/src/VHDLISNode.java @@ -5,8 +5,7 @@ import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathExpression; import javax.xml.xpath.XPathExpressionException; -import java.util.ArrayList; -import java.util.Collection; +import java.util.Stack; /* If Statement Node */ public class VHDLISNode extends VHDLNode @@ -56,15 +55,15 @@ public class VHDLISNode extends VHDLNode } @Override - public Collection parse () + public void parse + ( + final Stack waiting_list + ) throws XPathExpressionException { - final Collection result; final String xml_id; final IDs local_id; - result = new ArrayList(); - xml_id = XMLManager.get_attribute(xml_node, "id"); local_id = IDs.get_id_from_xml_id(xml_id, "node"); @@ -80,10 +79,8 @@ public class VHDLISNode extends VHDLNode handle_predicate_expr_reads(local_id); /** Children ************************************************************/ - result.add(handle_true_branch(local_id)); - result.addAll(handle_else_branch(local_id)); - - return result; + handle_true_branch(local_id, waiting_list); + handle_else_branch(local_id, waiting_list); } /***************************************************************************/ @@ -203,9 +200,10 @@ public class VHDLISNode extends VHDLNode /***************************************************************************/ /** Children ***************************************************************/ /***************************************************************************/ - private ParsableXML handle_true_branch + private void handle_true_branch ( - final IDs local_id + final IDs local_id, + final Stack waiting_list ) throws XPathExpressionException { @@ -218,32 +216,29 @@ public class VHDLISNode extends VHDLNode XPathConstants.NODE ); - return + waiting_list.push + ( + new VHDLSSCNode ( - new VHDLSSCNode - ( - parent_id, - true_branch, - local_id, - next_node, - (depth + 1), - new String[] {"COND_WAS_TRUE"} - ) - ); - + parent_id, + true_branch, + local_id, + next_node, + (depth + 1), + new String[] {"COND_WAS_TRUE"} + ) + ); } - private Collection handle_else_branch + private void handle_else_branch ( - final IDs local_id + final IDs local_id, + final Stack waiting_list ) throws XPathExpressionException { - final Collection result; final Node else_branch; - result = new ArrayList(); - else_branch = (Node) XPE_FIND_ELSE_BRANCH.evaluate ( @@ -273,7 +268,7 @@ public class VHDLISNode extends VHDLNode } else { - result.add + waiting_list.push ( new VHDLSSCNode ( @@ -286,7 +281,5 @@ public class VHDLISNode extends VHDLNode ) ); } - - return result; } } -- cgit v1.2.3-70-g09d2