summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2017-07-21 11:06:12 +0200
committerNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2017-07-21 11:06:12 +0200
commit878705688b42837b615067f0a479f31614910f38 (patch)
treed0d61b2f4f66baa638876f2d5641a6377979cdd1 /ast-to-instr/src/VHDLISNode.java
parentbee770032c7bf22eb897085f516f440a72dc3a9a (diff)
Optimization pass.
Diffstat (limited to 'ast-to-instr/src/VHDLISNode.java')
-rw-r--r--ast-to-instr/src/VHDLISNode.java57
1 files changed, 25 insertions, 32 deletions
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<ParsableXML> parse ()
+ public void parse
+ (
+ final Stack<ParsableXML> waiting_list
+ )
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");
@@ -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<ParsableXML> 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<ParsableXML> handle_else_branch
+ private void handle_else_branch
(
- final IDs local_id
+ final IDs local_id,
+ final Stack<ParsableXML> waiting_list
)
throws XPathExpressionException
{
- final Collection<ParsableXML> result;
final Node else_branch;
- result = new ArrayList<ParsableXML>();
-
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;
}
}