Commit Graph

48 Commits

Author SHA1 Message Date
Tim Chevalier
3f3c9caf4d Handle poststates of breaking loops correctly in typestate
The poststate should be one where all predicates are assumed false,
rather than the unchanged prestate.

Closes #2374
2012-05-29 18:22:38 -07:00
Niko Matsakis
ccd8d5573e remove dead assignments 2012-05-24 13:35:57 -07:00
Niko Matsakis
f5c51b0a9c remove initedness checking from typestate, as best I could 2012-05-24 09:52:16 -07:00
Brian Anderson
4756556748 rustc: Move new_def_hash to ast_util 2012-05-23 00:43:02 -07:00
Brian Anderson
e546c4820b rustc: Don't copy vecs in seq_preconds. Huge perf win on some tests
Compile time for the included test goes from 5min to 18s.
2012-05-18 15:59:00 -07:00
Brian Anderson
3f283bb168 rustc: Don't recurse in seq_preconds. Consumes too much stack 2012-05-18 14:28:39 -07:00
Lindsey Kuper
b8880e3254 Remove be keyword.
Closes #2227.
2012-05-15 10:41:14 -07:00
Tim Chevalier
5428a22b95 First cut at dtors for classes
Classes with dtors should compile now. Haven't yet tested
whether they actually run correctly.

Beginnings of support for #2295, though that won't be done until
there's more test cases and resources are removed.
2012-05-14 14:26:10 -07:00
Paul Stansifer
13c924c049 Remove do { ... } while ... from the language. 2012-05-10 15:09:33 -07:00
Niko Matsakis
8a9df5aa38 make it illegal to implicitly capture mutable variables
this is the final part of #1273
2012-05-07 13:22:42 -07:00
Niko Matsakis
50ec6bd2c3 new cap clause syntax 2012-05-04 12:33:08 -07:00
Niko Matsakis
825fd1808e lots of work to make iface/impls parameterized by regions
- paths can now take region parameters, replacing the dirty hack
  I was doing before of abusing vstores.  vstores are now a bit
  of a hack though.

- fix various small bugs:
  - we never checked that iface types were compatible when casting
    to an iface with `as`
  - we allowed nonsense like int<int>
  - and more! (actually that may be it)
2012-04-25 19:26:56 -07:00
Marijn Haverbeke
9f99c3263b Rewrite exhaustiveness checker
Issue #2111
2012-04-25 09:15:17 +02:00
Graydon Hoare
929c3dd710 Workarounds for bug #2280: add some temporaries for borrowing. 2012-04-24 15:19:01 -07:00
Marijn Haverbeke
9053f54498 Move map iface over to more for-friendly iteration methods 2012-04-23 15:18:19 +02:00
Marijn Haverbeke
a872a99bfe Simplify representation of ast::path 2012-04-23 13:04:46 +02:00
Tim Chevalier
734166f41c Print out return type correctly in typestate error message
In the "not all paths return" error message, typestate was printing
the AST type from the fn decl, not the ty::t type. This ended in tears
when the AST return type was "ty_infer". Now it looks up the function node
ID's type and uses util::ppaux::ty_to_str instead.

Closes #2163.
2012-04-20 18:48:08 -07:00
Niko Matsakis
3c995fb8f3 make nominal types optionally parameterized by a self region.
Issue #2201.
2012-04-19 21:01:11 -07:00
Tim Chevalier
4f4a468e84 Forbid deinitializing upvars in typestate
Closes #1965.
2012-04-15 01:05:41 -07:00
Tim Chevalier
5c12cd72f4 Allow classes to implement ifaces
Introduce syntax like:

iface animal { ... }
class cat implements animal { ... }

to allow classes to implement ifaces. Casting classes to ifaces
is *not* yet supported. ifaces that a class implements are not
yet included in metadata.

The syntax is subject to change, and may go away completely if we
decide to use duck typing to relate classes with ifaces (see
http://smallcultfollowing.com/babysteps/blog/2012/04/10/declared-vs-duckish-typing/ )
2012-04-11 16:20:01 -07:00
Graydon Hoare
7a3b290245 Add vstore/evec/estr to compiler. 2012-04-11 11:08:40 -07:00
Tim Chevalier
fd26743bed Generic classes and generic class methods work cross-crate
Classes can have ty params now. So can methods inside classes.
That was probably true before, but now it should still work if you
call methods in a class that's defined in a different crate. Yay!
2012-04-10 11:01:36 -07:00
Tim Chevalier
9d274ec5f2 Re-rename option functions
get_with_default (nee from_maybe) => get_default
with_option (nee maybe) => map_default
with_option_do (nee may) => iter

As per discussion of 21be1379d5
2012-04-06 12:20:13 -07:00
Marijn Haverbeke
fc202ca034 Remove support for old-style for
Closes #1619
2012-04-06 20:38:23 +02:00
Marijn Haverbeke
c902eafa14 Convert old-style for loops to new-style
Most could use the each method, but because of the hack used to
disambiguate old- and new-style loops, some had to use vec::each.

(This hack will go away soon.)

Issue #1619
2012-04-06 20:38:23 +02:00
Tim Chevalier
1f892dcb01 Monomorphize class constructors, support generic classes and class methods
Allow class methods to have type parameters (this is a change from the
original classes proposal).

Add test cases for classes with type parameters, and classes with methods
that have their own type parameters.
2012-04-03 16:23:50 -07:00
Tim Chevalier
21be1379d5 Rename some core::option functions
from_maybe => get_with_default
maybe => with_option
may => with_option_do

I know these names are kind of ridiculous, but it's the best I could think of.
Feel free to bikeshed. Closes #2081
2012-04-02 16:12:49 -07:00
Marijn Haverbeke
f6e3738b9c Support an alternate for syntax that calls a higher-order function
The last argument of the call must be a block, and the type of this
argument must a function returning bool. `break` and `cont` are
supported in the body of the block, and return `false` or `true` from
the function. When the end of the function is reached, `true` is
implicitly returned.

    for vec::all([1, 2, 3]) {|elt|
        if elt == 2 { break; }
        log(error, elt);
    }

Issue #1619
2012-03-27 09:27:31 +02:00
Graydon Hoare
6e6798c4e1 Bulk-edit mutable -> mut. 2012-03-26 18:35:18 -07:00
Brian Anderson
a477aaba08 rustc: Move eval_const_expr to its own mod 2012-03-26 17:16:26 -07:00
Tim Chevalier
8bbd78075f Handle self correctly when translating classes
This change uses the same code for handling the "self" reference for
classes as is already used for impls/ifaces. This allows removing the
extra maybe_self_id argument (which was just for classes) to trans_closure
that I added before. I also rewrote the translation for class ctors so
that it doesn't generate new AST nodes (instead translating directly).

Also changed visit so that it visits class ctors correctly with visit_fn,
and changed typestate to not do return-checking when visiting a class ctor.
2012-03-23 20:37:50 -07:00
Niko Matsakis
b653a18416 add mut decls to rustc and make them mandatory 2012-03-21 21:04:14 -07:00
Niko Matsakis
cfcbec3cc3 Implement an initial version of placement new. 2012-03-20 20:39:40 -07:00
Marijn Haverbeke
7a34ac5890 Revert order of arguments to option::maybe and from_maybe
Closes #2019
2012-03-20 14:55:07 +01:00
Brian Anderson
5e8004d493 std: Follow conventions in bitv 2012-03-15 14:08:47 -07:00
Brian Anderson
3864d6d845 std: Rename the hashmap constructors to conform to new standards
Instead of using the new_ prefix just name them after their type
2012-03-14 18:19:08 -07:00
Brian Anderson
cd72b1f848 Overhaul constructor naming in libs 2012-03-13 11:07:22 -07:00
Tim Chevalier
205cefdc6e In typestate, consider infinite loops w/ conts to be infinite
If a loop { } contains a cont, that doesn't affect whether the entire
loop diverges. Only breaks affect that. Fix that in typestate.
2012-03-10 20:34:57 -08:00
Tim Chevalier
98260a2a22 Handle infinite-loop poststate correctly in typestate
If control passes an infinite loop (that doesn't have non-local
exits), then everything is true.
2012-03-10 20:15:27 -08:00
Tim Chevalier
321fd80219 Add an infinite loop construct
Add a loop {} construct for infinite loops, and use it in test
cases. See #1906 for details.
2012-03-09 16:40:58 -08:00
Patrick Walton
ddeaea2287 rustc: Change the address-of operator to an explicit production so that we can parse the mutability 2012-03-08 16:34:36 -08:00
Tim Chevalier
0c5fdc8745 Rename last to last_opt, last_unsafe to last
As per discussion on IRC. I am about to file an RFC for further
discussion about the more general issue of whether to enforce
invariants through types, typestate, or dynamic checks, but for now,
removing the misleading name "last_unsafe".
2012-03-08 15:25:56 -08:00
Patrick Walton
c9375fed8d stdlib: Stop incurring vtable dispatch costs when hashmaps are used
This required changing almost all users of hashmaps to import the hashmap interface first.

The `size` member in the hashmap structure was renamed to `count` to work around a name conflict.
2012-03-07 17:35:13 -08:00
Patrick Walton
c245d9e980 Revert "stdlib: Stop incurring vtable dispatch costs when hashmaps are used"
This reverts commit f0250a23d3.
2012-03-07 16:56:45 -08:00
Patrick Walton
f0250a23d3 stdlib: Stop incurring vtable dispatch costs when hashmaps are used
This required changing almost all users of hashmaps to import the hashmap interface first.

The `size` member in the hashmap structure was renamed to `count` to work around a name conflict.
2012-03-07 16:51:31 -08:00
Brian Anderson
0ee96de4ee rustc: Lower case error messages 2012-03-05 17:05:20 -08:00
Tim Chevalier
e2fa6f03f5 Translate simple classes
Programs using classes with fields only (no methods) compile and run,
    as long as nothing refers to a class in a different crate (todo).

    Also changed the AST representation of classes to have a separate
    record for constructor info (instead of inlining the fields in the
    item_class node), and fixed up spans and pretty-printing for
    classes.
2012-03-04 12:43:17 -08:00
Graydon Hoare
87c14f1e3d Move src/comp to src/rustc 2012-03-02 18:46:13 -08:00