Rafael Ávila de Espíndola
41b7d6d74d
One last refactoring of the import handling:
...
* Create an import resolving stage. Currently this involves a copy of the ast,
we can probably revisit this once we revisit doing full copies of the ast in
general.
* Don't repeat work. Once we resolve a import, put it on a hash table and use
it next time we are asked for it. This solves a O(n^2) behaviour in
degenerated cases.
* Once import resolution is done, the target of an import is stored on the
import itself.
2011-01-18 15:43:13 -08:00
Rafael Ávila de Espíndola
9f3caed8a0
Enable more tests.
2011-01-17 18:13:55 -05:00
Rafael Ávila de Espíndola
58490d7fa0
Fix the last known (to me) bug in import resolution. We were not properly
...
dropping the inner part of the environment when an intermediate item resolved
in an outer scope.
2011-01-17 13:33:13 -08:00
Rafael Ávila de Espíndola
57b281533d
Some misc cleanups:
...
* Remove unused argument
* Move option.t wrapping to outer functions.
2011-01-17 14:58:18 -05:00
Rafael Ávila de Espíndola
5b9eda4a41
Fix the import handling in "complex" cases. When looking a.b.c and 'a' is a
...
module, we should look for 'b' *just* in the module 'a' and then continue
resolving b.c in the environment created by updating *with* a.
Still not 100% correct, but getting there.
2011-01-14 17:34:00 -05:00
Rafael Ávila de Espíndola
bdcb9d9b53
Make lookup non recursive and instead move the recursion just to
...
find_final_def. Use the fact that the recursion is in a simpler function to
detected import loops and exit.
2011-01-14 11:10:06 -08:00
Graydon Hoare
f3c3fc0353
Change single-ident expr_ident to greedy/fat multi-ident expr_path, to handle the module-path/value-indexing distinction.
2011-01-13 17:42:28 -08:00
Rafael Ávila de Espíndola
c1f2e29596
Produce better errors for invalid imports.
2011-01-12 12:27:31 -08:00
Rafael Ávila de Espíndola
c489abedb4
Call find_final_def directly in fold_view_item_import. It is both cleaner and
...
faster.
2011-01-12 12:26:59 -08:00
Rafael Ávila de Espíndola
359d72b4d0
Change mod_index_entry to point directly to items and view_items.
2011-01-12 12:26:23 -08:00
Rafael Ávila de Espíndola
34643eeac8
Fix another import case we got wrong: The local environment should not
...
interfere with the import statements.
2011-01-11 13:59:52 -08:00
Rafael Ávila de Espíndola
c5a766f133
Fix two invalid import cases we were not detecting:
...
* If an import was unused we would never print any errors for it.
* We would keep the existing environment in scope when descending 'foo.bar'
and would find 'bar' in the global environment if there was no 'bar' in
'foo'.
2011-01-11 13:58:39 -08:00
Rafael Ávila de Espíndola
2fb09eb585
Add sufficient import support to compile some simple single-crate programs.
...
This is likely not the final solution. It does repetitive work and doesn't produce
errors for invalid but unused imports. In any case, I think it is a useful step.
2011-01-07 15:17:18 -08:00
Rafael Ávila de Espíndola
7c8f99fdc1
Add names from imports to the namespace.
2011-01-04 17:58:10 -05:00
Rafael Ávila de Espíndola
e0fe271d34
Add support for looking up a name introduced by a 'use'.
...
With this we go from "error: unresolved name: foo" to
"unimplemented definition variant for: foo" in
use foo;
fn main(vec[str] args) {
foo.bar();
}
2011-01-04 11:35:13 -05:00
Graydon Hoare
ad889ba3ae
Change resolve errs to span_errs.
2010-12-31 14:43:43 -08:00
Graydon Hoare
bc9db2e972
Teach resolve to find obj fields and ty params from methods.
2010-12-30 15:27:52 -08:00
Patrick Walton
d1b2366983
rustc: Resolve type params
2010-12-15 13:13:36 -08:00
Graydon Hoare
4cddeed651
Teach resolve about obj items.
2010-12-14 17:09:37 -08:00
Patrick Walton
d08b5bc3d4
rustc: Fix nonexhaustive match failure on unresolved identifiers
2010-12-12 16:49:51 -08:00
Patrick Walton
9ac42ca743
rustc: Resolve variant names in patterns
2010-12-12 16:47:37 -08:00
Patrick Walton
bc5fa9bf67
rustc: "resoling" -> "resolving" typo
2010-12-12 16:37:31 -08:00
Patrick Walton
368459db43
rustc: Remove "update_env_for_arm" debugging message
2010-12-11 22:30:12 -08:00
Patrick Walton
de118d79b6
rustc: Resolve pattern bindings
2010-12-10 18:08:32 -08:00
Graydon Hoare
876282791e
First sketch of support for const items, not including most of trans.
2010-12-09 14:37:50 -08:00
Graydon Hoare
b971d6312e
Fix missing case in resolve, un-XFAIL rec-tup.rs.
2010-12-08 11:52:34 -08:00
Graydon Hoare
98a63bd1f9
Add code to fail on non-exhaustive alt matching. Fix all cases this picked up in rustc.
2010-12-01 17:09:02 -08:00
Patrick Walton
42282a25c0
rustc: Resolve tag variant names
2010-12-01 10:19:38 -08:00
Patrick Walton
9769b61226
rustc: Parse type-parametric typedefs
2010-11-24 17:36:22 -08:00
Patrick Walton
c1916adc7e
rustc: Parse type-parametric functions
2010-11-24 16:52:49 -08:00
Graydon Hoare
6fcf55347e
Resolve the easy case of type paths.
2010-11-22 13:24:53 -08:00
Patrick Walton
c3bc88a325
rustc: Add an annotation to function and type items so that the typechecker can store types with them
2010-11-10 18:20:02 -08:00
Patrick Walton
adb1754e4d
Move the option type to its own module
2010-11-05 11:18:40 -07:00
Patrick Walton
2fcf81cc4b
Revert "Move the option type to its own module"
2010-11-05 10:41:23 -07:00
Patrick Walton
1d214b4df3
Move the option type to its own module
2010-11-05 10:23:22 -07:00
Patrick Walton
a3d666bfdf
rustc: Use an extensible annotation field instead of putting option[@ty] everywhere
2010-11-03 15:54:46 -07:00
Graydon Hoare
6d47d2abde
Implement check-exprs, un-xfail 5 rustc tests.
2010-10-22 15:37:42 -07:00
Graydon Hoare
b8cca0971f
Teach trans to allocate, initialize and load from local variables.
2010-10-19 14:54:10 -07:00
Patrick Walton
10d628dbd0
Add a type slot to the AST
2010-10-19 13:28:43 -07:00
Graydon Hoare
4a3edb320d
Store items and decls in vecs to preserve input order, index externally. Implement block-local name lookup.
2010-10-18 18:19:16 -07:00
Graydon Hoare
865bbae685
More work on resolving names in rustc. Basic expr_name lookup working on items and args.
2010-10-18 16:15:25 -07:00
Graydon Hoare
67d4427345
Begin sketching name lookup in rustc.
2010-10-18 14:37:30 -07:00
Graydon Hoare
785d9b1594
Add a little code to resolve, to check that the fold interface works.
2010-10-07 18:34:22 -07:00
Graydon Hoare
fa5ef4cfb6
Add the beginnings of an ast folder plus an empty module for resolve.
2010-10-06 18:36:28 -07:00