}
/* do any post checks... (type constraints, etc?) */
-
- return ok;
+
+ return ok;
}
private boolean parse_constraint(ParseNode pn) {
/* 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 */
} else {
throw new IRException("not supported yet");
}
-
}
private LogicStatement parse_body(ParseNode pn) {
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;
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;
}
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();
}
} 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) {
er.report(null, "Undefined subtype '" + subtype.getSymbol() + "'");
ok = false;
} else {
- type.setSubType(newtype);
+ type.setSuperType(newtype);
}
}
} else if (t instanceof StructureTypeDescriptor) {
StructureTypeDescriptor type = (StructureTypeDescriptor)t;
- TypeDescriptor subtype = type.getSubType();
+ TypeDescriptor subtype = type.getSuperType();
Iterator fields = type.getFields();
while (fields.hasNext()) {
}
/* 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
}
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) {