Ejemplo n.º 1
0
  @Override
  public void applyImpl() throws RuleFailedException {

    var_fields =
        new Variable<java.util.List<it.xsemantics.example.fj.fj.Field>>(
            createCollectionType(createEClassifierType(basicPackage.getField())),
            getAll(
                var_e.getValue().getType().getClassref(),
                "members",
                "superclass",
                it.xsemantics.example.fj.fj.Field.class));

    try {
      equals(length(var_e.getValue().getArgs()), length(var_fields));
    } catch (RuleFailedException e) {
      e.setMessage(
          "argument number "
              + stringRep(length(var_e.getValue().getArgs()))
              + " is not equal to field number "
              + stringRep(length(var_fields)));
      throw e;
    }

    register("forall " + stringRep(length(var_e.getValue().getArgs())));
    try {
      for (var_i.setValue(0);
          var_i.getValue() < length(var_e.getValue().getArgs());
          var_i.setValue(var_i.getValue() + 1)) {

        var_argType =
            new Variable<it.xsemantics.example.fj.fj.Type>(
                createEClassifierType(basicPackage.getType()), null);

        var_fieldType =
            new Variable<it.xsemantics.example.fj.fj.Type>(
                createEClassifierType(basicPackage.getType()), null);

        applyTypeRule(env_G, var_e.getValue().getArgs().get(var_i.getValue()), var_argType);

        applyTypeRule(env_G, var_fields.getValue().get(var_i.getValue()), var_fieldType);

        try {
          applySubtypeRule(env_G, var_argType, var_fieldType);
        } catch (RuleFailedException e) {
          e.setMessage(
              "argument type ("
                  + stringRep(var_argType.getValue())
                  + ") is not a subtype of field type ("
                  + stringRep(var_fieldType.getValue())
                  + ")");
          throw e;
        }
      }
    } catch (Throwable e) {
      registerFailure(e);
      throw new RuleFailedException(
          "failure in checking arguments " + stringRep(var_e.getValue().getArgs()));
    }
    register("end " + "forall " + stringRep(length(var_e.getValue().getArgs())));
    assignment(var_t, var_e.getValue().getType());

    // final check for variable initialization

  }
  @Override
  public void applyImpl() throws RuleFailedException {
    // axiom

    getRight().setValue(var_v.getValue().getParamref().getType());
  }