7
7
package com .whatsapp .eqwalizer .ast
8
8
9
9
import com .whatsapp .eqwalizer .ast .Exprs .{Clause , Expr }
10
- import com .whatsapp .eqwalizer .ast .ExternalTypes ._
11
10
import com .whatsapp .eqwalizer .ast .InvalidDiagnostics .Invalid
12
11
import com .whatsapp .eqwalizer .ast .Types ._
13
12
import com .whatsapp .eqwalizer .tc .TcDiagnostics .{BehaviourError , TypeError }
@@ -19,37 +18,20 @@ import scala.collection.immutable.TreeSeqMap
19
18
20
19
object Forms {
21
20
22
- case class Module (name : String )(val pos : Pos ) extends ExternalForm with InternalForm
23
- case class CompileExportAll ()(val pos : Pos ) extends ExternalForm
24
- case class Export (funs : List [Id ])(val pos : Pos ) extends ExternalForm with InternalForm
25
- case class Import (module : String , funs : List [Id ])(val pos : Pos ) extends ExternalForm with InternalForm
26
- case class ExportType (types : List [Id ])(val pos : Pos ) extends ExternalForm with InternalForm
27
- case class FunDecl (id : Id , clauses : List [Clause ])(val pos : Pos ) extends ExternalForm with InternalForm
28
- case class File (file : String , start : Int )(val pos : Pos ) extends ExternalForm with InternalForm
21
+ case class Module (name : String )(val pos : Pos ) extends InternalForm
22
+ case class Export (funs : List [Id ])(val pos : Pos ) extends InternalForm
23
+ case class Import (module : String , funs : List [Id ])(val pos : Pos ) extends InternalForm
24
+ case class ExportType (types : List [Id ])(val pos : Pos ) extends InternalForm
25
+ case class FunDecl (id : Id , clauses : List [Clause ])(val pos : Pos ) extends InternalForm
26
+ case class File (file : String , start : Int )(val pos : Pos ) extends InternalForm
29
27
case class Fixme (comment : TextRange , suppression : TextRange , isIgnore : Boolean )
30
- case class ElpMetadata (fixmes : List [Fixme ])(val pos : Pos ) extends ExternalForm with InternalForm
31
- case class Behaviour (name : String )(val pos : Pos ) extends ExternalForm with InternalForm
32
- case class EqwalizerNowarnFunction (id : Id )(val pos : Pos ) extends ExternalForm with InternalForm
33
- case class EqwalizerUnlimitedRefinement (id : Id )(val pos : Pos ) extends ExternalForm with InternalForm
34
-
35
- /** used for analyses only, should not affect the behavior of the type checker
36
- */
37
- case class TypingAttribute (names : List [String ])(val pos : Pos ) extends ExternalForm
28
+ case class ElpMetadata (fixmes : List [Fixme ])(val pos : Pos ) extends InternalForm
29
+ case class Behaviour (name : String )(val pos : Pos ) extends InternalForm
30
+ case class EqwalizerNowarnFunction (id : Id )(val pos : Pos ) extends InternalForm
31
+ case class EqwalizerUnlimitedRefinement (id : Id )(val pos : Pos ) extends InternalForm
38
32
39
33
sealed trait Form
40
34
41
- sealed trait ExternalForm extends Form { val pos : Pos }
42
- case class ExternalTypeDecl (id : Id , params : List [String ], body : ExtType , file : Option [String ])(val pos : Pos )
43
- extends ExternalForm
44
- case class ExternalOpaqueDecl (id : Id , params : List [String ], body : ExtType , file : Option [String ])(val pos : Pos )
45
- extends ExternalForm
46
- case class ExternalFunSpec (id : Id , types : List [ConstrainedFunType ])(val pos : Pos ) extends ExternalForm
47
- case class ExternalCallback (id : Id , types : List [ConstrainedFunType ])(val pos : Pos ) extends ExternalForm
48
- case class ExternalOptionalCallbacks (ids : List [Id ])(val pos : Pos ) extends ExternalForm
49
- case class ExternalRecDecl (name : String , fields : List [ExternalRecField ], file : Option [String ])(val pos : Pos )
50
- extends ExternalForm
51
- case class ExternalRecField (name : String , tp : Option [ExtType ], defaultValue : Option [Expr ])
52
-
53
35
sealed trait InternalForm extends Form { val pos : Pos }
54
36
case class FunSpec (id : Id , ty : FunType )(val pos : Pos ) extends InternalForm
55
37
case class OverloadedFunSpec (id : Id , tys : List [FunType ])(val pos : Pos ) extends InternalForm
@@ -81,12 +63,12 @@ object Forms {
81
63
case class FuncDecl (id : Id , errors : List [TypeError ])(val pos : Pos ) extends InternalForm
82
64
case class MisBehaviour (te : BehaviourError )(val pos : Pos ) extends InternalForm
83
65
84
- def load (module : String ): List [ExternalForm ] = {
66
+ def load (module : String ): List [InternalForm ] = {
85
67
val bytes = Ipc .getAstBytes(module, Ipc .ConvertedForms ).get
86
- readFromArray[List [ExternalForm ]](bytes)
68
+ readFromArray[List [InternalForm ]](bytes)
87
69
}
88
70
89
- implicit val codec : JsonValueCodec [List [ExternalForm ]] = JsonCodecMaker .make(
71
+ implicit val codec : JsonValueCodec [List [InternalForm ]] = JsonCodecMaker .make(
90
72
CodecMakerConfig .withAllowRecursiveTypes(true ).withDiscriminatorFieldName(None ).withFieldNameMapper {
91
73
case " pos" => " location"
92
74
case " mod" => " module"
0 commit comments