File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,21 @@ import syntax::{visit, ast_util};
3
3
import syntax:: ast:: * ;
4
4
import syntax:: codemap:: span;
5
5
6
+ // Kind analysis pass. There are three kinds:
7
+ //
8
+ // sendable: scalar types, and unique types containing only sendable types
9
+ // copyable: boxes, objects, closures, and uniques containing copyable types
10
+ // noncopyable: resources, or unique types containing resources
11
+ //
12
+ // This pass ensures that type parameters are only instantiated with types
13
+ // whose kinds are equal or less general than the way the type parameter was
14
+ // annotated (with the `send` or `copy` keyword).
15
+ //
16
+ // It also verifies that noncopyable kinds are not copied. Sendability is not
17
+ // applied, since none of our language primitives send. Instead, the sending
18
+ // primitives in the stdlib are explicitly annotated to only take sendable
19
+ // types.
20
+
6
21
fn kind_to_str ( k : kind ) -> str {
7
22
alt k {
8
23
kind_sendable. { "sendable" }
Original file line number Diff line number Diff line change @@ -3,6 +3,24 @@ import syntax::ast::*;
3
3
import std:: list:: { list, nil, cons, tail} ;
4
4
import std:: { vec, list, option} ;
5
5
6
+ // Last use analysis pass.
7
+ //
8
+ // Finds the last read of each value stored in a local variable or
9
+ // callee-owned argument (arguments with by-move or by-copy passing
10
+ // style). This is a limited form of liveness analysis, peformed
11
+ // (perhaps foolishly) directly on the AST.
12
+ //
13
+ // The algorithm walks the AST, keeping a set of (def, last_use)
14
+ // pairs. When the function is exited, or the local is overwritten,
15
+ // the current set of last uses is marked with 'true' in a table.
16
+ // Other branches may later overwrite them with 'false' again, since
17
+ // they may find a use coming after them. (Marking an expression as a
18
+ // last use is only done if it has not already been marked with
19
+ // 'false'.)
20
+ //
21
+ // Some complexity is added to deal with joining control flow branches
22
+ // (by `break` or conditionals), and for handling loops.
23
+
6
24
// Marks expr_paths that are last uses.
7
25
type last_uses = std:: map:: hashmap < node_id , ( ) > ;
8
26
You can’t perform that action at this time.
0 commit comments