// _addInequality(debug, solver, firstArgTerm,
// returnValueTerm);
// _addInequality(debug, solver, baseTerm,
// returnValueTerm);
InequalityTerm returnValueTerm = new MonotonicFunction() {
public Object getValue() throws IllegalActionException {
if (firstArgTerm.getValue().equals(
TypeLattice.lattice().bottom())
|| finalBaseTerm.getValue().equals(
TypeLattice.lattice().bottom())) {
return TypeLattice.lattice().bottom();
}
return TypeLattice.lattice().leastUpperBound(
firstArgTerm.getValue(),
finalBaseTerm.getValue());
}
public InequalityTerm[] getVariables() {
ArrayList list = new ArrayList();
if (firstArgTerm.isSettable()) {
list.add(firstArgTerm);
}
if (finalBaseTerm.isSettable()) {
list.add(finalBaseTerm);
}
InequalityTerm[] terms = (InequalityTerm[]) list
.toArray(new InequalityTerm[list.size()]);
return terms;
}
public Object getAssociatedObject() {
return finalExpression;
}
};
return returnValueTerm;
} else if (methodName.equals("convert")) {
System.out.println("convert method!");
// The return value type is equal to the base
// type. The first argument type is less than or
// equal to the base type.
InequalityTerm firstArgTerm = (InequalityTerm) objectToInequalityTerm
.get(r.getArg(0));
_addInequality(debug, solver, firstArgTerm, baseTerm);
return baseTerm;
} else if (methodName.equals("getElement")
|| methodName.equals("arrayValue")
|| methodName.equals("getElementType")) {
// If we call getElement or arrayValue on an array
// token, then the returned type is the element
// type of the array.
ptolemy.data.type.ArrayType arrayType = new ptolemy.data.type.ArrayType(
ptolemy.data.type.BaseType.UNKNOWN);
_addInequality(debug, solver, baseTerm, new VariableTerm(
arrayType, r));
InequalityTerm returnTypeTerm = arrayType
.getElementTypeTerm();
return returnTypeTerm;
} else if (methodName.equals("getElementAsToken")) {
final InequalityTerm matrixTerm = baseTerm;
InequalityTerm returnTypeTerm = new MonotonicFunction() {
public Object getValue() throws IllegalActionException {
if (matrixTerm.getValue() instanceof MatrixType) {
MatrixType type = (MatrixType) matrixTerm
.getValue();
return type.getElementType();
} else {
return BaseType.UNKNOWN;
}
}
public InequalityTerm[] getVariables() {
if (matrixTerm.isSettable()) {
InequalityTerm[] terms = new InequalityTerm[1];
terms[0] = matrixTerm;
return terms;
} else {
return new InequalityTerm[0];
}
}
};
return returnTypeTerm;
} else if (methodName.equals("absolute")) {
// Return the same as the input type, unless
// complex, in which case, return double.
final InequalityTerm finalBaseTerm = baseTerm;
final InstanceInvokeExpr finalExpression = r;
InequalityTerm returnValueTerm = new MonotonicFunction() {
public Object getValue() throws IllegalActionException {
if (finalBaseTerm.getValue().equals(
BaseType.COMPLEX)) {
return BaseType.DOUBLE;
}