@@ -35,9 +35,15 @@ fn method_ty_to_fn_ty(method m) -> @ty.t {
35
35
ret plain_ty ( ty_fn ( m. proto , m. inputs , m. output ) ) ;
36
36
}
37
37
38
+ // Do not construct these manually. Soon we want to intern these, at which
39
+ // point this will break.
40
+ //
41
+ // TODO: It'd be really nice to be able to hide this definition from the
42
+ // outside world, to enforce the above invariant.
43
+ type t = rec ( sty struct , option. t[ str] cname ) ;
44
+
38
45
// NB: If you change this, you'll probably want to change the corresponding
39
46
// AST structure in front/ast.rs as well.
40
- type t = rec ( sty struct , option. t[ str] cname ) ;
41
47
tag sty {
42
48
ty_nil;
43
49
ty_bool;
@@ -99,6 +105,46 @@ type ty_param_count_and_ty = tup(uint, @t);
99
105
type type_cache = hashmap [ ast. def_id , ty_param_count_and_ty] ;
100
106
101
107
108
+ // Type constructors
109
+
110
+ fn mk_nil ( ) -> @t { ret plain_ty ( ty_nil) ; }
111
+ fn mk_bool ( ) -> @t { ret plain_ty ( ty_bool) ; }
112
+ fn mk_int ( ) -> @t { ret plain_ty ( ty_int) ; }
113
+ fn mk_float ( ) -> @t { ret plain_ty ( ty_float) ; }
114
+ fn mk_uint ( ) -> @t { ret plain_ty ( ty_uint) ; }
115
+ fn mk_mach ( util. common. ty_mach tm ) -> @t { ret plain_ty ( ty_machine ( tm) ) ; }
116
+ fn mk_char ( ) -> @t { ret plain_ty ( ty_char) ; }
117
+ fn mk_str ( ) -> @t { ret plain_ty ( ty_str) ; }
118
+
119
+ fn mk_tag ( ast. def_id did , vec[ @t] tys ) -> @t {
120
+ ret plain_ty ( ty_tag ( did, tys) ) ;
121
+ }
122
+
123
+ fn mk_box ( mt tm) -> @t { ret plain_ty ( ty_box ( tm) ) ; }
124
+ fn mk_vec ( mt tm) -> @t { ret plain_ty ( ty_vec ( tm) ) ; }
125
+ fn mk_port ( @t ty ) -> @t { ret plain_ty ( ty_port ( ty) ) ; }
126
+ fn mk_chan ( @t ty ) -> @t { ret plain_ty ( ty_chan ( ty) ) ; }
127
+ fn mk_task ( ) -> @t { ret plain_ty ( ty_task) ; }
128
+ fn mk_tup ( vec[ mt] tms ) -> @t { ret plain_ty ( ty_tup ( tms) ) ; }
129
+ fn mk_rec ( vec[ field] fs ) -> @t { ret plain_ty ( ty_rec ( fs) ) ; }
130
+
131
+ fn mk_fn ( ast. proto proto , vec[ arg] args , @t ty ) -> @t {
132
+ ret plain_ty ( ty_fn ( proto, args, ty) ) ;
133
+ }
134
+
135
+ fn mk_native_fn ( ast. native_abi abi , vec[ arg] args , @t ty ) -> @t {
136
+ ret plain_ty ( ty_native_fn ( abi, args, ty) ) ;
137
+ }
138
+
139
+ fn mk_obj ( vec[ method] meths ) -> @t { ret plain_ty ( ty_obj ( meths) ) ; }
140
+ fn mk_var ( int v) -> @t { ret plain_ty ( ty_var ( v) ) ; }
141
+ fn mk_local ( ast. def_id did ) -> @t { ret plain_ty ( ty_local ( did) ) ; }
142
+ fn mk_param ( uint n) -> @t { ret plain_ty ( ty_param ( n) ) ; }
143
+ fn mk_bound_param ( uint n) -> @t { ret plain_ty ( ty_bound_param ( n) ) ; }
144
+ fn mk_type ( ) -> @t { ret plain_ty ( ty_type) ; }
145
+ fn mk_native ( ) -> @t { ret plain_ty ( ty_native) ; }
146
+
147
+
102
148
// Stringification
103
149
104
150
fn path_to_str ( & ast. path pth ) -> str {
0 commit comments