public void generateNextTestSet(TransformationContext ctx, Term t) throws TermWareException {
   if (!t.isX()) {
     throw new AssertException("argument of generateNextTestSet must be a propositional variable");
   }
   Term retval = generateStateTermFromNextFieldModel();
   ctx.getCurrentSubstitution().put(t, retval);
   ++nGenerations_;
   if (nGenerations_ >= maxNGenerations_) {
     ctx.setStop(true);
   }
 }
 @Override
 protected final void createShell() {
   try {
     TransformationContext transformationContext =
         transformer.fillManagedForm(this.parent.orNull(), this);
     this.shell = transformationContext.getShell();
     onTransformationComplete(transformationContext);
   } catch (TransformerException e) {
     logger.error("Transformation failed", e); // NON-NLS
   } finally {
     formTransformationComplete = true;
   }
 }
 public static Term static_transform(Term t, TermSystem sys, TransformationContext ctx)
     throws TermWareException {
   if (!t.getName().equals("javaStrategy")) return t;
   if (t.getArity() != 2) {
     return t;
   }
   sys.getInstance().addJavaStrategy(t.getSubtermAt(0).getName(), t.getSubtermAt(1).getName());
   ctx.setChanged(true);
   return TermFactory.createBoolean(true);
 }
 public static Term static_transform(Term t, TermSystem system, TransformationContext ctx)
     throws TermWareException {
   if (t.getArity() != 2) {
     throw new AssertException("logical_and must have arity 2");
   }
   LogHelper.log(system, LogicalAndTransformer.class, "LogicalAnd, t=", t);
   Term frs = t.getSubtermAt(0);
   Term snd = t.getSubtermAt(1);
   Term retval = t;
   if (frs.isBoolean() && snd.isBoolean()) {
     ctx.setChanged(true);
     retval =
         system.getInstance().getTermFactory().createBoolean(frs.getBoolean() && snd.getBoolean());
   } else if (frs.isBoolean()) {
     if (frs.getBoolean()) {
       // true && y -> y
       ctx.setChanged(true);
       retval = snd;
     } else {
       // false &&  y -> false
       ctx.setChanged(true);
       retval = frs;
     }
   } else if (snd.isBoolean()) {
     if (snd.getBoolean()) {
       // x && true -> x
       ctx.setChanged(true);
       retval = frs;
     } else {
       // x && false -> x
       ctx.setChanged(true);
       retval = snd;
     }
   }
   LogHelper.log(system, LogicalAndTransformer.class, "return ", retval);
   return retval;
 }
Example #5
0
 public static Term static_transform(Term t, TermSystem sys, TransformationContext ctx)
     throws TermWareException {
   if (!t.getName().equals("printTerm")) return t;
   if (sys.isLoggingMode()) {
     sys.getEnv().getLog().print("native:");
     t.print(sys.getEnv().getLog());
     sys.getEnv().getLog().println();
   }
   Term retval = t;
   if (t.getArity() == 1) {
     t.getSubtermAt(0).print(sys.getEnv().getOutput());
     retval = t.getSubtermAt(0);
   } else if (t.getArity() == 2 || t.getArity() == 3) {
     // TODO:
     //    1.  check that name and language is string
     //    2.  outTag can be parameter.
     String printerName = t.getSubtermAt(1).getName();
     IPrinterFactory printerFactory = sys.getInstance().getPrinterFactory(printerName);
     IPrinter printer;
     Term arg = ((t.getArity() == 2) ? TermFactory.createNIL() : t.getSubtermAt(2));
     printer = printerFactory.createPrinter(sys.getEnv().getOutput(), "unknown", sys, arg);
     printer.writeTerm(t.getSubtermAt(0));
     retval = t.getSubtermAt(0);
   } else {
     if (sys.isLoggingMode()) {
       sys.getEnv().getLog().print("native:");
       t.print(sys.getEnv().getLog());
       sys.getEnv().getLog().println("- not changed.");
     }
     return t;
   }
   ctx.setChanged(true);
   if (sys.isLoggingMode()) {
     sys.getEnv().getLog().print("native:");
     t.print(sys.getEnv().getLog());
     sys.getEnv().getLog().println("- printed.");
   }
   return retval;
 }
  /** Test of replaceText method, of class TransformationContext. */
  @Test
  public void testReplaceText() {
    System.out.println("replaceText");
    int offset = 0;

    content.replace(instance.getRealOffset(offset), instance.getRealOffset(offset) + 3, "ones");
    instance.replaceText(offset, 3, 4);
    assertEquals("ones two three five", content.toString());

    content.replace(
        instance.getRealOffset(offset + 4), instance.getRealOffset(offset + 4) + 3, "twos");
    instance.replaceText(offset + 4, 3, 4);
    assertEquals("ones twos three five", content.toString());

    content.replace(
        instance.getRealOffset(offset + 14), instance.getRealOffset(offset + 14) + 4, "fives");
    instance.replaceText(offset + 14, 4, 5);
    assertEquals("ones twos three fives", content.toString());

    content.replace(
        instance.getRealOffset(offset + 14), instance.getRealOffset(offset + 14), "four ");
    instance.replaceText(offset + 14, 0, 5);
    assertEquals("ones twos three four fives", content.toString());

    content.replace(instance.getRealOffset(offset), instance.getRealOffset(offset), "zero ");
    instance.replaceText(offset, 0, 5);
    assertEquals("zero ones twos three four fives", content.toString());

    content.replace(instance.getRealOffset(offset + 8), instance.getRealOffset(offset + 8) + 6, "");
    instance.replaceText(offset + 8, 6, 0);
    assertEquals("zero ones twos four fives", content.toString());
  }