Commit graph

629 commits

Author SHA1 Message Date
Brian Anderson
b97318bb80 Simplify the code for generating tests. Issue #428 2011-07-12 16:54:47 -07:00
Brian Anderson
ed83f28076 Log the synthesized __test module. Issue #428 2011-07-12 16:54:46 -07:00
Brian Anderson
73e6a4f9e5 Elide existing main function when building a test runner. Issue #428
This prevents any defined main function from colliding with the one
synthesized for the test runner. This is not the best solution since it
doesn't compile a function the user defined, but I don't think it's likely to
be a problem in the near term.
2011-07-12 16:54:46 -07:00
Patrick Walton
a190a2c68e rustc: Remove exterior vectors from front::attr 2011-07-12 15:39:48 -07:00
Brian Anderson
94e1b362f0 Pass command-line args to the test runner. Issue #428
This will let the test runner filter the tests it runs.
2011-07-11 19:01:53 -07:00
Patrick Walton
05390b4b38 rustc: Implement explicit global scope resolution via leading "::"; add a test case 2011-07-11 16:02:16 -07:00
Brian Anderson
75047ea87e Generate code to load a crate's tests into the std test runner. Issue #428 2011-07-09 19:30:04 -07:00
Brian Anderson
f72dbec9b5 Collect functions that look like unit tests. Issue #428 2011-07-09 12:36:03 -07:00
Brian Anderson
5543404abe Track the path as we fold over the AST looking for unit tests. Issue #428 2011-07-09 12:35:30 -07:00
Patrick Walton
e1b107d74e rustc: Remove all exterior vectors from the AST 2011-07-07 18:39:05 -07:00
Patrick Walton
0e2fff5337 rustc: Change lots of AST nodes to use interior vectors 2011-07-07 12:53:17 -07:00
Brian Anderson
cf4c2ac0be Generate a main fn for test running. Issue #428 2011-07-06 18:26:22 -07:00
Patrick Walton
401b6362d7 rustc: Make meta items into interior vectors 2011-07-06 15:46:03 -07:00
Patrick Walton
0226f56115 rustc: Convert attribute in the AST to interior vectors 2011-07-06 15:15:00 -07:00
Brian Anderson
b06ccb45ab Begin adding unit testing infrastructure to the compiler
Add a --test flag and a pass for transforming the AST to generate a test
harness.

Issue #428
2011-07-06 14:39:36 -07:00
Patrick Walton
bbdba21b1f rustc: Revert the conversion to interior vectors due to heap corruption 2011-07-06 11:26:26 -07:00
Patrick Walton
ec890fff23 Temp commit on the way to making meta_item into an interior vector 2011-07-06 11:09:08 -07:00
Patrick Walton
c927d97fa0 rustc: Convert attribute in the AST to interior vectors 2011-07-06 11:09:08 -07:00
Brian Anderson
2cb129355b Change ast::meta_name_value to accept any literal, not just string
This isn't useful for much of anything yet, since metadata::encoder doesn't
know how to handle the non-string variants.

Issue #611
2011-07-05 17:25:18 -07:00
Brian Anderson
b79ea489e3 Support conditional compilation of native items. Closes #610 2011-07-05 13:30:00 -07:00
Brian Anderson
6f8bc404f8 Error if the link attribute has duplicate items. Issue #614 2011-07-05 11:46:02 -07:00
Marijn Haverbeke
6fd6fdea93 Move everything syntax-related to syntax/, break deps on rest of compiler
src/comp/syntax is currently just a sub-module of rustc, but it will,
in the near future, be its own crate. This includes:

 - The AST data structure
 - The parser
 - The pretty-printer
 - Visit, walk, and fold
 - The syntax extension system
 - Some utility stuff that should be in the stdlib*

*) Stdlib extensions currently require a snapshot before they can be
   used, and the win build is very broken right now. This is temporary
   and will be cleaned up when one of those problems goes away.

A lot of code was moved by this patch, mostly towards a more organized
layout. Some package paths did get longer, and I guess the new layout
will take some getting used to. Sorry about that!

Please try not to re-introduce any dependencies in syntax/ on any of
the other src/comp/ subdirs.
2011-07-05 15:57:21 +02:00
Marijn Haverbeke
b1423be1d6 Move the ids of pat AST nodes into their struct
Just like it was done with items and exprs. Simplifies some code.
2011-07-04 22:00:06 +02:00
Tim Chevalier
046c25dbc0 Handle fail as an argument; parse fail expressions unambiguously
An expression like:

foo(1, fail, 2)

was failing to parse, because the parser was interpreting the comma
as the start of an expression that was an argument to fail, rather
than recognizing that the fail here has no arguments

Fixed this by using can_begin_expr to determine whether the next
token after a fail token suggests that this is a nullary fail or a
unary fail.

In addition, when translating calls, check before translating each
argument that the block still isn't terminated. This has the effect
that if an argument list includes fail, the back-end won't keep trying
to generate code for successive arguments and trip the !*terminated
assertion.
2011-07-03 11:51:47 -07:00
Tim Chevalier
6369807ffe Add a predicate that determines whether a token can begin an expression 2011-07-03 11:51:46 -07:00
Josh Matthews
a4421cc4e8 Fix assertion failure when syntax extension name is missing. 2011-07-02 00:06:58 -07:00
Josh Matthews
d485e0d15a Allow any string expression to be used with fail. 2011-07-02 00:06:58 -07:00
Patrick Walton
d39c59ae41 rustc: Move path_to_str to front::ast 2011-07-01 17:22:18 -07:00
Brian Anderson
a34b61fb15 Add some FIXMEs for issue #607 2011-07-01 12:51:46 -07:00
Brian Anderson
021b203fc6 Add some logging to attr when reading crate link attributes
Only link attributes of the meta_list type are considered when matching crate
attributes. Instead of doing nothing we can at least log that link attributes
of other types were ignored.
2011-07-01 12:30:27 -07:00
Brian Anderson
172c5633c4 Export only what's in use from front::eval. Issue #604 2011-07-01 10:46:59 -07:00
Brian Anderson
bdc5abe82c Remove unused imports from front::eval 2011-07-01 10:45:30 -07:00
Brian Anderson
8614cc975c Remove remaining unused eval methods. Issue #604 2011-07-01 10:45:30 -07:00
Brian Anderson
91b87b31e5 Remove the concept of crate directive let statements. Issue #604 2011-07-01 10:45:30 -07:00
Brian Anderson
d8fe0d7cee Remove the concept of crate directive expressions. Issue #604 2011-07-01 10:45:30 -07:00
Brian Anderson
bca45720f7 Remove the environment concept from front::eval
This is the old method of conditional compilation. It is going away.

Issue #489
2011-07-01 10:45:30 -07:00
Brian Anderson
70a28dc238 Cleanup attribute code. Issue #487 2011-07-01 10:45:30 -07:00
Brian Anderson
26ce1e1035 Add some helper functions to front::attr 2011-07-01 10:45:29 -07:00
Marijn Haverbeke
57e6340253 Allow 'newtype' syntax for tags
Doing this:

    tag foo = mytype;

is now equivalent to doing this:

    tag foo { foo(mytype); }
2011-07-01 17:51:43 +02:00
Graydon Hoare
6d441d3238 Preserve hard \n\n pairs from source when pretty-printing, as explicit formatting control from users. 2011-06-30 17:25:20 -07:00
Brian Anderson
64d6081429 Use attributes for conditional compilation in std.rc 2011-06-30 14:13:49 -07:00
Brian Anderson
39fccf3bc7 Conditionally compile items declared as statements. Issue #489 2011-06-30 13:04:35 -07:00
Tim Chevalier
d8db9a0fe1 Kill unused variables 2011-06-30 12:37:30 -07:00
Brian Anderson
4165d3640a Add a pass to fold out items that do not belong in the current configuration
The parser needs to parse unconfigured items into the AST so that they can
make the round trip back through the pretty printer, but subsequent passes
shouldn't care about items not being translated. Running a fold pass after
parsing is the lowest-impact way to make this work. The performance seems
fine.

Issue #489
2011-06-30 10:06:26 -07:00
Brian Anderson
3483c65b1f Add missing item variants to fold_item_underscore 2011-06-30 10:06:26 -07:00
Brian Anderson
aa6a3debf3 Add missing expression variants to fold_expr 2011-06-30 10:06:26 -07:00
Brian Anderson
1f0c25406c Fold the crate-level module in front::fold 2011-06-30 10:06:26 -07:00
Brian Anderson
5de916dd5c Move middle::attr to front::attr 2011-06-30 10:06:26 -07:00
Brian Anderson
afc8a5c031 Convert the eval::env to an ast::crate_cfg
crate_cfg will replace eval::env as the mechanism for conditional compilation.
This is a transitional step so they can both exist together.

Issue #489
2011-06-30 10:06:25 -07:00
Brian Anderson
d53bfad8e7 Introduce a config property to the crate AST node
This represents the compilation environment, defined as AST meta_items, Used
for driving conditional compilation and will eventually replace the
environment used by the parser for the current conditional compilation scheme.

Issue #489
2011-06-30 10:06:25 -07:00
Graydon Hoare
afabde19dc More fixes to fast-check. 2011-06-29 17:54:05 -07:00
Tim Chevalier
88447a47c0 Eliminate the --check-claims compiler flag
The option can only be toggled at runtime now.
2011-06-29 14:28:02 -07:00
Brian Anderson
6832f75f0b Support attaching attributes to modules via the crate file. Issue #487 2011-06-28 18:39:34 -07:00
Tim Chevalier
9f1444c701 Implement "claim"
Implement "claim" (issue #14), which is a version of "check" that
doesn't really do the check at runtime. It's an unsafe feature.

The new flag --check-claims turns claims into checks automatically --
but it's off by default, so by default, the assertion in a claim
doesn't execute at runtime.
2011-06-28 16:41:06 -07:00
Eric Holk
64596e6583 Teach the parser and typechecker to understand port[int](). Closes #588 2011-06-28 16:11:04 -07:00
Tim Chevalier
a7c4c19d4b add a predicate that determines whether a binop is lazy (and and or are lazy) 2011-06-28 13:07:52 -07:00
Brian Anderson
cab73f8897 Write metadata for more meta_item types. Issue #487 2011-06-28 10:12:05 -07:00
Marijn Haverbeke
9561def209 Use 'resource' rather than 'res' as a keyword
Resources are now defined like...

    resource fd(int n) { close(n); }

Calling fd with an int will then produce a non-copyable value
that, when dropped, will call close on the given int.
2011-06-28 18:00:39 +02:00
Paul Stansifer
b3443eb049 '#simplext' -> '#macro' 2011-06-28 15:02:12 +00:00
Paul Stansifer
c3901cdf8e Add simple syntax extension (#simplext) 2011-06-28 15:02:12 +00:00
Paul Stansifer
b632681780 Add AST fold. 2011-06-28 15:02:12 +00:00
Rafael Ávila de Espíndola
ecc080ed0b Use "" in the native_name as an indication that no extra options have to
be passed to the "linker". Use that for libc.
2011-06-28 08:21:13 -04:00
Brian Anderson
ba5c7a570d Rename middle::metadata to metadata::cwriter. Move creader to metadata
Preparation for a lot more metadata refactoring
2011-06-27 16:30:27 -07:00
Rafael Ávila de Espíndola
ac081c30be Record and link with used native libraries. 2011-06-27 15:24:44 -04:00
Marijn Haverbeke
f6753be655 Allow moving out of temporary values
This will probably need more work, as moving doesn't appear to do
quite the right thing yet in general, and we should also check
somewhere that we're not, for example, moving out the content out of
an immutable field (probably moving out of fields is not okay in
general).
2011-06-25 21:15:11 +02:00
Marijn Haverbeke
61fc12d0d0 Partial implementation of resources
Non-copyability is not enforced yet, and something is still flaky with
dropping of the internal value, so don't actually use them yet. I'm
merging this in so that I don't have to keep merging against new
patches.
2011-06-25 21:15:11 +02:00
Tim Chevalier
c772269f08 Fix inexhaustive match in parser 2011-06-24 22:38:01 -07:00
Tim Chevalier
582e1f13f0 Invalidate constraints correctly after an assignment expression
Modified typestate to throw away any constraints mentioning a
variable on the LHS of an assignment, recv, assign_op, or on
either side of a swap.

Some code cleanup as well.
2011-06-24 22:36:53 -07:00
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
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
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
Brian Anderson
3aa8d7ff45 rustc: Pretty-print ternary operator 2011-06-23 23:14:40 -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
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
Brian Anderson
d9b56ec2ea rustc: Limit creader exports 2011-06-22 19:04:04 -07:00
Brian Anderson
8746b84eec rustc: Handle valueless ret expressions as block results. Closes #521 2011-06-22 17:20:01 -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
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
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
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
Brian Anderson
23d6a6bde1 rustc: Remove unused slice call from extfmt. Closes #532 2011-06-21 07:49:40 -07:00
Marijn Haverbeke
75681f9ad7 Get rid of def_ids and anns in AST nodes, use single node_id
This reduces some redundancy in the AST data structures and cruft in
the code that works with them. To get a def_id from a node_id, apply
ast::local_def, which adds the local crate_num to the given node_id.
Most code only deals with crate-local node_ids, and won't have to
create def_ids at all.
2011-06-20 23:53:28 +02:00
Rafael Ávila de Espíndola
3d8a5cb9e6 Remember the library files we used in rustc and pass them to the "linker".
This avoid the hardcoded -lstd, allows programs to use other crates and avoids
any differences that may exist in the rustc and ld search logic.
2011-06-20 17:44:12 -04:00
Brian Anderson
200dbe4c4f Remove various rustboot workarounds 2011-06-19 20:48:20 -07:00
Brian Anderson
43427dae0c rustc: Rename session.span_err -> span_fatal, err -> fatal
Issue #440
2011-06-19 12:19:53 -07:00
Brian Anderson
cf9ed08a50 Revert previous 6 commits. Hopefully put out Windows fire.
Revert "rustc: Export only what's needed from middle::ty"

This reverts commit 4255d58aa5.

Revert "rustc: Make name resolution errors less fatal"

This reverts commit b8ab9ea89c.

Revert "rustc: Make import resolution errors less fatal"

This reverts commit 92a8ae94b9.

Revert "rustc: Export only what's used from middle::resolve"

This reverts commit 4539a2cf7a.

Revert "rustc: Re-introduce session.span_err, session.err"

This reverts commit 7fe9a88e31.

Revert "rustc: Rename session.span_err -> span_fatal, err -> fatal"

This reverts commit c394a7f49a.
2011-06-19 03:29:19 -07:00
Brian Anderson
c394a7f49a rustc: Rename session.span_err -> span_fatal, err -> fatal
Issue #440
2011-06-19 02:40:59 -07:00
Brian Anderson
514813148b rustc: Store the lhs and rhs of receive exprs in left to right order
With the changing of receive semantics the parser has been putting the rhs
expression in the first argument of expr_recv and the lhs in the second, and
all subsequent passes have been referring to them backwords (but still doing
the right thing because they were assuming that lhs was the port and rhs was
the receiver).

This makes all code agree on what lhs and rhs mean for receive expressions.
2011-06-18 20:23:05 -07:00
Brian Anderson
364cd5763c rustc: receive is spelled |> now 2011-06-18 20:23:05 -07:00
Brian Anderson
ddbb31eb8e rustc: Remove the meta keyword
Issue #487
2011-06-18 20:23:05 -07:00
Brian Anderson
81a187e8be rustc: Remove metadata from the session.
This mechanism was not being used for anything. Issue #487.
2011-06-17 14:46:59 -07:00
Paul Stansifer
391348ec86 Consistify ast::local. 2011-06-16 17:56:24 -07:00
Brian Anderson
6f4326c54d Add better error messages for bad attributes in .rc files
Issue #487
2011-06-16 17:23:20 -07:00
Brian Anderson
4b8fba5f34 rustc: Fix regressed handling of bad attributes
Issue #487
2011-06-16 17:23:20 -07:00
Brian Anderson
ffa7c76ed2 rustc: Change print_file to print_crate
The pretty-printer needs access to the crate attributes in order to reproduce
inner crate attributes in standalone .rs files

Issue #487
2011-06-16 17:23:20 -07:00
Brian Anderson
e83a115d79 rustc: Parse crate attributes in standalone .rs files
Issue #487
2011-06-16 17:23:20 -07:00