use of edu.mit.csail.sdg.alloy4.Pos in project org.alloytools.alloy by AlloyTools.
the class ExprList method span.
// ============================================================================================================//
/**
* {@inheritDoc}
*/
@Override
public Pos span() {
Pos p = span;
if (p == null) {
p = pos.merge(closingBracket);
for (Expr a : args) p = p.merge(a.span());
span = p;
}
return p;
}
use of edu.mit.csail.sdg.alloy4.Pos in project org.alloytools.alloy by AlloyTools.
the class ExprUnary method resolve.
// ============================================================================================================//
/**
* {@inheritDoc}
*/
@Override
public Expr resolve(Type p, Collection<ErrorWarning> warns) {
if (errors.size() > 0)
return this;
ErrorWarning w1 = null, w2 = null;
Type s = p;
switch(op) {
case NOT:
s = Type.FORMULA;
break;
case TRANSPOSE:
case RCLOSURE:
case CLOSURE:
if (warns != null && op != Op.TRANSPOSE && type.join(type).hasNoTuple())
w1 = new ErrorWarning(pos, this + " is redundant since its domain and range are disjoint: " + sub.type.extract(2));
s = (op != Op.TRANSPOSE) ? resolveClosure(p, sub.type) : sub.type.transpose().intersect(p).transpose();
if (warns != null && s == EMPTY && p.hasTuple())
w2 = new ErrorWarning(sub.span(), "The value of this expression does not contribute to the value of the parent.\nParent's relevant type = " + p + "\nThis expression's type = " + sub.type.extract(2));
break;
case CARDINALITY:
case NO:
case ONE:
case SOME:
case LONE:
s = Type.removesBoolAndInt(sub.type);
break;
case CAST2SIGINT:
s = Type.smallIntType();
break;
case CAST2INT:
s = sub.type.intersect(SIGINT.type);
if (warns != null && s.hasNoTuple())
w1 = new ErrorWarning(sub.span(), "This expression should contain Int atoms.\nInstead, its possible type(s) are:\n" + sub.type.extract(1));
break;
}
Expr sub = this.sub.resolve(s, warns);
if (w1 != null)
warns.add(w1);
if (w2 != null)
warns.add(w2);
return (sub == this.sub) ? this : op.make(pos, sub, null, weight - (this.sub.weight));
}
use of edu.mit.csail.sdg.alloy4.Pos in project org.alloytools.alloy by AlloyTools.
the class Decl method span.
/**
* Returns a Pos object representing the entire span of this expression and all
* its subexpressions.
*/
public Pos span() {
Pos p = span;
if (p == null) {
p = expr.span().merge(disjoint).merge(disjoint2);
for (ExprHasName n : names) p = p.merge(n.span());
span = p;
}
return p;
}
use of edu.mit.csail.sdg.alloy4.Pos in project org.alloytools.alloy by AlloyTools.
the class ExprCall method resolve.
// ============================================================================================================//
/**
* {@inheritDoc}
*/
@Override
public Expr resolve(Type t, Collection<ErrorWarning> warns) {
if (errors.size() > 0)
return this;
TempList<Expr> args = new TempList<Expr>(this.args.size());
boolean changed = false;
for (int i = 0; i < this.args.size(); i++) {
Type p = fun.get(i).type;
Expr x = this.args.get(i);
// Use the
Expr y = x.resolve(p, warns).typecheck_as_set();
// the choices
if (x != y)
changed = true;
args.add(y);
// if (warns!=null && Version.experimental &&
// !y.type.isSubtypeOf(p))
// warns.add(new ErrorWarning(x.span(), "This argument may contain a
// tuple not in the parameter's type.\n"
// +"The Alloy Analyzer's analysis may be unsound\n"
// +"if the argument has a tuple outside the parameter's type.\n"
// +"The argument has type "+y.type+"\nbut the parameter has type
// "+p));
}
return changed ? make(pos, closingBracket, fun, args.makeConst(), extraWeight) : this;
}
use of edu.mit.csail.sdg.alloy4.Pos in project org.alloytools.alloy by AlloyTools.
the class ExprCall method span.
// ============================================================================================================//
/**
* {@inheritDoc}
*/
@Override
public Pos span() {
Pos p = span;
if (p == null) {
p = pos.merge(closingBracket);
for (Expr a : args) p = p.merge(a.span());
span = p;
}
return p;
}
Aggregations