Commit Graph

3636 Commits

Author SHA1 Message Date
Michael Sullivan
f3717da1b1 Modify the fn vistors in walk so that they can handle functions without names. Update the typestate code to understand this. 2011-06-24 15:46:20 -07:00
Paul Stansifer
142ff011da Make a test compile faster. 2011-06-24 14:47:36 -07:00
Patrick Walton
baf474443a rustc: Increment by the unit size in iter_structural_ty when iterating over interior vectors if the unit size is dynamic 2011-06-24 17:36:30 -04:00
Marijn Haverbeke
2ebd19477b Sanitize use of ids for obj constructors.
Typeck and trans used to, by historical coincidence, use the item_obj
node id, which was used to identify the obj type by the rest of the
system, for the constructor function. This is now identified by the
ctor id stored in the tag throughout.
2011-06-24 21:22:52 +02:00
Marijn Haverbeke
9643aedb04 Remove uses of variable name 'res' from rustc
This in preparation of making 'res' a keyword for defining resources.
Please don't introduce too many new ones in the meantime...
2011-06-24 21:22:23 +02:00
Marijn Haverbeke
d507d5fe91 Remove res idents from stdlib 2011-06-24 21:13:26 +02:00
Marijn Haverbeke
3d7fdb509a Remove def_obj
Since obj constructors and types have different def_ids now,
their def can simply be a def_fn and a def_ty.
2011-06-24 21:13:25 +02:00
Patrick Walton
b4c0893a39 rustc: If needed, duplicate types' heap parts recursively through structural types 2011-06-24 14:32:50 -04:00
Brian Anderson
1e7f06b17a test: Improve ternary operator tests 2011-06-23 23:27:32 -07:00
Brian Anderson
3aa8d7ff45 rustc: Pretty-print ternary operator 2011-06-23 23:14:40 -07:00
Brian Anderson
b9fc4dfc54 rustc: Cleanup trans_if, trans_alt 2011-06-23 22:16:16 -07:00
Brian Anderson
05c0216654 rustc: Add ternary operator. Closes #565
The implementation is so simple it might be considered cheating: at almost
every step the expr_ternary is just converted to expr_if.
2011-06-23 22:16:11 -07:00
Michael Sullivan
5495ad17d1 Fix type inference inside of anonymous functions. 2011-06-23 21:36:10 -07:00
Eric Holk
860e8fd98b Combined set_registers and get_registers into swap_registers. 2011-06-23 20:23:04 -07:00
Eric Holk
98dee91f25 Wrote swap_context in assembly. Closes #548. This also allows us to re-enable optimization on OSX for both gcc and clang. Also, re-enamed task-comm-1.rs, which was previously broken by optimization. 2011-06-23 18:49:29 -07:00
Rafael Ávila de Espíndola
3c534b2bef Remove parse_str_lit_or_env_ident.
We decided to use metadata for the more complex cases, and a simple
string is enough for rustc right now.
2011-06-23 18:42:55 -04:00
Graydon Hoare
14c31c26c2 Flesh out type pp code. 2011-06-23 18:40:44 -04:00
Patrick Walton
f3798fd213 rustc: Load immediate types when iterating over interior vectors 2011-06-23 17:43:03 -04:00
Tim Chevalier
3cf00c1577 Correct error message for argument mode mismatch
If you use a function expecting an alias argument in a context that
expects a function expecting a value argument, or vice versa, the
previous error message complained that the number of arguments was
wrong. Fixed the error message to be accurate.
2011-06-23 11:54:10 -07:00
Lindsey Kuper
5bd65de289 Typo fix in test case. 2011-06-23 10:47:29 -07:00
Tim Chevalier
9a48bd2f21 Compute typestate properly for move
typestate now drops constraints correctly in the post-state of
a move expression or a declaration whose op is a move. It doesn't
yet drop constraints mentioning variables that get updated.

To do this, I had to change typestate to use trit-vectors instead
of bit-vectors, because for every constraint, there are three
possible values: known-to-be-false (e.g. after x <- y, init(y) is
known-to-be-false), known-to-be-true, and unknown. Before, we
conflated known-to-be-false with unknown. But move requires them
to be treated differently. Consider:

(program a)
(a1) x = 1;
(a2) y <- x;
(a3) log x;

(program b)
(b1) x = 1;
(b2) y <- z;
(b3) log x;

With only two values, the postcondition of statement a2 for
constraint init(x) is the same as that of b2: 0. But in (a2)'s
postcondition, init(x) *must* be false, but in (b2)'s condition,
it's just whatever it was in the postcondition of the preceding statement.
2011-06-22 22:13:42 -07:00
Brian Anderson
7105cd1761 test: Add test for string matching in pattern alts. Closes #53 2011-06-22 22:05:11 -07:00
Brian Anderson
54566e9037 rustc: Convert field access on invalid types from an ICE to a fatal error
Closes #367
2011-06-22 21:31:32 -07:00
Lindsey Kuper
d9f452a2a8 Some work on supporting forwarding slots in vtables (issue #539). 2011-06-22 21:07:20 -07:00
Brian Anderson
523a088451 rustc: Use the rhs span when unifying binops
This makes the error message correctly identify the term that wasn't the
expected type. Issue #516.
2011-06-22 20:50:53 -07:00
Brian Anderson
ae234d61ea rustc: Remove some unneeded type annotations 2011-06-22 20:45:02 -07:00
Brian Anderson
d2b7ea877c rustc: Don't commit unification changes until unify succeeds
This is so that subsequent reports about type mismatches get the types
correct.

Issue #516
2011-06-22 20:43:50 -07:00
Brian Anderson
d9b56ec2ea rustc: Limit creader exports 2011-06-22 19:04:04 -07:00
Brian Anderson
ab98f16373 rustc: Downcase metadata::Encode 2011-06-22 18:09:53 -07:00
Brian Anderson
8746b84eec rustc: Handle valueless ret expressions as block results. Closes #521 2011-06-22 17:20:01 -07:00
Paul Stansifer
b4c3b83f26 Fix bug: globbed imports were importing everything visible from the other
module, not just everything exported.
2011-06-22 15:41:39 -07:00
Brian Anderson
adc18bb24a rustc: Introduce and parse additional meta_item forms
Examples: #[test], #[link(name = "vers")]

Issue #487
2011-06-22 13:55:58 -07:00
Rafael Ávila de Espíndola
64513808ca Use fast regalloc and codegen at OptLevel=0. 2011-06-22 16:50:30 -04:00
Brian Anderson
a6e188f8bf rustc: Rename parser.err to parser.fatal 2011-06-22 12:55:26 -07:00
Paul Stansifer
fe0925678c Remove a simidgeon of dead code. 2011-06-23 03:32:57 +08:00
Brian Anderson
cc2a514cdc test: Enable more tests 2011-06-22 08:35:02 -07:00
Michael Sullivan
7a4fb084f1 Pull environment loading out into a function. 2011-06-22 07:03:16 -07:00
Michael Sullivan
6b40cedcb1 Pull building the environment for for_each into a seperate function. 2011-06-22 07:03:16 -07:00
Michael Sullivan
c07443e6eb Removing out-of-date comment. 2011-06-22 07:03:15 -07:00
Tim Chevalier
1a6d029b07 Emit a better error message for unbound type parameters in nested functions
This code was causing a bounds check failure:

fn hd[U](&vec[U] v) -> U {
  fn hd1(&vec[U] w) -> U {
    ret w.(0);
  }
  ret hd1(v);
}

because in hd1, U was being treated as if it referred to a type
parameter of hd1, rather than referring to the lexically enclosing binding
for U that's part of hd.

I'm actually not sure whether this is a legit program or not. But I wanted
to get rid of the bounds check error, so I assumed that program shouldn't
compile and made it a proper error message.
2011-06-21 17:58:49 -07:00
Lindsey Kuper
efd8ff4647 Comments for all the anon obj tests. 2011-06-21 16:35:21 -07:00
Tim Chevalier
7fb35ecf84 Serialize constraints in types (literal arguments still not supported)
This involved, in part, changing the ast::def type so that a def_fn
has a "purity" field. This lets the typechecker determine whether
functions defined in other crates are pure.

It also required updating some error messages in tests. As a test
for cross-crate constrained functions, I added a safe_slice function
to std::str (slice(), with one of the asserts replaced with a
function precondition) and some test cases (various versions of
fn-constraint.rs) that call it. Also, I changed "fn" to "pred" for
some of the boolean functions in std::uint.
2011-06-21 14:37:33 -07:00
Marijn Haverbeke
3b6d94d489 Move names and ids of native items into their recs, rather than their tags 2011-06-21 23:11:00 +02:00
Lindsey Kuper
26d8eaefa7 Puts out burning tinderbox (oops, AST nodes don't have def_ids/anns). 2011-06-21 14:07:28 -07:00
Lindsey Kuper
84005fadbf Some progress on support for extending objects with new fields (issue
into four separate issues (#538, #539, #540, #543) with corresponding
tests.
2011-06-21 13:31:27 -07:00
Lindsey Kuper
718ee98f43 More descriptive identifiers. 2011-06-21 13:31:27 -07:00
Marijn Haverbeke
c34e9b33d9 Move expr ids into the expr record type
This simplifies the tag variants a bit and makes expr_node_id
obsolete.
2011-06-21 22:25:32 +02:00
Eric Holk
edf73f0512 Setting rt optimization on OS X to -O0 when using clang, like we already do with gcc. Tail-call elimination was causing valgrind errors with stack switching. Closes #494. 2011-06-21 13:13:33 -07:00
Brian Anderson
34040be580 test: Add a test for distinguishing attributes from extensions
Issue #487
2011-06-21 11:50:55 -07:00
Patrick Walton
c109c9dd73 rustc: Output an unimplemented message when alias encounters an unknown sequence type 2011-06-21 11:10:14 -04:00