Skip to content

Commit 241dbee

Browse files
committed
Add org.cprover package and makefile
1 parent 48b9427 commit 241dbee

File tree

2 files changed

+144
-3
lines changed

2 files changed

+144
-3
lines changed

src/java_bytecode/library/Makefile

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
all: org.cprover.jar
2+
3+
SOURCE_DIR := src
4+
BINARY_DIR := classes
5+
6+
FIND := find
7+
8+
JAVAC := javac
9+
JFLAGS := -sourcepath $(SOURCE_DIR) -d $(BINARY_DIR)
10+
11+
CLASSPATH := SOURCE_DIR
12+
13+
all_javas := $(shell $(FIND) $(SOURCE_DIR) -name '*.java')
14+
15+
$(BINARY_DIR):
16+
mkdir -p $(BINARY_DIR)
17+
18+
.PHONY: compile
19+
compile: $(BINARY_DIR)
20+
$(JAVAC) $(JFLAGS) $(all_javas)
21+
22+
JAR := jar
23+
JARFLAGS := -cf
24+
25+
org.cprover.jar: compile
26+
$(JAR) $(JARFLAGS) $@ -C $(BINARY_DIR) org

src/java_bytecode/library/src/org/cprover/CProver.java

+118-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,124 @@
33
public final class CProver
44
{
55
public static boolean enableAssume=true;
6-
public static void assume(boolean condition)
6+
public static boolean enableNondet=true;
7+
8+
public static boolean nondetBoolean()
9+
{
10+
if (enableNondet)
11+
{
12+
throw new RuntimeException(
13+
"Cannot execute program with CProver.nondetBoolean()");
14+
}
15+
16+
return false;
17+
}
18+
19+
public static byte nondetByte()
20+
{
21+
if (enableNondet)
22+
{
23+
throw new RuntimeException(
24+
"Cannot execute program with CProver.nondetByte()");
25+
}
26+
27+
return 0;
28+
}
29+
30+
public static char nondetChar()
31+
{
32+
if (enableNondet)
33+
{
34+
throw new RuntimeException(
35+
"Cannot execute program with CProver.nondetChar()");
36+
}
37+
38+
return '\0';
39+
}
40+
41+
public static short nondetShort()
42+
{
43+
if (enableNondet)
44+
{
45+
throw new RuntimeException(
46+
"Cannot execute program with CProver.nondetShort()");
47+
}
48+
49+
return 0;
50+
}
51+
52+
public static int nondetInt()
53+
{
54+
if (enableNondet)
55+
{
56+
throw new RuntimeException(
57+
"Cannot execute program with CProver.nondetInt()");
58+
}
59+
60+
return 0;
61+
}
62+
63+
public static long nondetLong()
64+
{
65+
if (enableNondet)
66+
{
67+
throw new RuntimeException(
68+
"Cannot execute program with CProver.nondetLong()");
69+
}
70+
71+
return 0;
72+
}
73+
74+
public static float nondetFloat()
75+
{
76+
if (enableNondet)
77+
{
78+
throw new RuntimeException(
79+
"Cannot execute program with CProver.nondetFloat()");
80+
}
81+
82+
return 0;
83+
}
84+
85+
public static double nondetDouble()
86+
{
87+
if (enableNondet)
88+
{
89+
throw new RuntimeException(
90+
"Cannot execute program with CProver.nondetDouble()");
91+
}
92+
93+
return 0;
94+
}
95+
96+
public static <T> T nondetWithNull()
97+
{
98+
if (enableNondet)
99+
{
100+
throw new RuntimeException(
101+
"Cannot execute program with CProver.nondetWithNull<T>(T)");
102+
}
103+
104+
return null;
105+
}
106+
107+
public static <T> T nondetWithoutNull()
108+
{
109+
if (enableNondet)
110+
{
111+
throw new RuntimeException(
112+
"Cannot execute program with CProver.nondetWithoutNull<T>(T)");
113+
}
114+
115+
return null;
116+
}
117+
118+
public static void assume(boolean condition)
7119
{
8120
if(enableAssume)
9-
throw new RuntimeException("Cannot execute program with CProver.assume()");
10-
}
121+
{
122+
throw new RuntimeException(
123+
"Cannot execute program with CProver.assume()");
124+
}
125+
}
11126
}

0 commit comments

Comments
 (0)