Commit graph

1572 commits

Author SHA1 Message Date
Paul Stansifer
20bd927c3f Flatten functions and objects in trans::simplify_type. 2011-06-02 17:40:12 -07:00
Graydon Hoare
cb61d7b38e Pretty-print literals exactly as we saw them in the source. 2011-06-02 17:18:49 -07:00
Lindsey Kuper
3a6b5576ac Refactor make_fp_cmp_glue and make_integral_cmp_glue into one. 2011-06-02 16:35:25 -07:00
Paul Stansifer
1377e9b341 Implement pcwalton's code review suggestions. 2011-06-02 15:12:17 -07:00
Paul Stansifer
5cd10d2fef Error message, instead of segfault, when recursive types are used. 2011-06-02 14:03:17 -07:00
Patrick Walton
12f86e6f2f rustc: Print node IDs for more types of nodes 2011-06-02 11:29:17 -07:00
Patrick Walton
7c6a0f189e rustc: Tiny style fix in pprust::rust_printer 2011-06-02 11:29:17 -07:00
Patrick Walton
78374d11ce rustc: Add a new mode to the pretty printer that prints out node IDs, for debugging 2011-06-01 18:53:52 -07:00
Patrick Walton
eae3036179 rustc: Remove else-after-return in main 2011-06-01 18:38:00 -07:00
Patrick Walton
d43f60e5d4 rustc: Fold --pretty and --typed-pretty into a single option with an optional argument 2011-06-01 18:32:05 -07:00
Tim Chevalier
24c9d7e5f8 Improve type error message for non-constructor in pattern 2011-06-01 18:15:12 -07:00
Tim Chevalier
1402cd101b Redo typestate-related data structures to support predicate constraints. No actual support yet, just infrastructure. 2011-06-01 18:14:48 -07:00
Tim Chevalier
af4554aadf Add a few more to_str functions 2011-06-01 17:47:59 -07:00
Tim Chevalier
ac4ef1741e Allow constraint args to be literals 2011-06-01 17:45:13 -07:00
Lindsey Kuper
528c6516f0 Use span_err instead of err. Fixes issue #444. 2011-06-01 17:22:23 -07:00
Patrick Walton
af9272f70e rustc: Remove rustboot workaround from walk::default_visitor() 2011-06-01 16:52:22 -07:00
Patrick Walton
8851ae0423 rustc: Allow walking over patterns 2011-06-01 16:47:24 -07:00
Graydon Hoare
1f915ef7ce Permit breaking before fn args block. 2011-06-01 16:39:31 -07:00
Lindsey Kuper
dba9caeba9 Comments. 2011-06-01 16:39:52 -07:00
Graydon Hoare
1b67fbdfd3 More tweaks to comment preservation rules. 2011-06-01 15:29:38 -07:00
Graydon Hoare
198f6a247e Print iters as iters not fns. 2011-06-01 13:18:16 -07:00
Graydon Hoare
023bbc0449 Add a space after @mutable. 2011-06-01 13:12:12 -07:00
Graydon Hoare
19f85cc9c4 Print ty_bot properly. 2011-06-01 13:08:08 -07:00
Rafael Ávila de Espíndola
a6ca9c2922 Don't create an empty section. 2011-06-01 15:59:28 -04:00
Rafael Ávila de Espíndola
30efdeeca1 Visibility is an ELF concept and protected visibility is not very well implemented,
avoid using it for now.

Instead, mark pairs that are not needed elsewhere as internal.
2011-06-01 15:45:31 -04:00
Graydon Hoare
2ef2bda276 Move brace/if/for/while/do/alt/spawn exprs into bottom_expr rule. 2011-06-01 12:42:28 -07:00
Graydon Hoare
4eef7b613c Bug fixes to pprust. 2011-06-01 12:26:42 -07:00
Graydon Hoare
e5dc138dfa Buffer pending whitespace in printer so as not to introduce trailing whitespace lines. 2011-06-01 12:01:42 -07:00
Graydon Hoare
681f0c7a2b Support printing globs. 2011-06-01 11:39:20 -07:00
Graydon Hoare
ae16639dfa Slightly more aggressive about inserting whitespace. Getting frustrated with comments. 2011-06-01 11:39:20 -07:00
Lindsey Kuper
649a7bf38a Comments and cleanup. 2011-06-01 11:34:52 -07:00
Paul Stansifer
9f5dddf08c Now imports are not re-exported unless 'export' is explicitly used. 2011-05-31 18:43:26 -07:00
Graydon Hoare
0235e742f6 Give up on use of huge_word for comments. Still not formatting quite right, but closer. 2011-05-31 17:39:15 -07:00
Michael Sullivan
f4df2e4974 Fix pretty printer for move. 2011-05-31 17:39:14 -07:00
Michael Sullivan
fd1029e6dd Support move as an initializer. 2011-05-31 17:39:14 -07:00
Michael Sullivan
c232964301 Implement move semantics. 2011-05-31 17:39:14 -07:00
Michael Sullivan
5e7bba3d23 Insert plumbing for move that behaves just like assign. 2011-05-31 17:39:14 -07:00
Eric Holk
84a56ed7cd Teach the compiler to understand yield and join, as well as using task as a type name. 2011-05-31 16:28:13 -07:00
Brian Anderson
9daa00bf83 rustc: Teach rustc to use block results as fn return values. Closes #372 2011-05-31 19:18:55 -04:00
Graydon Hoare
223c7dfb11 Fix comment-scanning logic in lexer. 2011-05-31 15:31:50 -07:00
Graydon Hoare
2de1a4bb1b Handle pretty-printing else-if properly. 2011-05-31 12:58:02 -07:00
Rafael Ávila de Espíndola
cc96eeafca Move rust_vec_append_glue to rt. 2011-05-31 14:32:08 -04:00
Graydon Hoare
b6971d94df Consolidate formatting functions a bit more. 2011-05-31 11:00:47 -07:00
Graydon Hoare
55e3cd41de Fix utility printers to flush eof in common.rs. 2011-05-31 11:00:47 -07:00
Graydon Hoare
1811513552 Fix long lines 2011-05-31 11:00:47 -07:00
Graydon Hoare
371c25683c Break methods in obj types. 2011-05-31 11:00:47 -07:00
Graydon Hoare
1676c67446 Tighten up comment rules a little more. 2011-05-31 11:00:47 -07:00
Graydon Hoare
cf57553679 Improve handling of trailing comments. 2011-05-31 11:00:47 -07:00
Graydon Hoare
b48cab962a Add span to field to catch per-field comments in rec exprs. 2011-05-31 11:00:47 -07:00
Graydon Hoare
d12ea39896 Improve comment handling in pp. 2011-05-31 11:00:47 -07:00
Graydon Hoare
30f8348473 Differentiate consistency of commasep boxes 2011-05-31 11:00:47 -07:00
Graydon Hoare
21313d623a new pretty printer 2011-05-31 11:00:47 -07:00
Rafael Ávila de Espíndola
e66f9e46f6 Start finishing up the rust_start signature transition. 2011-05-31 11:17:17 -04:00
Marijn Haverbeke
7d68cbdff0 Have blocks return their result by writing to a reserved space
This makes it possible to pass the location of that space through to
nested blocks, resulting in less copying, taking, and dropping.

This makes the compiler slightly faster and 19k smaller.

A FIXME is to use 'move' semantics when returning the values from the
block -- don't bump the refcount and drop it again for the returning
block, but simply assign ownership to the receiver. To do this, we'll
need a way to (safely) scrub things from a block's cleanup list.
2011-05-31 14:29:16 +02:00
Brian Anderson
81fc2d8728 rustc: Remove unneeded type params from alt patterns 2011-05-31 01:23:53 -04:00
Brian Anderson
c7e3f88c93 rustc: Pushdown type params for tag patterns. Closes #363 2011-05-31 00:00:04 -04:00
Tim Chevalier
18883fea3a In pre/postcondition computation, failing calls should set the postcondition
A non-returning call should have a postcondition in which all predicates
are true -- not just a poststate. Otherwise, alt expressions where
one or more branches terminate in a non-returning call and others
initialize a variable get rejected.

Includes a test case.
2011-05-27 20:43:51 -07:00
Tim Chevalier
95e1aa18c1 change comment 2011-05-27 20:43:51 -07:00
Tim Chevalier
9a24e4f780 Fix two typestate bugs
* Non-returning calls should set all predicates to be true, not
  just the "this function returns" predicate

* Fixed a bug in the expr_alt case in tstate.states that wasn't updating
  the changed flag properly, then fixed *another* bug that was updating
  it too enthusiastically, but was masked by the first bug.
2011-05-27 20:43:51 -07:00
Lindsey Kuper
dc9d5e1689 Lots of comments, and some more descriptive names. 2011-05-27 18:20:43 -07:00
Tim Chevalier
b6e0c5829f Check the declaration type in a for loop against the sequence type
Changed the typechecker to correctly typecheck the declared variable
type in a for or for-each loop against the vector element type (for
a for loop) or the iterator type (for a for-each loop). Added a
test case.
2011-05-27 17:42:09 -07:00
Tim Chevalier
0c5a55f275 add a function that returns the type of a local decl 2011-05-27 17:34:50 -07:00
Eric Holk
52795049e7 Generating names for wrappers, removed extra logging 2011-05-27 15:37:19 -07:00
Eric Holk
8cfc388d40 Switched calling conventions so that spawn with multiple arguments works. 2011-05-27 15:20:58 -07:00
Eric Holk
d49998f0ed Switching over to wrappers for spawning functions of multiple arguments. Doesn't quite work yet. 2011-05-27 15:20:58 -07:00
Eric Holk
da0e0b6f5e Removing excessively verbous logging. 2011-05-27 15:20:58 -07:00
Eric Holk
a88af906c5 Programs using spawn terminate 2011-05-27 15:20:58 -07:00
Eric Holk
dad426419c Working on 2 argument spawn. The arguments seem to be copied correctly once, but then they get lost. 2011-05-27 15:20:58 -07:00
Eric Holk
bb4c7a9c68 Arguments seem to be correctly passed to child processes now. 2011-05-27 15:20:58 -07:00
Eric Holk
21efd07bc1 New tasks run, but their arguments get lost and something ends up in an infinite loop when the task exits. 2011-05-27 15:20:58 -07:00
Tim Chevalier
0cbcf92749 Use annotations on blocks
Previously, block_ty returned the type of the terminating
expression of the block (or nil if said expression was absent).
I changed check_expr to write the type of that expression into
the annotation for the block itself, so now block_ty can use the
block's annotation.
2011-05-27 12:21:37 -07:00
Michael Sullivan
a7a42c24be Change the syntax for RECV from "var <- port" to "port |> var". 2011-05-27 12:01:20 -07:00
Michael Sullivan
2119e3b5b9 Fix missing bump in RECV lexer case. 2011-05-27 12:01:20 -07:00
Michael Sullivan
9c79200a7f Pretty print the new RECV token... 2011-05-27 12:01:20 -07:00
Michael Sullivan
ea16e582eb Remove parser support for recv as an initializer in preparation for changing the recv syntax. 2011-05-27 12:01:20 -07:00
Michael Sullivan
55b40e6894 Lex '|>' as the RECV token. 2011-05-27 12:01:20 -07:00
Tim Chevalier
1a96e79fe0 Make _|_ unify with anything
The typechecker had a number of special cases for unifying types
with _|_ (as with checking if and alt). But, a value of type _|_
should be usable in any context, as such a value always diverges,
and will never be used by its immediate context. Changed unify
accordingly, removed special cases.
2011-05-26 20:50:25 -07:00
Paul Stansifer
af6b4821c1 Handle circularity in glob imports in a more elegant fashion. 2011-05-27 02:42:33 +00:00
Paul Stansifer
7fe3d821ac Add a map from def_id s to items in resolve::env.
Use it to provide better error messages in the event of
glob-importing the same name multiple times.
2011-05-27 02:42:33 +00:00
Paul Stansifer
54ca8565c9 Fix bugs: make sure glob imports show up in the right module,
and make sure that circular glob imports don't diverge.
2011-05-27 02:42:33 +00:00
Paul Stansifer
40fe44d23e "import module::*;" now works. 2011-05-27 02:42:33 +00:00
Paul Stansifer
e2bb98001e Part one of adding globbing to resolve.rs: build up glob links. (Part two will follow those links if non-glob resolution fails.) 2011-05-27 02:42:32 +00:00
Paul Stansifer
f11f846ead Parsing and folding changes for globbed imports. 2011-05-27 02:42:32 +00:00
Tim Chevalier
610c81af19 Fix typo 2011-05-26 19:13:56 -07:00
Graydon Hoare
79c9e13073 More delicious dead code removal from runtime, upcalls. 2011-05-26 18:21:02 -07:00
Tim Chevalier
4f792f2dbb Track spans for each local variable in typestate
This lets us print better messages in situations with name
shadowing.
2011-05-26 18:14:32 -07:00
Tim Chevalier
250643c549 Remove unused imports 2011-05-26 18:01:48 -07:00
Tim Chevalier
97e0575e2e Add a span_str function in session 2011-05-26 18:00:54 -07:00
Tim Chevalier
79693fab1f Fix typo in error message 2011-05-26 18:00:54 -07:00
Graydon Hoare
9f95538462 Remove redisue of unused fields from 'ann'. 2011-05-26 17:26:59 -07:00
Graydon Hoare
2561b01211 Remove residual uses of fold, and fold itself. 2011-05-26 17:16:54 -07:00
Graydon Hoare
8e945dcd81 Remove native glues. All calls to C are direct now. 2011-05-26 16:45:01 -07:00
Graydon Hoare
9491dc3e61 Add early returns to rustc main on non-compiling paths. 2011-05-26 15:22:08 +00:00
Graydon Hoare
dc1b34288c Pretty print view items with :: rather than :. 2011-05-25 22:09:36 -07:00
Brian Anderson
29a801565a rustc: Fail better when the first argument to #fmt is not a string literal 2011-05-25 23:50:19 -04:00
Brian Anderson
c4e9d8fb91 rustc: Fail when #fmt is given too many arguments 2011-05-25 23:43:04 -04:00
Michael Sullivan
1b29892b5b Produce a useful error message in trans when attempting to log an unsupported type.
(Previously, an llvm assert was tripped.)
2011-05-25 18:54:33 -04:00
Eric Holk
d72d50473f Fixing typechecking for spawn. 2011-05-25 18:01:45 -04:00
Rafael Ávila de Espíndola
94129c4216 dead argument removal part one. 2011-05-25 15:33:57 -04:00
Brian Anderson
9a88ba2b81 rustc: Downcase typeck::demand and typeck::pushdown 2011-05-24 20:26:46 -04:00
Brian Anderson
6473b73174 rustc: Use demand functions instead of open-coded typecheck for spawn
Un-xfail spawn-non-nil-fn
2011-05-24 20:23:21 -04:00
Rafael Ávila de Espíndola
de2e84e5b0 Only one gc glue. 2011-05-24 18:52:31 -04:00
Rafael Ávila de Espíndola
ac836dd79c There is only one yield glue. 2011-05-24 18:29:08 -04:00
Rafael Ávila de Espíndola
b1292580b9 Remove dead code for unwind_glue. 2011-05-24 17:28:37 -04:00
Rafael Ávila de Espíndola
0fc91b6ecc There is only one activate function now. 2011-05-24 17:00:45 -04:00
Eric Holk
2e8afc7b47 Merge pull request #404 from lkuper/cleanup
Just removing some unnecessary imports.
2011-05-24 13:51:00 -07:00
Marijn Haverbeke
fbc0e840e3 Stop showing a 'cyclic import' message for unresolved imports
This only happened for single-length import paths, because the import
was being looked up in its own scope.
2011-05-24 20:58:38 +02:00
Lindsey Kuper
f1d3b88f0a Just removing some unnecessary imports. 2011-05-24 11:22:40 -07:00
Tim Chevalier
bad05e20a3 Improve nonexistent-module error message
The error message for (for example) "import vec;" without "use std;"
was "cyclic import", which was misleading because there were no
cycles. I changed it to "cyclic import or nonexistent module",
which doesn't break existing tests.
2011-05-24 10:47:58 -07:00
Tim Chevalier
c9a8bdee2f Improve error message for ambiguous polymorphic types
If a type still contains free type variables after typechecking (for
example, as with "auto foo = []", the result was an assertion failure
in typeck. Made it a human-readable error message instead.
2011-05-23 19:46:27 -07:00
Tim Chevalier
b620be9cd2 Typecheck @[] correctly
Previously, if you wrote
let @vec[int] foo = @[];

that would be a type error. That didn't seem right, so I changed
pushdown to unify the inner type in an unop application with the
argument type of the operator type.
2011-05-23 17:17:49 -07:00
Brian Anderson
2505a2312e rustc: Run the llvm verifier pass before optimization. Closes #376
The optimization passes were hiding some codegen errors so now we run the
verifier both before and after optimization.
2011-05-23 19:52:57 -04:00
Marijn Haverbeke
86d51ec24b Get test-pass/utf8.rs to run
This involved a small fix to the unicode-escape character lexing and
to the pretty-printer.
2011-05-23 23:25:55 +02:00
Tim Chevalier
2a73c4ffab Add line breaks to typestate error messages 2011-05-23 13:32:29 -07:00
Brian Anderson
db7611c4c9 rustc: More cleanup of rustc.rs 2011-05-22 16:58:33 -04:00
Brian Anderson
1081d0aee9 rustc: Some refactoring of rustc.rs 2011-05-22 16:41:32 -04:00
Brian Anderson
65ec38c096 rustc: Cleanup formatting in rustc.rs 2011-05-22 16:07:30 -04:00
Brian Anderson
d82e9c1874 rustc: Add a FIXME to expr_alt type checking 2011-05-21 18:35:21 -04:00
Brian Anderson
4504e23a82 rustc: Remove unnecessary pushdown from check_expr in the expr_if case 2011-05-21 18:18:48 -04:00
Brian Anderson
e24d7ae967 rustc: If all if branches are _|_, then the entire if is _|_ 2011-05-21 18:18:48 -04:00
Brian Anderson
085fb1a2db rustc: Remove outdated comment 2011-05-21 14:43:04 -04:00
Brian Anderson
b62bf8cede rustc: Allow if expressions to fail 2011-05-21 14:22:01 -04:00
Brian Anderson
6824f119fc rustc: Allow alt expressions to fail 2011-05-21 13:22:01 -04:00
Brian Anderson
418b4c4567 rustc: Assign ty_bot to nodes in write::bot_ty. Remove FIXME 2011-05-21 13:02:58 -04:00
Brian Anderson
779dd809d2 rustc: Blocks shouldn't try to return results for ty_bot 2011-05-21 12:56:31 -04:00
Tim Chevalier
755ca8eb73 Correctly check that ! functions always diverge
Also make _|_ unify with any type.
2011-05-20 19:54:14 -07:00
Brian Anderson
2fc0bedc83 rustc: Don't write metadata for unexported items 2011-05-20 21:32:57 -04:00
Tim Chevalier
467b938ea8 Merge remote-tracking branch 'graydon/master' into typestate_4 2011-05-20 18:23:03 -07:00
Tim Chevalier
964898eaf1 Error instead of warning for missing returns. Huzzah! 2011-05-20 18:20:54 -07:00
Tim Chevalier
fed0486c33 Annotate erroring functions in session and parser 2011-05-20 18:20:54 -07:00
Lindsey Kuper
c3410bf927 More work on anonymous objects. 2011-05-20 17:59:56 -07:00
Tim Chevalier
c8d488b337 Change node_ann hash table to a vector in typestate 2011-05-20 16:57:37 -07:00
Tim Chevalier
9128a1bab8 rm unnecessary logging 2011-05-20 16:57:37 -07:00
Tim Chevalier
7e82f23bc0 rm unused import 2011-05-20 16:57:37 -07:00
Tim Chevalier
551fb13689 Add a "fail" after a while(true) loop in two places
(in preparation for changing the "function may not return" warning
to an error)
2011-05-20 16:57:37 -07:00
Tim Chevalier
a08a376d6e Make controlflow part of a function type
Change ty_fn to have a controlflow field. A 'controlflow' is
essentially a bit of data that says whether or not this function
never returns to the caller (if it never returns, that means it calls
"fail" or another "never-returns" function on every control path).

Also add syntax for annotating functions that never return:

fn foo() -> ! {
   fail;
}

for example. Functions marked with ! implicitly have a result type of
ty_bot, which is a new type that this commit also adds.
2011-05-20 16:57:37 -07:00
Eric Holk
3dd2877975 Using the right mode... 2011-05-20 16:51:09 -07:00
Eric Holk
0de27ce8bd Translated start_task, but it fails on spp == align_down(spp) 2011-05-20 16:51:09 -07:00
Eric Holk
d01948cd07 Called the new_task upcall. There are refcount issues though. 2011-05-20 16:51:08 -07:00
Eric Holk
41b3979990 Nicer printer of LLVM array types. 2011-05-20 16:51:08 -07:00
Eric Holk
219351e4b9 A little closure towards translating spawn. We're about ready to do the upcall, except that rustc segfaults. 2011-05-20 16:51:08 -07:00
Eric Holk
d6338a8c15 Added some comments to trans_spawn that sort of explains what needs to happen 2011-05-20 16:51:08 -07:00
Eric Holk
2b124a8140 Started working on translating spawn. It correctly generates the task name in the case that it is not provided. 2011-05-20 16:51:08 -07:00
Graydon Hoare
36c083b14c Options fix from erickt. 2011-05-20 15:20:48 -07:00
Graydon Hoare
fa75703700 Twiddle glue inlining heuristics. ~10% win on build time. 2011-05-20 14:57:52 -07:00
Graydon Hoare
67b8501eb8 Elide a bunch of do-nothing take glue. 2011-05-20 14:50:57 -07:00
Graydon Hoare
381ba1d0ba Remove redundant secondary declaration of glue. 2011-05-20 14:48:33 -07:00
Patrick Walton
7e43a31f08 rustc: Move the interner to a new module intended to be used for general data structures 2011-05-20 13:57:53 -07:00
Brian Anderson
b6d2fe4d74 rustc: Translate else if blocks the same as other blocks. Closes #388 2011-05-19 23:32:09 -04:00
Brian Anderson
879a952a37 rustc: Find the correct outer scope in trans_block 2011-05-19 23:32:08 -04:00