use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ErrorType in project org.alloytools.alloy by AlloyTools.
the class TranslateAlloyToKodkod method visit.
/**
* {@inheritDoc}
*/
@Override
public Object visit(ExprCall x) throws Err {
final Func f = x.fun;
final Object candidate = f.count() == 0 ? cacheForConstants.get(f) : null;
if (candidate != null)
return candidate;
final Expr body = f.getBody();
if (body.type().arity() < 0 || body.type().arity() != f.returnDecl.type().arity())
throw new ErrorType(body.span(), "Function return value not fully resolved.");
final int n = f.count();
int maxRecursion = unrolls;
for (Func ff : current_function) if (ff == f) {
if (maxRecursion < 0) {
throw new ErrorSyntax(x.span(), "" + f + " cannot call itself recursively!");
}
if (maxRecursion == 0) {
Type t = f.returnDecl.type();
if (t.is_bool)
return Formula.FALSE;
if (t.is_int())
return IntConstant.constant(0);
int i = t.arity();
Expression ans = Expression.NONE;
while (i > 1) {
ans = ans.product(Expression.NONE);
i--;
}
return ans;
}
maxRecursion--;
}
Env<ExprVar, Object> newenv = new Env<ExprVar, Object>();
for (int i = 0; i < n; i++) newenv.put(f.get(i), cset(x.args.get(i)));
Env<ExprVar, Object> oldenv = env;
env = newenv;
current_function.add(f);
Object ans = visitThis(body);
env = oldenv;
current_function.remove(current_function.size() - 1);
if (ans instanceof Formula)
k2pos((Formula) ans, x);
if (f.count() == 0)
cacheForConstants.put(f, ans);
return ans;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ErrorType in project org.alloytools.alloy by AlloyTools.
the class ExprITE method make.
/**
* Constructs a ExprITE expression.
*
* @param cond - the condition formula
* @param left - the then-clause
* @param right - the else-clause
*/
public static Expr make(Pos pos, Expr cond, Expr left, Expr right) {
JoinableList<Err> errs = emptyListOfErrors;
if (cond.mult != 0)
errs = errs.make(new ErrorSyntax(cond.span(), "Multiplicity expression not allowed here."));
if (left.mult != 0)
errs = errs.make(new ErrorSyntax(left.span(), "Multiplicity expression not allowed here."));
if (right.mult != 0)
errs = errs.make(new ErrorSyntax(right.span(), "Multiplicity expression not allowed here."));
Type c = EMPTY;
while (left.errors.isEmpty() && right.errors.isEmpty()) {
Type a = left.type, b = right.type;
c = a.unionWithCommonArity(b);
// if (a.is_int && b.is_int) c=Type.makeInt(c);
if (a.is_bool && b.is_bool)
c = Type.makeBool(c);
if (c == EMPTY) {
// [AM]
// if (Type.SIGINT2INT) {
// if (a.is_int && b.intersects(SIGINT.type)) {
// right=right.cast2int(); continue; }
// if (b.is_int && a.intersects(SIGINT.type)) {
// left=left.cast2int(); continue; }
// }
// if (Type.INT2SIGINT) {
// if (a.is_int && b.hasArity(1)) { left=left.cast2sigint();
// continue; }
// if (b.is_int && a.hasArity(1)) { right=right.cast2sigint();
// continue; }
// }
errs = errs.make(new ErrorType(cond.span().merge(right.span()).merge(left.span()), "The then-clause and the else-clause must match.\nThe then-clause has type: " + a + "\nand the else-clause has type: " + b));
}
break;
}
cond = cond.typecheck_as_formula();
return new ExprITE(pos, cond, left, right, c, errs.make(cond.errors).make(left.errors).make(right.errors));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ErrorType in project openflowplugin by opendaylight.
the class OnfExperimenterErrorFactory method deserialize.
@Override
public ErrorMessage deserialize(ByteBuf message) {
ErrorMessageBuilder builder = new ErrorMessageBuilder();
builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
builder.setXid(message.readUnsignedInt());
int type = message.readUnsignedShort();
ErrorType errorType = ErrorType.forValue(type);
if (errorType != null && errorType.equals(ErrorType.EXPERIMENTER)) {
builder.setType(errorType.getIntValue());
builder.setTypeString(errorType.getName());
} else {
LOG.warn("Deserializing other than {} error message with {}", ErrorType.EXPERIMENTER.getName(), this.getClass().getCanonicalName());
builder.setType(type);
builder.setTypeString(UNKNOWN_TYPE);
}
int code = message.readUnsignedShort();
OnfExperimenterErrorCode errorCode = OnfExperimenterErrorCode.forValue(code);
if (errorCode != null) {
builder.setCode(errorCode.getIntValue());
builder.setCodeString(errorCode.getName());
} else {
builder.setCode(code);
builder.setCodeString(UNKNOWN_CODE);
}
builder.addAugmentation(ExperimenterIdError.class, new ExperimenterIdErrorBuilder().setExperimenter(new ExperimenterId(message.readUnsignedInt())).build());
if (message.readableBytes() > 0) {
byte[] data = new byte[message.readableBytes()];
message.readBytes(data);
builder.setData(data);
}
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ErrorType in project openflowplugin by opendaylight.
the class ErrorMessageFactory method deserialize.
@Override
// FB doesn't recognize Objects.requireNonNull
@SuppressFBWarnings("UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR")
public ErrorMessage deserialize(ByteBuf rawMessage) {
Objects.requireNonNull(registry);
int startIndex = rawMessage.readerIndex();
ErrorMessageBuilder builder = new ErrorMessageBuilder();
builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
builder.setXid(rawMessage.readUnsignedInt());
int type = rawMessage.readUnsignedShort();
ErrorType errorType = ErrorType.forValue(type);
if (ErrorType.EXPERIMENTER.equals(errorType)) {
OFDeserializer<ErrorMessage> deserializer = registry.getDeserializer(ExperimenterDeserializerKeyFactory.createExperimenterErrorDeserializerKey(EncodeConstants.OF13_VERSION_ID, rawMessage.getUnsignedInt(rawMessage.readerIndex() + EncodeConstants.SIZE_OF_SHORT_IN_BYTES)));
rawMessage.readerIndex(startIndex);
return deserializer.deserialize(rawMessage);
}
decodeType(builder, errorType, type);
decodeCode(rawMessage, builder, errorType);
int remainingBytes = rawMessage.readableBytes();
if (remainingBytes > 0) {
byte[] data = new byte[remainingBytes];
rawMessage.readBytes(data);
builder.setData(data);
}
return builder.build();
}
Aggregations