diff options
author | Clément Pit--Claudel <clement.pitclaudel@live.com> | 2015-07-31 14:26:53 -0700 |
---|---|---|
committer | Clément Pit--Claudel <clement.pitclaudel@live.com> | 2015-07-31 14:26:53 -0700 |
commit | 990966db7dcea00045c5c104ded084348e8f7dde (patch) | |
tree | b7ba5727c821848354de40c4149633ed9dc5a23d /Source/DafnyServer/VerificationTask.cs | |
parent | 48fed349a2fc592e7f015ecaa6cf98582446278f (diff) |
Split the server source into multiple files
Diffstat (limited to 'Source/DafnyServer/VerificationTask.cs')
-rw-r--r-- | Source/DafnyServer/VerificationTask.cs | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/Source/DafnyServer/VerificationTask.cs b/Source/DafnyServer/VerificationTask.cs new file mode 100644 index 00000000..a00688b1 --- /dev/null +++ b/Source/DafnyServer/VerificationTask.cs @@ -0,0 +1,59 @@ +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() {
+ ServerUtils.ApplyArgs(args);
+ new DafnyHelper(filename, ProgramSource).Verify();
+ }
+ }
+}
|