blob: eb740e70af2223872ae9e31588166b0acc1799b0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
using System.Text;
using System.Threading.Tasks;
namespace Microsoft.Dafny {
[Serializable]
class VerificationTask {
[DataMember]
string[] args = null;
[DataMember]
string filename = null;
[DataMember]
string source = null;
[DataMember]
bool sourceIsFile = false;
string ProgramSource { get { return sourceIsFile ? File.ReadAllText(source) : source; } }
internal static VerificationTask ReadTask(string b64_repr) {
try {
var json = Encoding.UTF8.GetString(System.Convert.FromBase64String(b64_repr));
using (MemoryStream ms = new MemoryStream(Encoding.Unicode.GetBytes(json))) {
DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(VerificationTask));
return (VerificationTask)serializer.ReadObject(ms);
}
} catch (Exception ex) {
throw new ServerException("Deserialization failed: {0}.", ex.Message);
}
}
internal static void SelfTest() {
var task = new VerificationTask() {
filename = "<none>",
sourceIsFile = false,
args = new string[] { },
source = "method selftest() { assert true; }"
};
try {
task.Run();
Interaction.EOM(Interaction.SUCCESS, null);
} catch (Exception ex) {
Interaction.EOM(Interaction.FAILURE, ex);
}
}
internal void Run() {
new DafnyHelper(args, filename, ProgramSource).Verify();
}
}
}
|