Moved the interpreter
[repair.git] / Repair / RepairInterpreter / normalizer.h
diff --git a/Repair/RepairInterpreter/normalizer.h b/Repair/RepairInterpreter/normalizer.h
new file mode 100755 (executable)
index 0000000..401232f
--- /dev/null
@@ -0,0 +1,80 @@
+// converts constraints into disjunctive normal form
+
+#ifndef NORMALIZER_H
+#define NORMALIZER_H
+#include "classlist.h"
+#include<stdio.h>
+
+
+class CoercePredicate {
+ public:
+  CoercePredicate(bool, Predicate *);
+  CoercePredicate(char *ts, char *lt, char *rs);
+  CoercePredicate(char *ts, char *lt, char *rt,char *rs);
+  Predicate * getpredicate();
+  bool getcoercebool();
+  bool isrule();
+  bool istuple();
+  char *gettriggerset();
+  char *getrelset();
+  char *getltype();
+  char *getrtype();
+
+ private:
+  char *triggerset;
+  bool tuple;
+  char *ltype;
+  char *rtype;
+  char *relset;
+  bool rule;
+  bool coercebool;
+  Predicate *predicate;
+};
+
+
+
+class CoerceSentence {
+ public:
+  CoerceSentence(CoercePredicate **pred, int numpredicates);
+  int getnumpredicates();
+  CoercePredicate *getpredicate(int i);
+  bool issatisfied(processobject *po, Hashtable *env);
+  int cost(processobject *po, Hashtable *env);
+  ~CoerceSentence();
+  
+ private:
+  CoercePredicate **predicates;
+  int numpreds;
+};
+
+
+
+// represents a statement in normal form
+class SentenceArray {
+ public:
+  SentenceArray(CoerceSentence **sentences, int l);
+  int length;
+  CoerceSentence **sentences;
+};
+
+
+// represents a constraint in normal form
+class NormalForm {
+ public:
+  NormalForm(Constraint *c);
+  CoerceSentence * closestmatch(WorkSet *,processobject *po,Hashtable *env);
+  int getnumsentences();
+  CoerceSentence *getsentence(int i);
+  NormalForm(Rule *r);
+  void fprint(FILE *f);
+ private:
+  Constraint *c; /*keep reference for quantifiers */
+  CoerceSentence **sentences;  // the number of sentences in this constraint
+  int length;
+};
+
+
+SentenceArray * computesentences(Statement *st,bool stat);
+int costfunction(CoercePredicate *p);
+char * gettype(char *label, char *set,AElementexpr *ae);
+#endif