*/
public class Compiler {
- public static boolean REPAIR=false;
+ public static boolean REPAIR=true;
public static void main(String[] args) {
State state = null;
success = parse(state) || error(state, "Parsing failed, not attempting semantic analysis.");
success = semantics(state) || error(state, "Semantic analysis failed, not attempting variable initialization.");
- /* Check partition constraints */
- (new ImplicitSchema(state)).update();
+
if (REPAIR) {
+ /* Check partition constraints */
+ (new ImplicitSchema(state)).update();
Termination t=new Termination(state);
}
state.printall();
}
public void update() {
- // updaterules();
+ updaterules();
updateconstraints();
updaterelationconstraints();
}
1. match up quantifiers
2. check inclusion condition
3. see if guard expr of set rule is more general */
-
RelationInclusion inc1=(RelationInclusion) r1.getInclusion();
RelationDescriptor rd=inc1.getRelation();
SetDescriptor sd=isdomain?rd.getDomain():rd.getRange();
Expr expr=isdomain?inc1.getLeftExpr():inc1.getRightExpr();
-
+
Inclusion inc2=r2.getInclusion();
if (!(inc2 instanceof SetInclusion))
return false;
for(Iterator superit=supersets.iterator();superit.hasNext();) {
SetDescriptor sd1=(SetDescriptor)superit.next();
Rule nr=new Rule();
- nr.guard=r.guard;
+ nr.setGuardExpr(r.getGuardExpr());
nr.quantifiers=r.quantifiers;
nr.isstatic=r.isstatic;
nr.isdelay=r.isdelay;
--- /dev/null
+package MCC.IR;
+
+public interface Quantifiers {
+ public int numQuantifiers();
+ public Quantifier getQuantifier(int i);
+}
Vector quantifiers = new Vector();
boolean isstatic = false;
boolean isdelay = false;
- Expr guard = null;
+ private Expr guard = null;
Inclusion inclusion = null;
SymbolTable st = new SymbolTable();
DNFRule dnfguard=null,dnfnegguard=null;
static int addtocount=0;
void generateaddtosetrelation(GraphNode gn, AbstractRepair ar) {
- System.out.println("Attempting to generate add to set");
- System.out.println(ar.getPredicate().getPredicate().name());
- System.out.println(ar.getPredicate().isNegated());
+ // System.out.println("Attempting to generate add to set");
+ //System.out.println(ar.getPredicate().getPredicate().name());
+ //System.out.println(ar.getPredicate().isNegated());
for(int i=0;i<state.vRules.size();i++) {
Rule r=(Rule) state.vRules.get(i);
/* See if this is a good rule*/
- System.out.println(r.getGuardExpr().name());
+ //System.out.println(r.getGuardExpr().name());
if ((r.getInclusion() instanceof SetInclusion&&
ar.getDescriptor()==((SetInclusion)r.getInclusion()).getSet())||
(r.getInclusion() instanceof RelationInclusion&&
/* First solve for quantifiers */
Vector bindings=new Vector();
/* Construct bindings */
- System.out.println("Attempting to generate add to set: #2");
+ //System.out.println("Attempting to generate add to set: #2");
if (!constructbindings(bindings,r,false))
continue;
- System.out.println("Attempting to generate add to set: #3");
+ //System.out.println("Attempting to generate add to set: #3");
//Generate add instruction
DNFRule dnfrule=r.getDNFGuardExpr();
for(int j=0;j<dnfrule.size();j++) {
//Finally build necessary updates to satisfy conjunction
RuleConjunction ruleconj=dnfrule.get(j);
/* Add in updates for quantifiers */
- System.out.println("Attempting to generate add to set #4");
+ //System.out.println("Attempting to generate add to set #4");
MultUpdateNode mun=new MultUpdateNode(ar,MultUpdateNode.ADD);
TermNode tn=new TermNode(mun);
GraphNode gn2=new GraphNode("UpdateAdd"+addtocount,tn);
if (processquantifers(gn2,un, r)&&debugdd()&&
processconjunction(un,ruleconj)) {
- System.out.println("Attempting to generate add to set #5");
+ //System.out.println("Attempting to generate add to set #5");
mun.addUpdate(un);
GraphNode.Edge e=new GraphNode.Edge("abstract"+addtocount,gn2);
addtocount++;
}
boolean debugdd() {
- System.out.println("Attempting to generate add to set DD");
+ //System.out.println("Attempting to generate add to set DD");
return true;
}
}
}
+ public boolean checkconflicts() {
+ Set toremove=new HashSet();
+ for(int i=0;i<updates.size();i++) {
+ Updates u1=(Updates)updates.get(i);
+ for(int j=0;j<updates.size();j++) {
+ Updates u2=(Updates)updates.get(j);
+ if (u1.isAbstract()||u2.isAbstract())
+ continue; /* Abstract updates are already accounted for by graph */
+ if (u1.getDescriptor()!=u2.getDescriptor())
+ continue; /* No interference - different descriptors */
+
+ if ((u1.getOpcode()==Opcode.GT||u1.getOpcode()==Opcode.GE)&&
+ (u2.getOpcode()==Opcode.GT||u2.getOpcode()==Opcode.GE))
+ continue; /* Can be satisfied simultaneously */
+
+ if ((u1.getOpcode()==Opcode.LT||u1.getOpcode()==Opcode.LE)&&
+ (u2.getOpcode()==Opcode.LT||u2.getOpcode()==Opcode.LE))
+ continue;
+
+
+ return false; /* They interfere */
+ }
+ }
+ updates.remove(toremove);
+ return false;
+ }
+
public void addBinding(Binding b) {
bindings.add(b);
binding.put(b.getVar(),b);
return null;
}
-
public void addUpdate(Updates u) {
updates.add(u);
}
Expr rightexpr;
Expr leftexpr;
Opcode opcode;
- boolean negate;
+ boolean negate=false;
public String toString() {
String st="type="+type+"\n";
} else if (op==Opcode.EQ) {
rightexpr=rexpr;
} else if (op==Opcode.NE) {
+ rightexpr=rexpr;
opcode=Opcode.NE;
}
}
leftexpr=lexpr;
rightposition=rpos;
type=Updates.POSITION;
- opcode=null;
+ opcode=Opcode.EQ;
}
boolean isAbstract() {
[], sizeof(Nodes) >= literal(1);
[forall node in Nodes], sizeof(node.~nextnodes) <= literal(1);
-[forall node in Nodes], sizeof(node.~prevnodes) <= literal(1);
[forall n in Nodes],
sizeof(n.nextnodes) = literal(0) or n.nextnodes.prevnodes = n;