Commit graph

268 commits

Author SHA1 Message Date
Brian Anderson
e35984b6c6 Introduce str_slice runtime function
This reduces the time to execute the new lib-str tests from 1:40ish to a few
seconds and will eventually allow the full lib-sha1 test to run in a
reasonable amount of time. XFAIL lib-str in stage0 - it will run very slowly
until the next snapshot.
2011-05-11 01:38:16 -04:00
Patrick Walton
869e9017eb rustc: Create mutable vectors in macos_OS.rs. Should put out Darwin tinderbox. 2011-05-10 17:50:39 -07:00
Graydon Hoare
4b5b96c511 Remove a couple more spurious 'mutable' value qualifiers from macos_OS.rs. 2011-05-10 17:04:41 -07:00
Patrick Walton
813636d52e stdlib: Remove Str.unsafe_from_mutable_bytes(). rustc now self-hosts 18 seconds faster. 2011-05-10 15:20:36 -07:00
Graydon Hoare
10a2093d37 Failure to re-stage changes strikes again. 2011-05-06 16:54:50 -07:00
Graydon Hoare
0f23bbac01 Fix GenericOS.getenv returning a raw str, return an Option.t[str] instead. 2011-05-06 16:30:39 -07:00
Marijn Haverbeke
a3ec0b1f64 Rename std modules to be camelcased
(Have fun mergining your stuff with this.)
2011-05-06 22:51:19 +02:00
Kelly Wilson
b4a0d891c0 Ge the host triple using LLVM. Fix a few 'mutable' warnings also. 2011-05-06 11:30:39 -07:00
Kelly Wilson
850dff486e Add quick sort function to the std lib. 2011-05-05 16:40:57 -07:00
Graydon Hoare
50ac893b00 Attempt to fix fs.dirname harder. 2011-05-05 14:31:45 -07:00
Graydon Hoare
2131f2bb6b Because good hackers at least check to see if the code compiles. 2011-05-05 13:53:57 -07:00
Graydon Hoare
c80255e510 Fix assumption that only os_fs.path_sep can separate paths, sigh. 2011-05-05 13:42:52 -07:00
Marijn Haverbeke
1f45dda9d2 Remove 'deprecated mutable...' from our code
This should make compilation a bit less noisy.
2011-05-05 20:19:43 +02:00
Patrick Walton
147a2d655f Un-revert "Use different syntax for checks that matter to typestate", fixing the problem.
This reverts commit d08b443fff.
2011-05-02 17:50:46 -07:00
Graydon Hoare
d08b443fff Revert "Use different syntax for checks that matter to typestate"
This reverts commit aa25f22f19. It broke stage2, not sure why yet.
2011-05-02 17:35:33 -07:00
Tim Chevalier
aa25f22f19 Use different syntax for checks that matter to typestate
This giant commit changes the syntax of Rust to use "assert" for
"check" expressions that didn't mean anything to the typestate
system, and continue using "check" for checks that are used as
part of typestate checking.

Most of the changes are just replacing "check" with "assert" in test
cases and rustc.
2011-05-02 12:16:29 -07:00
Patrick Walton
5d3e553141 stdlib: Add a Time module to the standard library 2011-04-29 11:54:06 -07:00
Patrick Walton
66e5dfbde6 stdlib: Provide "array" as a friendlier shorthand for "vec[mutable? T]" 2011-04-28 17:15:32 -07:00
Patrick Walton
660c742902 stdlib: Add a color_supported() function to Term 2011-04-28 14:54:00 -07:00
Patrick Walton
5f60937318 stdlib: Add getenv(3) to win32_os. 2011-04-28 14:35:22 -07:00
Tim Chevalier
7c4f8cb459 Further work on typestate_check
Lots of work on typestate_check, seems to get a lot of the way
through checking the standard library.

* Added for, for_each, assign_op, bind, cast, put, check, break,
and cont. (I'm not sure break and cont are actually handled correctly.)

* Fixed side-effect bug in seq_preconds so that unioning the
preconditions of a sequence of statements or expressions
is handled correctly.

* Pass poststate correctly through a stmt_decl.

* Handle expr_ret and expr_fail properly (after execution of a ret
or fail, everything is true -- this is needed to handle ifs and alts
where one branch is a ret or fail)

* Fixed bug in set_prestate_ann where a thing that needed to be
mutated wasn't getting passed as an alias

* Fixed bug in how expr_alt was treated (zero is not the identity
for intersect, who knew, right?)

* Update logging to reflect log_err vs. log

* Fixed find_locals so as to return all local decls and exclude
function arguments.

* Make union_postconds work on an empty vector (needed to handle
empty blocks correctly)

* Added _vec.cat_options, which takes a list of option[T] to a list
of T, ignoring any Nones

* Added two test cases.
2011-04-28 13:26:19 -07:00
Patrick Walton
616ae95f6b stdlib: Use an unsafe cast to speed up the memory writer 2011-04-27 18:18:28 -07:00
Patrick Walton
180a389832 stdlib/rt: Add an unsafe function to cast immutable vectors to mutable ones 2011-04-27 18:14:56 -07:00
Graydon Hoare
4c7886de80 Fix _str.bytes to trivial version. 2011-04-27 13:06:19 -07:00
Patrick Walton
fef8314c2e stdlib: Real fix for _uint.parse_buf(). 2011-04-27 11:59:22 -07:00
Patrick Walton
73044b3455 stdlib: Fix a crazy underflow bug in _uint.parse_buf. Oops. 2011-04-27 11:49:06 -07:00
Brian Anderson
8216b5fc10 Fix the interaction between various flags in #fmt 2011-04-26 20:49:03 -04:00
Brian Anderson
2e12fbfc06 Support octal #fmt conversions 2011-04-26 20:20:17 -04:00
Brian Anderson
66b59e4b05 Make #fmt char conversions behave like printf 2011-04-26 20:20:17 -04:00
Patrick Walton
79d27ccb58 stdlib: Add a silly ANSI color library 2011-04-26 13:08:48 -07:00
Marijn Haverbeke
74c7457131 Add GetOpts module to std 2011-04-26 20:30:44 +02:00
Marijn Haverbeke
d0ed2e384a Add _str.slice to std lib 2011-04-26 17:38:14 +02:00
Graydon Hoare
5fe21b5af0 Skip likely-zero initial probe, speed up map.rs. 2011-04-25 04:12:33 +00:00
Graydon Hoare
d3eb3b42aa Minimize calls to hash function in map.rs 2011-04-22 01:06:20 -07:00
Patrick Walton
735435bf96 stdlib: Add a pointer equality function to the standard library and a test case 2011-04-21 16:44:17 -07:00
Tim Chevalier
b7dd75c904 Handle nested items correctly in typestate_check
Summary says it all. Actually, only nested objects and functions
are handled, but that's better than before. The fold that I was using
before to traverse a crate wasn't working correctly, because annotations
have to reflect the number of local variables of the nearest enclosing
function (in turn, because annotations are represented as bit vectors).
The fold was traversing the AST in the wrong order, first filling in
the annotations correctly, but then re-traversing them with the bit
vector length for any outer nested functions, and so on.

Remedying this required writing a lot of tedious boilerplate code
because I scrapped the idea of using a fold altogether.

I also made typestate_check handle unary, field, alt, and fail.

Also, some miscellaneous changes:
* added annotations to blocks in typeck
* fix pprust so it can handle spawn
* added more logging functions in util.common
* fixed _vec.or
* added maybe and from_maybe in option
* removed fold_block field from ast_fold, since it was never used
2011-04-19 14:56:28 -07:00
Graydon Hoare
3d9cf15d0b Remove half-baked 'opacity' layer qualifier. 2011-04-19 14:00:04 -07:00
Graydon Hoare
d2bd07dcb0 Remove effect system from src. 2011-04-19 13:35:49 -07:00
Marijn Haverbeke
6511d471ba replace error logging with log_err in stdlib and rustc 2011-04-19 16:57:13 +02:00
Brian Anderson
7f90000ab6 Precision overrides 0-padding in #fmt 2011-04-18 22:53:26 -04:00
Brian Anderson
59d5267936 Rearrange ExtFmt.RT.pad to recover some horizontal space 2011-04-18 21:36:04 -04:00
Brian Anderson
869b28e393 Left-justification overrides 0-padding in #fmt 2011-04-18 21:36:04 -04:00
Brian Anderson
d4f1a48111 Support 0 flag in #fmt 2011-04-18 21:36:04 -04:00
Brian Anderson
9976bb93d6 Support the space flag in #fmt 2011-04-17 19:50:58 -04:00
Brian Anderson
86a43c24d6 Support + flag in #fmt 2011-04-17 18:19:26 -04:00
Brian Anderson
1bec738c56 Support #fmt precision for bools, with same rules as strings
Not totally confident this is desirable. The alternative would be to make it a
compile error.
2011-04-17 17:24:17 -04:00
Brian Anderson
685e820465 Treat char #fmt conversions just like str conversions
Add missing tests
2011-04-17 17:06:55 -04:00
Brian Anderson
8f6603f58e Support #fmt precision for signed types 2011-04-17 16:51:17 -04:00
Brian Anderson
4c0aea69da Support #fmt precision for unsigned types 2011-04-17 16:18:25 -04:00
Brian Anderson
c7edcb3a72 Support #fmt precision for string types 2011-04-17 13:10:02 -04:00
Brian Anderson
96e3e29e88 Support left-justification in #fmt conversions 2011-04-16 19:43:29 -04:00
Brian Anderson
dcfdb02fab Make #fmt support explicit conversion widths 2011-04-16 18:01:17 -04:00
Patrick Walton
3e922e2ecf stdlib: Add some vector functions: empty, empty_mut, grow_set, and freeze. Change _vec.grow to use uint arguments. 2011-04-15 17:46:16 -07:00
Patrick Walton
ec5a60d5e2 rustc: Use union-find for variable substitution 2011-04-14 11:24:25 -07:00
Brian Anderson
99a697b56a Add support for upper-case hex and binary output to #fmt.
Only works for uints at present. Necessitated the addition of _str.to_upper.
2011-04-13 22:14:54 -04:00
Brian Anderson
5c0f4c1939 Add more commentary about ExtFmt 2011-04-13 22:14:40 -04:00
Brian Anderson
4844e1c08a Add support for printing uints as lower-case hex to ExtFmt.
Begin passing an ExtFmt.RT.conv parsed format description to each of the
ExtFmt.RT.conv* functions.
2011-04-13 22:14:24 -04:00
Brian Anderson
aebdef0cd6 Move #fmt conversion model into ExtFmt.CT namespace 2011-04-13 22:13:21 -04:00
Tim Chevalier
7c6e6fc5d4 Make expr_while work in typestate_check
Also did some refactoring in typestate_check. All test cases in
compile-fail that involve uninitialized vars now fail correctly!
(All eight of them, that is.)
2011-04-13 15:50:34 -07:00
Graydon Hoare
80a4b1ba53 Slight updates to match API drift in io, lib-io.rs passes. 2011-04-13 12:05:15 -07:00
Tim Chevalier
d7e8818414 Further work on typestate. Handles expr_rec and expr_assign now.
Also changed the ts_ann field on statements to be an ann instead,
which explains most of the changes.

As well, got rid of the "warning: no type for expression" error
by filling in annotations for local decls in typeck (not sure whether
this was my fault or not).

Finally, in bitv, added a clone() function to copy a bit vector,
and fixed is_true, is_false, and to_str to not be nonsense.
2011-04-12 14:31:46 -07:00
Brian Anderson
73eecbd0ca Factor out creation of calls into ExtFmt.RT 2011-04-11 21:55:03 -04:00
Brian Anderson
bba245f3e6 Add support for bool, char to extfmt.
XFAIL syntax-extension-fmt in rustboot.
2011-04-11 21:54:03 -04:00
Brian Anderson
37f87161cc Move ExtFmt compile-time functions into their own module 2011-04-11 21:51:23 -04:00
Brian Anderson
c41796f2ca Use correct indentation for ExtFmt.rs 2011-04-11 21:51:23 -04:00
Brian Anderson
ce85b9eb7b Make ExtFmt call its own functions instead of others defined in std 2011-04-11 21:51:23 -04:00
Brian Anderson
d4d0144bcf Move extfmt parsing into standard library 2011-04-11 21:51:23 -04:00
Brian Anderson
5a36786634 Move the extfmt data model into the standard library. 2011-04-11 21:51:23 -04:00
Marijn Haverbeke
094d31f5e4 Make lexer buffer the whole file
This way, it won't have to go through a bunch of calls for each
byte fetched.
2011-04-09 01:05:18 +02:00
Tim Chevalier
9c001af07c Implemented computing prestates and poststates for a few expression forms.
The typestate checker (if it's uncommented) now correctly rejects a
trivial example program that has an uninitialized variable.
2011-04-08 17:46:46 +00:00
Patrick Walton
afa6d85d61 stdlib: Add a simple union-find data structure 2011-04-07 18:02:01 -07:00
Marijn Haverbeke
53cc673db1 Re-add a read_byte() method to buf_reader objs
This was removed because of the repetition, but doing single-byte
reads in terms of read_bytes (which allocates a vec) is needlessly
slow. This change speeds up parsing by 22%.

(Eventually, we won't be able to escape handling the buffering in the
stdlib itself.)
2011-04-08 02:23:14 +02:00
Marijn Haverbeke
ac3026412b Revise EBML reader API
New one is less stateful, easier to work with.
2011-04-07 14:19:16 -07:00
Tim Chevalier
2e90bd94de Continued sketching out code for checking states against preconditions.
It's still sketchy. I added a typestate annotation field to statements
tagged stmt_decl or stmt_expr, because a stmt_decl statement has a typestate
that's different from that of its child node. This necessitated trivial
changes to a bunch of other files all over to the compiler. I also added a
few small standard library functions, some of which I didn't actually end
up using but which I thought might be useful anyway.
2011-04-06 17:58:18 -07:00
Tim Chevalier
3130348ee1 Started adding support for typestate checking.
I added a new field to the ast "ann" type for typestate information.
Currently, the field contains a record of a precondition bit vector and
postcondition vector, but I tried to structure things so as to make
it easy to change the representation of the typestate annotation type.
I also had to add annotations to some syntactic forms that didn't have
them before (fail, ret, be...), with all the boilerplate changes
that that would imply.

The main call to the typestate_check entry point is commented out and
the actual pre-postcondition algorithm only has a few cases
implemented, though the overall AST traversal is there. The rest of
the typestate algorithm isn't implemented yet.
2011-04-01 11:27:32 -07:00
Patrick Walton
3c1de96cda rustc: Use the crate index to look up defs 2011-03-31 14:37:44 -07:00
Patrick Walton
dec92d392e stdlib: Add a write_be_uint() function to writers 2011-03-31 11:54:52 -07:00
Graydon Hoare
e99feabf47 Add a result_str method to std.sha1.sha1. 2011-03-26 17:36:08 -07:00
Patrick Walton
24a75eeccc rustc: Parse definition IDs from crates; add a function to parse unsigned ints to the standard library 2011-03-25 18:35:30 -07:00
Patrick Walton
94c19a18ae rustc: Look up names in "use"d crates 2011-03-25 17:54:48 -07:00
Patrick Walton
864e2ab24e stdlib: Implement a memory buffer reader, untested at the moment 2011-03-25 15:01:21 -07:00
Patrick Walton
739c4aedf1 stdlib: Separate basic I/O reading functionality into a separate buf_reader object, like writing 2011-03-25 14:06:18 -07:00
Marijn Haverbeke
a045514477 Start making the standard-lib utf-8 aware
Finally implements _str.is_utf8, adds from_chars, from_char, to_chars,
char_at, char_len, (push|pop|shift|unshift)_char. Also, proper
character I/O for streams.
2011-03-25 08:22:52 -07:00
Patrick Walton
af3d0d1848 rustc: Open "use"d crates; add a _vec.vec_from_buf() method along the way; XFAIL use-import-export.rs in rustc 2011-03-24 17:22:07 -07:00
Patrick Walton
c1bc0101ca stdlib: Provide a function to extract the underlying buf_writer from a writer 2011-03-22 17:53:43 -07:00
Patrick Walton
d56971d5b4 stdlib: Add EBML writing functionality 2011-03-22 17:29:23 -07:00
Patrick Walton
e890383db1 stdlib: Add a convenience method for opening paths as a FILE 2011-03-22 17:29:23 -07:00
Patrick Walton
b33f0df152 stdlib: Make writers seekable; switch file writers to the C FILE interface to make this work 2011-03-22 16:40:22 -07:00
Patrick Walton
bcf04e253f Revert "Remove usages of case(_) { fail; } since the compiler does this automatically". When we have exhaustiveness checking, "case(_) { fail; }" will be useful to silence warnings.
This reverts commit 92a716d862.
2011-03-22 14:02:52 -07:00
Patrick Walton
6623597c18 lib: Add an EBML reader module 2011-03-22 14:00:27 -07:00
Brian Anderson
92a716d862 Remove usages of case(_) { fail; } since the compiler does this automatically 2011-03-22 08:11:34 -07:00
Patrick Walton
e56a1720e4 Add a "last" function to return the last element of a vector to the standard library 2011-03-21 17:21:35 -07:00
Patrick Walton
71de17d38e Add a binding to ftell() 2011-03-21 16:41:18 -07:00
Graydon Hoare
0c7545c1ce Switch win32 path_sep to '/', add comment explaining a bit. 2011-03-20 19:43:43 -07:00
Graydon Hoare
460d89156f Add slightly nicer failure message to io.rs when it can't open a file. 2011-03-20 19:43:41 -07:00
Patrick Walton
9ad9d3783d rustc: Fix list.foldl() to pass its second argument by alias 2011-03-18 15:19:32 -07:00
Patrick Walton
47d650e25b rustc: Box the tuples returned by hashmap.items() for now since we don't have alias iterators yet 2011-03-18 15:18:45 -07:00
Patrick Walton
a9ba76d52a Fix bug in string comparison. std.rc typechecks now. 2011-03-18 14:15:27 -07:00
Patrick Walton
0cf16e77ca Add "mutable?" to _vec in the standard library; fix callers 2011-03-18 14:01:03 -07:00
Patrick Walton
368eb4bab6 Add some mutable variants of vector functions to the standard library 2011-03-18 13:53:49 -07:00