⭐️ A friendly language for building type-safe, scalable systems!
at main 6.6 kB view raw
1@0xb533a99cfdbcedbe; 2 3# This Cap'n Proto schema is compiled into Rust code for use in the compiler. 4# 5# We don't want the compiler build to depend on the Cap'n Proto compiler so 6# the Cap'n Proto to Rust build step is commented out in `build.rs`. 7# 8# This schema is not considered a stable API and may change at any time. 9 10struct Property(Value) { 11 key @0 :Text; 12 value @1 :Value; 13} 14 15struct Option(Value) { 16 union { 17 none @0 :Void; 18 some @1 :Value; 19 } 20} 21 22struct Module { 23 name @0 :Text; 24 types @1 :List(Property(TypeConstructor)); 25 values @2 :List(Property(ValueConstructor)); 26 accessors @3 :List(Property(AccessorsMap)); 27 package @4 :Text; 28 typesConstructors @5 :List(Property(TypesVariantConstructors)); 29 lineNumbers @6 :LineNumbers; 30 srcPath @7 :Text; 31 isInternal @8 :Bool; 32 requiredVersion @9 :Version; 33 typeAliases @10 :List(Property(TypeAliasConstructor)); 34 documentation @11 :List(Text); 35 containsEcho @12 :Bool; 36 references @13 :References; 37} 38 39struct References { 40 importedModules @0 :List(Text); 41 valueReferences @1 :List(ReferenceMap); 42 typeReferences @2 :List(ReferenceMap); 43} 44 45struct ReferenceMap { 46 module @0 :Text; 47 name @1 :Text; 48 references @2 :List(Reference); 49} 50 51struct Reference { 52 location @0 :SrcSpan; 53 kind @1 :ReferenceKind; 54} 55 56struct ReferenceKind { 57 union { 58 qualified @0 :Void; 59 unqualified @1 :Void; 60 import @2 :Void; 61 definition @3 :Void; 62 alias @4 :Void; 63 } 64} 65 66struct TypeAliasConstructor { 67 publicity @0 :Publicity; 68 module @1 :Text; 69 type @2 :Type; 70 arity @3 :UInt32; 71 deprecation @4 :Text; 72 documentation @5 :Text; 73 origin @6 :SrcSpan; 74} 75 76struct Version { 77 major @0 :UInt32; 78 minor @1 :UInt32; 79 patch @2 :UInt32; 80} 81 82struct TypesVariantConstructors { 83 variants @0 :List(TypeValueConstructor); 84 typeParametersIds @1 :List(UInt16); 85 opaque @2 :Bool; 86} 87 88struct TypeValueConstructor { 89 name @0 :Text; 90 parameters @1 :List(TypeValueConstructorParameter); 91 documentation @2 :Text; 92} 93 94struct TypeValueConstructorParameter { 95 type @0 :Type; 96 label @1 :Text; 97} 98 99struct TypeConstructor { 100 type @0 :Type; 101 # TODO: convert this to an int as we only need to reconstruct type vars, 102 # not other types 103 # TODO: test 104 parameters @1 :List(Type); 105 module @2 :Text; 106 publicity @3 :Publicity; 107 deprecated @4 :Text; 108 origin @5 :SrcSpan; 109 documentation @6 :Text; 110} 111 112struct AccessorsMap { 113 type @0 :Type; 114 sharedAccessors @1 :List(Property(RecordAccessor)); 115 variantSpecificAccessors @2 :List(VariantSpecificAccessors); 116 publicity @3 :Publicity; 117} 118 119struct VariantSpecificAccessors { 120 accessors @0 :List(Property(RecordAccessor)); 121} 122 123struct RecordAccessor { 124 type @0 :Type; 125 index @1 :UInt16; 126 label @2 :Text; 127} 128 129# UInt16 cannot be used as a generic parameter to Option, 130# so we need to create a custom type for this. 131struct InferredVariant { 132 union { 133 unknown @0 :Void; 134 inferred @1 :UInt16; 135 } 136} 137 138struct Type { 139 union { 140 app :group { 141 name @0 :Text; 142 module @1 :Text; 143 parameters @2 :List(Type); 144 package @7 :Text; 145 inferredVariant @8 :InferredVariant; 146 } 147 148 fn :group { 149 arguments @3 :List(Type); 150 return @4 :Type; 151 } 152 153 var :group { 154 id @5 :UInt64; 155 } 156 157 tuple :group { 158 elements @6 :List(Type); 159 } 160 } 161} 162 163struct ValueConstructor { 164 type @0 :Type; 165 variant @1 :ValueConstructorVariant; 166 publicity @2 :Publicity; 167 deprecated @3 :Text; 168} 169 170struct Publicity { 171 union { 172 public @0 :Void; 173 private @1 :Void; 174 internal @2 :Option(SrcSpan); 175 } 176} 177 178struct Implementations { 179 gleam @0 :Bool; 180 usesErlangExternals @1 :Bool; 181 usesJavascriptExternals @2 :Bool; 182 canRunOnErlang @3 :Bool; 183 canRunOnJavascript @4 :Bool; 184} 185 186struct ValueConstructorVariant { 187 union { 188 moduleConstant :group { 189 literal @0 :Constant; 190 location @1 :SrcSpan; 191 module @2 :Text; 192 name @22 :Text; 193 documentation @14 :Text; 194 implementations @19 :Implementations; 195 } 196 197 moduleFn :group { 198 name @3 :Text; 199 fieldMap @4 :Option(FieldMap); 200 module @5 :Text; 201 arity @6 :UInt16; 202 location @7 :SrcSpan; 203 documentation @15 :Text; 204 implementations @18 :Implementations; 205 externalErlang @20 :Option(External); 206 externalJavascript @21 :Option(External); 207 purity @23 :Purity; 208 } 209 210 record :group { 211 name @8 :Text; 212 arity @9 :UInt16; 213 fieldMap @10 :Option(FieldMap); 214 location @11 :SrcSpan; 215 module @12 :Text; 216 constructorsCount @13 :UInt16; 217 documentation @16 :Text; 218 constructorIndex @17 :UInt16; 219 } 220 } 221} 222 223struct Purity { 224 union { 225 pure @0 :Void; 226 trustedPure @1 :Void; 227 impure @2 :Void; 228 unknown @3 :Void; 229 } 230} 231 232struct External { 233 module @0 :Text; 234 function @1 :Text; 235} 236 237struct SrcSpan { 238 start @0 :UInt32; 239 end @1 :UInt32; 240} 241 242# Cap'n Proto only permits pointer types to be used as type parameters 243struct BoxedUInt16 { 244 value @0 :UInt16; 245} 246 247# Cap'n Proto only permits pointer types to be used as type parameters 248struct BoxedUInt32 { 249 value @0 :UInt32; 250} 251 252struct FieldMap { 253 arity @0 :UInt32; 254 fields @1 :List(Property(BoxedUInt32)); 255} 256 257struct Constant { 258 union { 259 int @0 :Text; 260 float @1 :Text; 261 string @2 :Text; 262 tuple @3 :List(Constant); 263 264 list :group { 265 elements @4 :List(Constant); 266 type @5 :Type; 267 } 268 269 record :group { 270 args @6 :List(Constant); 271 tag @7 :Text; 272 type @8 :Type; 273 } 274 275 bitArray @9 :List(BitArraySegment); 276 277 var :group { 278 module @10 :Text; 279 name @11 :Text; 280 type @12 :Type; 281 constructor @13 :ValueConstructor; 282 } 283 284 stringConcatenation :group { 285 left @14 :Constant; 286 right @15 :Constant; 287 } 288 } 289} 290 291struct BitArraySegment { 292 value @0 :Constant; 293 options @1 :List(BitArraySegmentOption); 294 type @2 :Type; 295} 296 297struct BitArraySegmentOption { 298 union { 299 bytes @0 :Void; 300 301 integer @1 :Void; 302 303 float @2 :Void; 304 305 bits @3 :Void; 306 307 utf8 @4 :Void; 308 309 utf16 @5 :Void; 310 311 utf32 @6 :Void; 312 313 utf8Codepoint @7 :Void; 314 315 utf16Codepoint @8 :Void; 316 317 utf32Codepoint @9 :Void; 318 319 signed @10 :Void; 320 321 unsigned @11 :Void; 322 323 big @12 :Void; 324 325 little @13 :Void; 326 327 native @14 :Void; 328 329 size :group { 330 value @15 :Constant; 331 shortForm @16 :Bool; 332 } 333 334 unit :group { 335 value @17 :UInt8; 336 shortForm @18 :Bool; 337 } 338 } 339} 340 341struct LineNumbers { 342 lineStarts @0 :List(UInt32); 343 length @1 :UInt32; 344 mapping @2 :List(Character); 345} 346 347struct Character { 348 byteIndex @0 :UInt64; 349 lengthUtf8 @1 :UInt8; 350 lengthUtf16 @2 :UInt8; 351}