From baa98211b7078cd6b2159e42f5bf0b4d44becc2c Mon Sep 17 00:00:00 2001 From: bdemsky Date: Tue, 10 Apr 2007 10:40:09 +0000 Subject: [PATCH] forgot these two files --- Robust/src/IR/Flat/FlatTagActionNode.java | 62 +++++++++++++++++++++++ Robust/src/IR/Flat/TempTagPair.java | 37 ++++++++++++++ 2 files changed, 99 insertions(+) create mode 100644 Robust/src/IR/Flat/FlatTagActionNode.java create mode 100644 Robust/src/IR/Flat/TempTagPair.java diff --git a/Robust/src/IR/Flat/FlatTagActionNode.java b/Robust/src/IR/Flat/FlatTagActionNode.java new file mode 100644 index 00000000..95afd20d --- /dev/null +++ b/Robust/src/IR/Flat/FlatTagActionNode.java @@ -0,0 +1,62 @@ +package IR.Flat; +import IR.TagVarDescriptor; +import java.util.Hashtable; +import java.util.HashSet; +import java.util.Iterator; + +public class FlatTagActionNode extends FlatNode { + Hashtable temptagpairs; + int taskexit; + public static final int NEWOBJECT=0; + public static final int PRE=1; + public static final int TASKEXIT=2; + + + public FlatTagActionNode(int taskexit) { + temptagpairs=new Hashtable(); + this.taskexit=taskexit; + } + + public int getTaskType() { + return taskexit; + } + + public void addTagAction(TempDescriptor td, TagVarDescriptor tvd, boolean status) { + TempTagPair ttp=new TempTagPair(td,tvd); + if (temptagpairs.containsKey(ttp)) { + throw new Error("Temp/Tag combination used twice: "+ttp); + } + temptagpairs.put(ttp, new Boolean(status)); + } + + public int kind() { + return FKind.FlatTagActionNode; + } + + /** This method returns an iterator over the Temp/Tag pairs. */ + + public Iterator getTempTagPairs() { + return temptagpairs.keySet().iterator(); + } + + public boolean getTagChange(TempTagPair ttp) { + return ((Boolean)temptagpairs.get(ttp)).booleanValue(); + } + + public TempDescriptor [] readsTemps() { + if (temptagpairs.size()==0) + return new TempDescriptor [0]; + else { + HashSet temps=new HashSet(); + for(Iterator it=temptagpairs.keySet().iterator();it.hasNext();) { + TempTagPair ttp=(TempTagPair)it.next(); + temps.add(ttp.getTemp()); + } + return (TempDescriptor[]) temps.toArray(new TempDescriptor [temps.size()]); + } + } + + public String toString() { + return "FlatTagActionNode"; + } +} diff --git a/Robust/src/IR/Flat/TempTagPair.java b/Robust/src/IR/Flat/TempTagPair.java new file mode 100644 index 00000000..c777a064 --- /dev/null +++ b/Robust/src/IR/Flat/TempTagPair.java @@ -0,0 +1,37 @@ +package IR.Flat; +import IR.TagVarDescriptor; + +public class TempTagPair { + TagVarDescriptor tvd; + TempDescriptor td; + + public TempTagPair(TempDescriptor td, TagVarDescriptor tvd) { + this.tvd=tvd; + this.td=td; + } + public int hashCode() { + if (tvd!=null) + return tvd.hashCode()^td.hashCode(); + else + return td.hashCode(); + } + + public TempDescriptor getTemp() { + return td; + } + + public TagVarDescriptor getTag() { + return tvd; + } + + public boolean equals(Object o) { + if (!(o instanceof TempTagPair)) + return false; + TempTagPair ttp=(TempTagPair)o; + return ttp.tvd==tvd&&(ttp.td==td); + } + + public String toString() { + return "<"+tvd+","+td+">"; + } +} -- 2.34.1