1
1
using HydraScript . Lib . IR . Ast . Impl . Nodes . Expressions . PrimaryExpressions ;
2
- using HydraScript . Lib . IR . CheckSemantics . Exceptions ;
3
- using HydraScript . Lib . IR . CheckSemantics . Types ;
4
2
using HydraScript . Lib . IR . CheckSemantics . Variables ;
5
- using HydraScript . Lib . IR . CheckSemantics . Variables . Symbols ;
6
3
7
4
namespace HydraScript . Lib . IR . Ast . Impl . Nodes . Declarations ;
8
5
9
- public abstract record TypeValue
6
+ public abstract record TypeValue : IVisitable < TypeValue >
10
7
{
11
- public abstract Type BuildType ( SymbolTable symbolTable ) ;
8
+ public SymbolTable SymbolTable { get ; set ; } = default ! ;
9
+ public abstract TReturn Accept < TReturn > ( IVisitor < TypeValue , TReturn > visitor ) ;
12
10
}
13
11
14
- public record TypeIdentValue ( IdentifierReference TypeId ) : TypeValue
12
+ [ AutoVisitable < TypeValue > ]
13
+ public partial record TypeIdentValue ( IdentifierReference TypeId ) : TypeValue
15
14
{
16
- public override Type BuildType ( SymbolTable symbolTable ) =>
17
- symbolTable . FindSymbol < TypeSymbol > ( TypeId ) ? . Type ??
18
- throw new UnknownIdentifierReference ( TypeId ) ;
19
-
20
15
public override string ToString ( ) => TypeId ;
21
16
}
22
17
23
- public record ArrayTypeValue ( TypeValue TypeValue ) : TypeValue
18
+ [ AutoVisitable < TypeValue > ]
19
+ public partial record ArrayTypeValue ( TypeValue TypeValue ) : TypeValue
24
20
{
25
- public override Type BuildType ( SymbolTable symbolTable ) =>
26
- new ArrayType ( TypeValue . BuildType ( symbolTable ) ) ;
27
-
28
21
public override string ToString ( ) => $ "{ TypeValue } []";
29
22
}
30
23
31
- public record NullableTypeValue ( TypeValue TypeValue ) : TypeValue
24
+ [ AutoVisitable < TypeValue > ]
25
+ public partial record NullableTypeValue ( TypeValue TypeValue ) : TypeValue
32
26
{
33
- public override Type BuildType ( SymbolTable symbolTable ) =>
34
- new NullableType ( TypeValue . BuildType ( symbolTable ) ) ;
35
-
36
27
public override string ToString ( ) => $ "{ TypeValue } ?";
37
28
}
38
29
@@ -44,15 +35,10 @@ public override string ToString() =>
44
35
$ "{ Key } : { TypeValue } ";
45
36
}
46
37
47
- public record ObjectTypeValue (
38
+ [ AutoVisitable < TypeValue > ]
39
+ public partial record ObjectTypeValue (
48
40
IEnumerable < PropertyTypeValue > Properties ) : TypeValue
49
41
{
50
- public override Type BuildType ( SymbolTable symbolTable ) =>
51
- new ObjectType (
52
- Properties . Select ( x => new PropertyType (
53
- Id : x . Key ,
54
- x . TypeValue . BuildType ( symbolTable ) ) ) ) ;
55
-
56
42
public override string ToString ( ) =>
57
43
$ "{{{string.Join(';', Properties)}}}";
58
44
}
0 commit comments