X-Git-Url: http://plrg.eecs.uci.edu/git/?p=repair.git;a=blobdiff_plain;f=Repair%2FRepairCompiler%2FMCC%2FIR%2FSemanticChecker.java;h=5339bb74f4ab956d1dad7e28584884d63060c1ce;hp=7ae3fb2ec138ab2bdd572f6fae021b4b5664b879;hb=b63f5f1f7c6292259d7e322f4b89b8cf43891f0d;hpb=7541bf06c65742e115a92a3acb80f8f276490c14 diff --git a/Repair/RepairCompiler/MCC/IR/SemanticChecker.java b/Repair/RepairCompiler/MCC/IR/SemanticChecker.java index 7ae3fb2..5339bb7 100755 --- a/Repair/RepairCompiler/MCC/IR/SemanticChecker.java +++ b/Repair/RepairCompiler/MCC/IR/SemanticChecker.java @@ -389,8 +389,8 @@ public class SemanticChecker { } /* do any post checks... (type constraints, etc?) */ - - return ok; + + return ok; } private boolean parse_constraint(ParseNode pn) { @@ -474,7 +474,7 @@ public class SemanticChecker { /* return to caller */ return sq; - } else if (pn.getChild("relatiion") != null) { /* for < v1, v2 > in Relation */ + } else if (pn.getChild("relation") != null) { /* for < v1, v2 > in Relation */ RelationQuantifier rq = new RelationQuantifier(); /* get vars */ @@ -527,7 +527,6 @@ public class SemanticChecker { } else { throw new IRException("not supported yet"); } - } private LogicStatement parse_body(ParseNode pn) { @@ -560,7 +559,7 @@ public class SemanticChecker { return new LogicStatement(LogicStatement.OR, left, right); } else if (pn.getChild("not") != null) { /* NOT body */ - LogicStatement left = parse_body(pn.getChild("not").getChild("left").getChild("body")); + LogicStatement left = parse_body(pn.getChild("not").getChild("body")); if (left == null) { return null; @@ -582,10 +581,10 @@ public class SemanticChecker { if (pn.getChild("inclusion") != null) { ParseNode in = pn.getChild("inclusion"); - /* get quantiifer var */ - VarDescriptor vd = parse_quantifiervar(in.getChild("quantifiervar")); + /* Expr */ + Expr expr = parse_expr(in.getChild("expr")); - if (vd == null) { + if (expr == null) { return null; } @@ -596,81 +595,15 @@ public class SemanticChecker { return null; } - return new InclusionPredicate(vd, setexpr); - } else if (pn.getChild("sizeof") != null) { - ParseNode sizeof = pn.getChild("sizeof"); - - /* get set expr */ - SetExpr setexpr = parse_setexpr(sizeof.getChild("setexpr")); - - if (setexpr == null) { - return null; - } - - /* get comparison operator */ - String compareop = sizeof.getChild("compare").getTerminal(); - Opcode opcode = Opcode.decodeFromString(compareop); - - if (opcode == null) { - er.report(pn, "Unsupported operation '" + compareop + "'"); - return null; - } else if (opcode != Opcode.EQ && - opcode != Opcode.GE && - opcode != Opcode.LE) { - er.report(pn, "Invalid operation '" + compareop + "': Must be one of '=', '>=', '<='"); - return null; - } + return new InclusionPredicate(expr, setexpr); + } else if (pn.getChild("expr") != null) { + Expr expr = parse_expr(pn.getChild("expr")); - /* get decimal */ - String decimal = sizeof.getChild("decimal").getTerminal(); - IntegerLiteralExpr cardinality = new IntegerLiteralExpr(Integer.parseInt(decimal)); - - return new SizeofPredicate(setexpr, opcode, cardinality); - } else if (pn.getChild("comparison") != null) { - ParseNode cn = pn.getChild("comparison"); - - /* get quantifier variable */ - String varname = cn.getChild("quantifier").getTerminal(); - String relation = cn.getChild("relation").getTerminal(); - - if (!sts.peek().contains(varname)) { - er.report(pn, "Undefined quantifier '" + varname + "'"); - return null; - } - - VarDescriptor vd = (VarDescriptor) sts.peek().get(varname); - - if (!stRelations.contains(relation)) { - er.report(pn, "Undefined relation '" + varname + "'"); - return null; - } - - RelationDescriptor rd = (RelationDescriptor) stRelations.get(relation); - - /* get the expr's */ - Expr expr = parse_expr(cn.getChild("expr")); - if (expr == null) { return null; } - /* get comparison operator */ - String compareop = cn.getChild("compare").getTerminal(); - Opcode opcode = Opcode.decodeFromString(compareop); - - if (opcode == null) { - er.report(pn, "Unsupported operation '" + compareop + "'"); - return null; - } else if (opcode != Opcode.EQ && - opcode != Opcode.GE && - opcode != Opcode.LE) { - er.report(pn, "Invalid operation '" + compareop + "': Must be one of '=', '>=', '<='"); - return null; - } - - rd.addUsage(RelationDescriptor.IMAGE); - - return new ComparisonPredicate(vd, rd, opcode, expr); + return new ExprPredicate(expr); } else { throw new IRException(); } @@ -852,13 +785,17 @@ public class SemanticChecker { String rangesetname = pn.getChild("range").getChild("type").getTerminal(); assert rangesetname != null; - /* get domain multiplicity */ - String domainmult = pn.getChild("domain").getChild("mult").getTerminal(); - assert domainmult != null; + /* get domain multiplicity */ + String domainmult; + if (pn.getChild("domain").getChild("domainmult") != null) + domainmult = pn.getChild("domain").getChild("domainmult").getChild("mult").getTerminal(); + //assert domainmult != null; /* get range multiplicity */ - String rangemult = pn.getChild("range").getChild("mult").getTerminal(); - assert rangemult != null; + String rangemult; + if (pn.getChild("range").getChild("domainrange") != null) + rangemult = pn.getChild("range").getChild("domainrange").getChild("mult").getTerminal(); + //assert rangemult != null; /* NOTE: it is assumed that the sets have been parsed already so that the set namespace is fully populated. any missing setdescriptors for the set @@ -926,7 +863,7 @@ public class SemanticChecker { } else if (t instanceof StructureTypeDescriptor) { StructureTypeDescriptor type = (StructureTypeDescriptor) t; - TypeDescriptor subtype = type.getSubType(); + TypeDescriptor subtype = type.getSuperType(); // check that the subtype is valid if (subtype instanceof MissingTypeDescriptor) { @@ -937,7 +874,7 @@ public class SemanticChecker { er.report(null, "Undefined subtype '" + subtype.getSymbol() + "'"); ok = false; } else { - type.setSubType(newtype); + type.setSuperType(newtype); } } @@ -1006,7 +943,7 @@ public class SemanticChecker { } else if (t instanceof StructureTypeDescriptor) { StructureTypeDescriptor type = (StructureTypeDescriptor)t; - TypeDescriptor subtype = type.getSubType(); + TypeDescriptor subtype = type.getSuperType(); Iterator fields = type.getFields(); while (fields.hasNext()) { @@ -1081,7 +1018,7 @@ public class SemanticChecker { return false; } - stGlobals.add(new VarDescriptor(name, name, td)); + stGlobals.add(new VarDescriptor(name, name, td,true)); return true; } @@ -1105,7 +1042,7 @@ public class SemanticChecker { } /* lookup the type to get the type descriptor */ - type.setSubType(lookupType(subtype, CREATE_MISSING)); + type.setSuperType(lookupType(subtype, CREATE_MISSING)); } // set the current type so that the recursive parses on the labels @@ -1384,7 +1321,7 @@ public class SemanticChecker { } String relname = pn.getChild("name").getTerminal(); - boolean inverse = pn.getChild("inv") == null; + boolean inverse = pn.getChild("inv") != null; Expr expr = parse_expr(pn.getChild("expr")); if (expr == null) {