Commit 774a7df3 authored by Sarah Grebing's avatar Sarah Grebing

BigInteger now as an example

parent 361e39ae
Pipeline #42076 passed with stages
in 5 minutes and 52 seconds
......@@ -31,10 +31,23 @@ public abstract class Example {
File examplefolder = new File(psdbg.getPath(), FilenameUtils.removeExtension(filename));
File f = new File(examplefolder, filename);
FileUtils.copyURLToFile(url, f);
return f;
}
public static File newTempFile(File file, String filename) throws IOException {
File psdbg = new File(FileUtils.getTempDirectoryPath(), "psdbg");
File examplefolder = new File(psdbg.getPath(), FilenameUtils.removeExtension(filename));
File f = new File(examplefolder, file.getName());
FileUtils.copyFile(file, f);
return f;
}
protected void defaultInit(Class aClass) {
setHelpText(aClass.getResource("help.html"));
setKeyFile(aClass.getResource("problem.key"));
......
......@@ -11,6 +11,13 @@ import org.apache.commons.io.IOUtils;
import java.io.*;
import java.net.URL;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* @author Alexander Weigl
......@@ -26,6 +33,9 @@ public class JavaExample extends Example {
@Setter
private URL projectFile;
@Getter
@Setter
private Path directoryPath;
@Override
public void open(DebuggerMain debuggerMain) {
//TODO should be reworked if we have an example
......@@ -40,6 +50,23 @@ public class JavaExample extends Example {
File java = newTempFile(javaFile, getName() + ".java");
//System.out.println(java.getAbsolutePath());
//debuggerMain.openKeyFile(key);
if(directoryPath != null){
try (Stream<Path> paths = Files.walk(directoryPath)) {
List<Path> collect = paths.filter(Files::isRegularFile).collect(Collectors.toList());
List<String> files = new LinkedList<>();
collect.forEach(path -> {
File f = path.toFile();
if(f.getName().endsWith(".java") && !f.getName().equals(getName()+".java")){
try {
File temp = newTempFile(f, getName()+".java");
} catch (IOException e) {
e.printStackTrace();
}
}});
files.forEach(path -> System.out.println("path = " + path));
}
}
debuggerMain.openJavaFile(java);
if (settingsFile != null) {
File settings = newTempFile(settingsFile, getName() + ".props");
......
package edu.kit.iti.formal.psdbg.examples.java.bigInteger;
import edu.kit.iti.formal.psdbg.examples.JavaExample;
import java.net.URISyntaxException;
import java.nio.file.Paths;
public class BigIntegerExample extends JavaExample {
public BigIntegerExample() throws URISyntaxException {
setName("BigInteger Example");
setDirectoryPath(Paths.get(getClass().getResource("BigInteger.java").toURI()).getParent());
setJavaFile(getClass().getResource("BigInteger.java"));
setScriptFile(getClass().getResource("script.kps"));
// setSettingsFile(getClass().getResource("proof-settings.props"));
// setHelpText(getClass().getResource("help.html"));
}
}
......@@ -14,7 +14,7 @@ import java.util.stream.Stream;
*/
public class RuleCompleter implements AutoCompleter {
@Getter
@Setter
private KeYEnvironment environment;
private List<Suggestion> suggestions = new ArrayList<>(2048);
......
......@@ -102,7 +102,6 @@ public class ContractChooser extends Dialog<Contract> {
private void render() {
if (getItem() != null) {
text.getChildren().clear();
System.out.println(getItem().getName());
String content = content = getItem().getPlainText(services);
Text contract = new Text("Contract for method: ");
......
......@@ -15,7 +15,7 @@ public class AbstractTreeNode {
@Getter @Setter
private List<AbstractTreeNode> children;
@Getter @Setter
@Getter
private final Node node;
@Getter @Setter
......
......@@ -21,7 +21,7 @@ public class ForeachTreeNode extends AbstractTreeNode {
@Getter
private final PTreeNode<KeyData> scriptState;
@Getter @Setter
@Getter
private final int linenr;
private final boolean foreachstart;
......
......@@ -21,7 +21,7 @@ public class RepeatTreeNode extends AbstractTreeNode {
@Getter
private final PTreeNode<KeyData> scriptState;
@Getter @Setter
@Getter
private final int linenr;
private final boolean repeatstart;
......
......@@ -18,7 +18,7 @@ public class ScriptTreeNode extends AbstractTreeNode {
@Getter
private final PTreeNode<KeyData> scriptState;
@Getter @Setter
@Getter
private final int linenr;
......
......@@ -14,10 +14,8 @@ import edu.kit.iti.formal.psdbg.interpreter.dbg.ProofTreeManager;
import edu.kit.iti.formal.psdbg.parser.ast.*;
import javafx.scene.control.TreeItem;
import javafx.util.Pair;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.val;
import sun.reflect.generics.tree.Tree;
import java.util.*;
......
......@@ -9,6 +9,7 @@ edu.kit.iti.formal.psdbg.examples.java.maxtriplet.MaxTripletExample
edu.kit.iti.formal.psdbg.examples.java.quicksort.QuickSort
edu.kit.iti.formal.psdbg.examples.java.sumPositive.SumPositiveExample
edu.kit.iti.formal.psdbg.examples.agatha.AgathaExample
edu.kit.iti.formal.psdbg.examples.java.bigInteger.BigIntegerExample
#edu.kit.iti.formal.psdbg.examples.java.bubbleSort.BubbleSortExample
#edu.kit.iti.formal.psdbg.examples.java.sumAndMax.SumAndMaxExample
#edu.kit.iti.formal.psdbg.examples.lulu.LuLuDoubleLinkedList
......
package java.math;
import java.util.Arrays;
public class BigInteger extends Number implements Comparable/*<BigInteger>*/ {
/**
* The signum of this BigInteger: -1 for negative, 0 for zero, or
* 1 for positive. Note that the BigInteger zero <i>must</i> have
* a signum of 0. This is necessary to ensures that there is exactly one
* representation for each BigInteger value.
*
* @serial
*/
final int signum;
/**
* The magnitude of this BigInteger, in <i>big-endian</i> order: the
* zeroth element of this array is the most-significant int of the
* magnitude. The magnitude must be "minimal" in that the most-significant
* int ({@code mag[0]}) must be non-zero. This is necessary to
* ensure that there is exactly one representation for each BigInteger
* value. Note that this implies that the BigInteger zero has a
* zero-length mag array.
*/
final int[] mag;
/**
* This constant limits {@code mag.length} of BigIntegers to the supported
* range.
*/
private static final int MAX_MAG_LENGTH = Integer.MAX_VALUE / Integer.SIZE + 1; // (1 << 26)
/**
* This mask is used to obtain the value of an int as if it were unsigned.
*/
final static long LONG_MASK = 0xffffffffL;
/**
* The BigInteger constant zero.
*
* @since 1.2
*/
public static final BigInteger ZERO = new BigInteger(new int[0], 0);
/*@ helper normal_behavior
@ ensures this.mag == magnitude;
@*/
BigInteger(int[] magnitude, int signum) {
}
}
package java.lang;
import java.util.*;
public interface Comparable/*<T>*/ {
public int compareTo(/*T*/ Object o);
}
package java.lang;
public final class Math {
public static int min(int a, int b) {
return (a <= b) ? a : b;
}
}
package java.util;
public class Arrays {
/*@ public normal_behavior
@ requires 0 <= from && from <= original.length && from <= to && original != null;
@ ensures \result != original; // always returns a new array
@ ensures \result.length == to - from;
@ ensures (to <= original.length)
@ ==> (\forall int i; from <= i && i < to; \result[i - from] == original[i]);
@ ensures (to > original.length)
@ ==> ((\forall int i; from <= i && i < original.length; \result[i - from] == original[i])
@ && (\forall int i; original.length <= i && i < to; \result[i - from] == 0));
@ assignable \nothing;
@
@ also
@
@ public exceptional_behavior
@ requires from < 0 || from > original.length || from > to || original == null;
@ signals (IllegalArgumentException e) from > to;
@ signals (ArrayIndexOutOfBoundsException e) from < 0 || from > original.length;
@ signals (NullPointerException e) original == null;
@ signals_only IllegalArgumentException, ArrayIndexOutOfBoundsException, NullPointerException;
@ assignable \nothing;
@*/
public static int[] copyOfRange(int[] original, int from, int to) {
int newLength = to - from;
if (newLength < 0)
throw new IllegalArgumentException(from + " > " + to);
int[] copy = new int[newLength];
System.arraycopy(original, from, copy, 0,
Math.min(original.length - from, newLength));
return copy;
}
}
package java.lang;
import java.util.*;
public interface Comparable/*<T>*/ {
public int compareTo(/*T*/ Object o);
}
package java.lang;
public final class Math {
public static int min(int a, int b) {
return (a <= b) ? a : b;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment