summaryrefslogtreecommitdiff
path: root/ddl/out/csharp/LambdaCube.TypeInfo.cs
blob: c92a747f9f376bb5430d4a6897125655b98b4bb4 (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
// generated file, do not modify!
// 2016-11-11T11:17:03.605012000000Z

using System;
using System.Linq;
using System.Collections.Generic;
using Newtonsoft.Json.Linq;

using LambdaCube.IR;

namespace LambdaCube.TypeInfo {
  public class Range {
      public enum Tag { 
        Range
      };
      public Tag tag;
  };

  namespace data { 
    public class Range : LambdaCube.TypeInfo.Range { 
      public int startLine;
      public int startColumn;
      public int endLine;
      public int endColumn;
      public Range() { tag = LambdaCube.TypeInfo.Range.Tag.Range; }
    };
  }
  public class TypeInfo {
      public enum Tag { 
        TypeInfo
      };
      public Tag tag;
  };

  namespace data { 
    public class TypeInfo : LambdaCube.TypeInfo.TypeInfo { 
      public global::LambdaCube.TypeInfo.Range range;
      public string text;
      public TypeInfo() { tag = LambdaCube.TypeInfo.TypeInfo.Tag.TypeInfo; }
    };
  }
  public class WarningInfo {
      public enum Tag { 
        WarningInfo
      };
      public Tag tag;
  };

  namespace data { 
    public class WarningInfo : LambdaCube.TypeInfo.WarningInfo { 
      public global::LambdaCube.TypeInfo.Range wRange;
      public string wText;
      public WarningInfo() { tag = LambdaCube.TypeInfo.WarningInfo.Tag.WarningInfo; }
    };
  }
  public class ErrorInfo {
      public enum Tag { 
        ErrorInfo
      };
      public Tag tag;
  };

  namespace data { 
    public class ErrorInfo : LambdaCube.TypeInfo.ErrorInfo { 
      public global::LambdaCube.TypeInfo.Range eRange;
      public string eText;
      public ErrorInfo() { tag = LambdaCube.TypeInfo.ErrorInfo.Tag.ErrorInfo; }
    };
  }
  public class CompileResult {
      public enum Tag { 
        CompileError,
        Compiled
      };
      public Tag tag;
  };

  namespace data { 
    public class CompileError : LambdaCube.TypeInfo.CompileResult { 
      public string _0;
      public List<global::LambdaCube.TypeInfo.TypeInfo> _1;
      public List<global::LambdaCube.TypeInfo.WarningInfo> _2;
      public List<global::LambdaCube.TypeInfo.ErrorInfo> _3;
      public CompileError() { tag = LambdaCube.TypeInfo.CompileResult.Tag.CompileError; }
    };
    public class Compiled : LambdaCube.TypeInfo.CompileResult { 
      public string _0;
      public string _1;
      public global::LambdaCube.TypeInfo.Pipeline _2;
      public List<global::LambdaCube.TypeInfo.TypeInfo> _3;
      public List<global::LambdaCube.TypeInfo.WarningInfo> _4;
      public Compiled() { tag = LambdaCube.TypeInfo.CompileResult.Tag.Compiled; }
    };
  }

  // JSON deserializer
  public enum Type { 
    Int,
    String,
    Array_ErrorInfo,
    Array_TypeInfo,
    Array_WarningInfo,
    CompileResult,
    ErrorInfo,
    Pipeline,
    Range,
    TypeInfo,
    WarningInfo
  }

  public class Loader {
    public static object fromJSON(Type type, JToken obj) {
      switch (type) {
        case Type.Int: return (int)obj;
        case Type.String: return (string)obj;
        case Type.Array_ErrorInfo: return ((JArray)obj).Select(x => (global::LambdaCube.TypeInfo.ErrorInfo)fromJSON (Type.ErrorInfo, x)).ToList();
        case Type.Array_TypeInfo: return ((JArray)obj).Select(x => (global::LambdaCube.TypeInfo.TypeInfo)fromJSON (Type.TypeInfo, x)).ToList();
        case Type.Array_WarningInfo: return ((JArray)obj).Select(x => (global::LambdaCube.TypeInfo.WarningInfo)fromJSON (Type.WarningInfo, x)).ToList();

        case Type.Range: {
          string tag = (string)obj["tag"];
          switch (tag) {
            case "Range": {
              data.Range tv = new data.Range();
              tv.startLine = (int)fromJSON(Type.Int,obj["startLine"]);
              tv.startColumn = (int)fromJSON(Type.Int,obj["startColumn"]);
              tv.endLine = (int)fromJSON(Type.Int,obj["endLine"]);
              tv.endColumn = (int)fromJSON(Type.Int,obj["endColumn"]);
              return tv;
            }
            default: throw new Exception("unknown constructor: " + tag);
          }
        }
        case Type.TypeInfo: {
          string tag = (string)obj["tag"];
          switch (tag) {
            case "TypeInfo": {
              data.TypeInfo tv = new data.TypeInfo();
              tv.range = (global::LambdaCube.TypeInfo.Range)fromJSON(Type.Range,obj["range"]);
              tv.text = (string)fromJSON(Type.String,obj["text"]);
              return tv;
            }
            default: throw new Exception("unknown constructor: " + tag);
          }
        }
        case Type.WarningInfo: {
          string tag = (string)obj["tag"];
          switch (tag) {
            case "WarningInfo": {
              data.WarningInfo tv = new data.WarningInfo();
              tv.wRange = (global::LambdaCube.TypeInfo.Range)fromJSON(Type.Range,obj["wRange"]);
              tv.wText = (string)fromJSON(Type.String,obj["wText"]);
              return tv;
            }
            default: throw new Exception("unknown constructor: " + tag);
          }
        }
        case Type.ErrorInfo: {
          string tag = (string)obj["tag"];
          switch (tag) {
            case "ErrorInfo": {
              data.ErrorInfo tv = new data.ErrorInfo();
              tv.eRange = (global::LambdaCube.TypeInfo.Range)fromJSON(Type.Range,obj["eRange"]);
              tv.eText = (string)fromJSON(Type.String,obj["eText"]);
              return tv;
            }
            default: throw new Exception("unknown constructor: " + tag);
          }
        }
        case Type.CompileResult: {
          string tag = (string)obj["tag"];
          switch (tag) {
            case "CompileError": {
              data.CompileError tv = new data.CompileError();
              tv._0 = (string)fromJSON(Type.String,obj["arg0"]);
              tv._1 = (List<global::LambdaCube.TypeInfo.TypeInfo>)fromJSON(Type.Array_TypeInfo,obj["arg1"]);
              tv._2 = (List<global::LambdaCube.TypeInfo.WarningInfo>)fromJSON(Type.Array_WarningInfo,obj["arg2"]);
              tv._3 = (List<global::LambdaCube.TypeInfo.ErrorInfo>)fromJSON(Type.Array_ErrorInfo,obj["arg3"]);
              return tv;
            }
            case "Compiled": {
              data.Compiled tv = new data.Compiled();
              tv._0 = (string)fromJSON(Type.String,obj["arg0"]);
              tv._1 = (string)fromJSON(Type.String,obj["arg1"]);
              tv._2 = (global::LambdaCube.TypeInfo.Pipeline)fromJSON(Type.Pipeline,obj["arg2"]);
              tv._3 = (List<global::LambdaCube.TypeInfo.TypeInfo>)fromJSON(Type.Array_TypeInfo,obj["arg3"]);
              tv._4 = (List<global::LambdaCube.TypeInfo.WarningInfo>)fromJSON(Type.Array_WarningInfo,obj["arg4"]);
              return tv;
            }
            default: throw new Exception("unknown constructor: " + tag);
          }
        }
      }
      throw new Exception("unknown type");
      return null;
    }

    public static JToken toJSON(Range v) {
      var obj = new JObject();
      switch (v.tag) { 
        case Range.Tag.Range:
          obj["tag"] = "Range";
          {
            var tv = (data.Range)v;
            obj["startLine"] = toJSON(tv.startLine);
            obj["startColumn"] = toJSON(tv.startColumn);
            obj["endLine"] = toJSON(tv.endLine);
            obj["endColumn"] = toJSON(tv.endColumn);
          }
          break;
      }
      return obj;
    }
    public static JToken toJSON(TypeInfo v) {
      var obj = new JObject();
      switch (v.tag) { 
        case TypeInfo.Tag.TypeInfo:
          obj["tag"] = "TypeInfo";
          {
            var tv = (data.TypeInfo)v;
            obj["range"] = toJSON(tv.range);
            obj["text"] = toJSON(tv.text);
          }
          break;
      }
      return obj;
    }
    public static JToken toJSON(WarningInfo v) {
      var obj = new JObject();
      switch (v.tag) { 
        case WarningInfo.Tag.WarningInfo:
          obj["tag"] = "WarningInfo";
          {
            var tv = (data.WarningInfo)v;
            obj["wRange"] = toJSON(tv.wRange);
            obj["wText"] = toJSON(tv.wText);
          }
          break;
      }
      return obj;
    }
    public static JToken toJSON(ErrorInfo v) {
      var obj = new JObject();
      switch (v.tag) { 
        case ErrorInfo.Tag.ErrorInfo:
          obj["tag"] = "ErrorInfo";
          {
            var tv = (data.ErrorInfo)v;
            obj["eRange"] = toJSON(tv.eRange);
            obj["eText"] = toJSON(tv.eText);
          }
          break;
      }
      return obj;
    }
    public static JToken toJSON(CompileResult v) {
      var obj = new JObject();
      switch (v.tag) { 
        case CompileResult.Tag.CompileError:
          obj["tag"] = "CompileError";
          {
            var tv = (data.CompileError)v;
            obj["arg0"] = toJSON(tv._0);
            obj["arg1"] = toJSON(tv._1);
            obj["arg2"] = toJSON(tv._2);
            obj["arg3"] = toJSON(tv._3);
          }
          break;
        case CompileResult.Tag.Compiled:
          obj["tag"] = "Compiled";
          {
            var tv = (data.Compiled)v;
            obj["arg0"] = toJSON(tv._0);
            obj["arg1"] = toJSON(tv._1);
            obj["arg2"] = toJSON(tv._2);
            obj["arg3"] = toJSON(tv._3);
            obj["arg4"] = toJSON(tv._4);
          }
          break;
      }
      return obj;
    }

    public static JToken toJSON(int v) { return new JValue(v); }
    public static JToken toJSON(string v) { return new JValue(v); }
    public static JToken toJSON(List<global::LambdaCube.TypeInfo.ErrorInfo> v) {
      var obj = new JArray();
      foreach (var i in v) {
        obj.Add(toJSON(i));
      }
      return obj;
    }
    public static JToken toJSON(List<global::LambdaCube.TypeInfo.TypeInfo> v) {
      var obj = new JArray();
      foreach (var i in v) {
        obj.Add(toJSON(i));
      }
      return obj;
    }
    public static JToken toJSON(List<global::LambdaCube.TypeInfo.WarningInfo> v) {
      var obj = new JArray();
      foreach (var i in v) {
        obj.Add(toJSON(i));
      }
      return obj;
    }
  }
}