Commit graph

391 commits

Author SHA1 Message Date
Graydon Hoare
4539f8a03c Alias-ify fold and its users, remove another 85kb. 2011-05-09 17:50:06 -07:00
Graydon Hoare
b00f3074d4 Remove boxes from token.t. 2011-05-09 14:17:45 -07:00
Patrick Walton
662e949540 rustc: Alias fix part 1 -- Separate out AST modes from typechecker modes, and introduce an "either value or alias" mode 2011-05-09 12:27:03 -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
Patrick Walton
2d9ccf3ae5 rustc: Add Rust intrinsic support to the crate metadata reader and writer 2011-05-05 14:35:18 -07:00
Tim Chevalier
e3a68e235c Bring back "pred" syntax for writing predicates for check
This commit reinstates the requirement that the predicate in a
"check" must be a manifest call to a special kind of function
declared with the new "pred" keyword instead of "fn". Preds must
have a boolean return type and can only call other preds; they
can't have any effects (as enforced by the typechecker).
The arguments to a predicate in a check expression must be
slot variables or literals.
2011-05-05 11:26:07 -07:00
Tim Chevalier
3060eadcba Check well-formedness of constraints
Check that the operand in a constraint is an explicit name,
and that the operands are all local variables or literals. Still need
to check that the name refers to a pure function.
2011-05-05 11:26:07 -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
Graydon Hoare
d55fa2a9a3 Add #env syntax extension for plucking strings out of the compilation environment. 2011-05-04 19:05:32 -07:00
Graydon Hoare
cdb6822405 Add a structure for passing option flags around the compiler, put it in session, and use it. 2011-05-04 16:59:21 -07:00
Patrick Walton
ac8eb20224 rustc: Stub support for Rust intrinsics 2011-05-03 18:03:59 -07:00
Patrick Walton
2bc17adc29 Revert "Rename the "llvm" API to "llvm-intrinsic"" due to tinderbox bustage
This reverts commit 6871c245a6.
2011-05-03 17:50:37 -07:00
Graydon Hoare
b453c3c728 Start sketching --depend support in rustc. 2011-05-03 15:56:00 -07:00
Patrick Walton
6871c245a6 Rename the "llvm" API to "llvm-intrinsic" 2011-05-03 15:55:01 -07:00
Brian Anderson
ed40c85af5 Extract ast.is_exported from the resolve module 2011-05-02 22:07:36 -04: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
Graydon Hoare
a2f68b2d58 Intern metadata while writing, shrink stage1 from 12mb to 5.7mb. 2011-04-29 15:26:28 +00:00
Brian Anderson
2e12fbfc06 Support octal #fmt conversions 2011-04-26 20:20:17 -04:00
Patrick Walton
e102413aad rustc: Pass a "type context" around instead of directly passing the type store; prep for removing type annotations 2011-04-25 12:15:55 -07:00
Patrick Walton
e0eccaddb2 rustc: Thread the type store through everything that needs to access type structures 2011-04-22 17:00:46 -07:00
Patrick Walton
c7473c8260 rustc: Switch @ty.t to ty.t so that we can change it to a uint 2011-04-22 12:27:52 -07:00
Patrick Walton
c1335510d5 rustc: Eliminate the direct use of ty.t.struct 2011-04-22 12:09:09 -07:00
Marijn Haverbeke
2361b65526 Switch to binary search in codemap.lookup_pos
Patrick observed excessive slowness when looking up positions
in rustc. This might help.
2011-04-22 12:11:00 +02:00
Brian Anderson
540344acb9 Fix the signature of expr_ext
The extension body is just a string, not an expression.
2011-04-21 20:42:26 -04:00
Patrick Walton
5dbf554bb3 rustc: Pass a type store around, which does nothing yet 2011-04-21 14:30:27 -07:00
Patrick Walton
3dbfc9310a rustc: Make the parser never assign any types, not even ty_nil 2011-04-21 13:00:06 -07:00
Patrick Walton
cac7524c1a rustc: Remove all manual type construction outside ty.rs 2011-04-20 11:59:10 -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
Marijn Haverbeke
6d3a423094 add log_err to rustc 2011-04-19 16:57:13 +02:00
Brian Anderson
d4f1a48111 Support 0 flag in #fmt 2011-04-18 21:36:04 -04:00
Marijn Haverbeke
0bf75a203e collect crate meta info and ext crate names 2011-04-18 15:28:47 +02: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
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
Graydon Hoare
232c450957 Work on destructors, not entirely functional yet (no tydesc integration). 2011-04-14 16:50:59 -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
Graydon Hoare
8e0ecb4d1a Lex numeric escapes, needed for lib-str.rs (which now passes). 2011-04-13 11:25:11 -07:00
Tim Chevalier
63e87c102d typestate_check can now handle expr_block, expr_if, and expr_binary
(caveat for the latter: it assumes that binary operations are strict;
a TODO is to detect or and and and correctly reflect that they're lazy
in the second argument). I had to add an ann field to ast.block,
resulting in the usual boilerplate changes.

Test cases that currently work (if you uncomment the typestate pass
in the driver) (all these are under test/compile-fail):

fru-typestate
ret-uninit
use-uninit
use-uninit-2
use-uninit-3
2011-04-12 19:03:52 -07:00
Patrick Walton
de0175abed rustc: Switch to indices for type parameters 2011-04-12 15:10:40 -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
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
c0d0b717ee Fix codemap.lookup_pos
Previously, it would place every single location in the first
file of the crate that was parsed.
2011-04-09 01:57:48 +02:00
Marijn Haverbeke
1af3174fe3 Move to single-uint file-position representation.
This makes passing them around cheaper. There is now a table (see
front/codemap.rs) that is needed to transform such an uint into an
actual filename/line/col location.

Also cleans up the span building in the parser a bit.
2011-04-09 01:05:18 +02: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
Lindsey Kuper
1092bbfff0 Support for self-calls that take arguments.
Nicer parsing of self-calls (expr_self_method nodes inside expr_call
nodes, rather than a separate expr_call_self) makes typechecking
tractable.  We can now write self-calls that take arguments and return
values (see: test/run-pass/obj-self-*.rs).
2011-04-07 14:26:34 -07:00
Marijn Haverbeke
39774e88b4 Add a very basic crate-dump utility
'rustc -ls [cratelib]' will now dump out a list of symbols defined by
the crate, as well as a short description of what they are.
2011-04-07 14:19:19 -07: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
Lindsey Kuper
4fc8de1969 Last pieces of self-call support.
The last few pieces of the hack that lets us use trans.trans_call() to
translate self-calls, plus a fix for the parser buy that was
preventing self-call expressions from getting past parsing.
test/run-pass/obj-self.rs works now (as in it actually prints "hi!"
twice!).
2011-04-05 16:26:31 -07:00
Lindsey Kuper
b8bb2e118e Further on the path toward self-awareness.
Mostly:

  * Merciless refactoring of trans.rs so that trans_call can work for
    self-calls as well as other kinds of calls

Also:

  * Various changes to go with having idents, rather than exprs, in
    expr_call_self AST nodes
  * Added missing case for SELF token to token.to_str()
2011-04-05 14:54:48 -07:00
Graydon Hoare
70e5457d7c Make box prefix operator and box type carry mutability flag. 2011-04-04 15:44:15 -07:00
Graydon Hoare
0397c05f42 Support for passing native types through metadata/creader. 2011-04-01 17:04:51 -07:00
Patrick Walton
6dc452335a rustc: Get tag variants from the crate metadata 2011-04-01 13:02:44 -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
c66edca83d rustc: Add a type annotation to tag items 2011-03-31 19:12:40 -07:00
Patrick Walton
bdea343879 rustc: Use the path index. Speeds up compilation a lot. 2011-03-31 18:28:59 -07:00
Patrick Walton
fffc5d3b3d rustc: Write out a path index as well 2011-03-31 18:28:59 -07:00
Graydon Hoare
1b65a61cad Couple minor bug fixes in creader, lib-bitv, int, rand, sort, sha1, uint and vec all work. 2011-03-31 15:57:36 -07:00
Patrick Walton
3c1de96cda rustc: Use the crate index to look up defs 2011-03-31 14:37:44 -07:00
Patrick Walton
3945ace520 rustc: Write out an index of definition info in crate metadata 2011-03-31 11:56:02 -07:00
Brian Anderson
50e354611f Remove redundant parser logic.
These cases are all dealt with in parse_expr_inner.
2011-03-31 14:52:29 +00:00
Marijn Haverbeke
6a75740e96 handle unterminated block comments and line comment at eof 2011-03-31 14:41:40 +00:00
Marijn Haverbeke
39f0656b4f Improve line comment positioning
This involved making ast.variant spanned.
2011-03-31 14:41:40 +00:00
Marijn Haverbeke
8a7ea941bb Support break and cont in pretty-printer 2011-03-31 14:41:40 +00:00
Marijn Haverbeke
f8393cc572 Add effect field to ast.ty_fn.
Still not used, except by the pretty-printer.
2011-03-31 14:41:40 +00:00
Marijn Haverbeke
e7e6f396d8 Preserve comments when pretty-printing.
The patch also includes a number of smaller fixes to the
pretty-printer that were encountered on the way.
2011-03-31 14:41:39 +00:00
Patrick Walton
ab8d200fb0 rustc: Read 'y' tags from external crates 2011-03-30 18:28:33 -07:00
Patrick Walton
cc59cea8b0 rustc: Thread an item-to-type mapping throughout the typechecking and translation phases 2011-03-30 17:28:06 -07:00
Patrick Walton
626bdaaa1f rustc: Parse parameter IDs in external crate metadata. Un-XFAIL lib-bitv.rs. 2011-03-29 17:25:55 -07:00
Patrick Walton
c67eb1a575 rustc: Partially resolve external module imports 2011-03-29 17:01:27 -07:00
Patrick Walton
6a5feffd6c rustc: Tolerate def id tags inside module tags. Fixes metadata reading. 2011-03-29 16:43:27 -07:00
Lindsey Kuper
55fbed3d8d Beginnings of support for magical self prefix; nothing profound happening yet. 2011-03-29 15:59:15 -07:00
Graydon Hoare
f6490a6f03 Ignore 'mutable foo' in plain field contexts. 2011-03-29 15:40:21 -07:00
Patrick Walton
94c061729b rustc: Resolve external modules and native modules to definition IDs as well 2011-03-29 14:46:42 -07:00
Graydon Hoare
734abe593d Teach trans to emit undefined references to 'use'd symbols. Can compile and run a simple 'use std;' example now. 2011-03-29 13:23:51 -07:00
Brian Anderson
2b27d12ce1 Add expr_spawn, spawn parsing, folding, typechecking, ty_task 2011-03-28 21:13:53 -07:00
Patrick Walton
2809e30d1d rustc: Parse types in external metadata 2011-03-28 16:49:26 -07:00
Patrick Walton
ace2c92a96 rustc: Populate the item types table with types of items from external crates; remove the redundant typeck.ty_and_params type on the way 2011-03-28 14:42:01 -07:00
Patrick Walton
62f4709953 rustc: Resolve def ids in external crates 2011-03-28 13:29:59 -07:00
Patrick Walton
81695a19f8 rustc: Add support for calling LLVM intrinsics as native functions 2011-03-28 08:24:58 -07:00
Marijn Haverbeke
6ecdc04788 Add support for break and cont to rustc
Testing proper cleanup is hampered by
https://github.com/graydon/rust/issues/293
2011-03-27 14:11:23 +02:00
Graydon Hoare
ac6e1131e9 Teach creader and metadata writer how to do ty.ty_type. 2011-03-26 17:35:51 -07:00
Patrick Walton
bea41aa7d8 rustc: Add a function to look up external item info in the item info table 2011-03-25 19:02:19 -07:00
Graydon Hoare
027368b885 Janitorial: move llvmext back to llvm module, as they're the same thing now. 2011-03-25 18:45:00 -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