From 5efab36c54ee5cf97cdf12f033e29ffad1b2bc3a Mon Sep 17 00:00:00 2001 From: bdemsky Date: Thu, 29 Jul 2004 05:51:02 +0000 Subject: [PATCH] Updating size computation class.` --- Repair/RepairCompiler/MCC/IR/ExactSize.java | 85 +++++++++++++++++++- Repair/RepairCompiler/MCC/IR/SizeObject.java | 1 + 2 files changed, 85 insertions(+), 1 deletion(-) diff --git a/Repair/RepairCompiler/MCC/IR/ExactSize.java b/Repair/RepairCompiler/MCC/IR/ExactSize.java index 0588c0f..b5b9851 100755 --- a/Repair/RepairCompiler/MCC/IR/ExactSize.java +++ b/Repair/RepairCompiler/MCC/IR/ExactSize.java @@ -7,11 +7,13 @@ class ExactSize { State state; private Hashtable sizemap; private Hashtable constraintmap; + private SetAnalysis setanalysis; public ExactSize(State state) { this.state=state; this.sizemap=new Hashtable(); this.constraintmap=new Hashtable(); + this.setanalysis=new SetAnalysis(state); computesizes(); } @@ -27,6 +29,32 @@ class ExactSize { return (Constraint)constraintmap.get(so); } + public int getsize(RelationDescriptor rd, SetDescriptor sd, boolean inverted) { + Iterator it=setanalysis.getSuperset(sd).iterator(); + while(sd!=null) { + SizeObject so=new SizeObject(rd,sd,inverted); + if (sizemap.containsKey(so)) + return ((Integer)sizemap.get(so)).intValue(); + sd=null; + if (it.hasNext()) + sd=(SetDescriptor)it.next(); + } + return -1; + } + + public Constraint getConstraint(RelationDescriptor rd, SetDescriptor sd, boolean inverted) { + Iterator it=setanalysis.getSuperset(sd).iterator(); + while(sd!=null) { + SizeObject so=new SizeObject(rd,sd,inverted); + if (constraintmap.containsKey(so)) + return ((Constraint)constraintmap.get(so)); + sd=null; + if (it.hasNext()) + sd=(SetDescriptor)it.next(); + } + return null; + } + private void computesizes() { for(Iterator it=state.stSets.descriptors();it.hasNext();) { SetDescriptor sd=(SetDescriptor)it.next(); @@ -60,7 +88,7 @@ class ExactSize { break; } } - } + } } } } @@ -77,5 +105,60 @@ class ExactSize { } } } + + for(Iterator it=state.stRelations.descriptors();it.hasNext();) { + RelationDescriptor rd=(RelationDescriptor)it.next(); + for(int i=0;i