Skip to content

Commit db6bdbd

Browse files
committed
---
yaml --- r: 2172 b: refs/heads/master c: ac62488 h: refs/heads/master v: v3
1 parent 8f85000 commit db6bdbd

File tree

2 files changed

+48
-2
lines changed

2 files changed

+48
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: c49735d7c48770f21d2fd5e1e92a41e78d1506d2
2+
refs/heads/master: ac62488bb1ca8ff934a803d3b608e2a1b2ccc82e

trunk/src/comp/middle/ty.rs

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,15 @@ fn method_ty_to_fn_ty(method m) -> @ty.t {
3535
ret plain_ty(ty_fn(m.proto, m.inputs, m.output));
3636
}
3737

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+
3845
// NB: If you change this, you'll probably want to change the corresponding
3946
// AST structure in front/ast.rs as well.
40-
type t = rec(sty struct, option.t[str] cname);
4147
tag sty {
4248
ty_nil;
4349
ty_bool;
@@ -99,6 +105,46 @@ type ty_param_count_and_ty = tup(uint, @t);
99105
type type_cache = hashmap[ast.def_id,ty_param_count_and_ty];
100106

101107

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+
102148
// Stringification
103149

104150
fn path_to_str(&ast.path pth) -> str {

0 commit comments

Comments
 (0)