Tim Chevalier
fa74df033d
Add a constraint on trans::type_of_fn_from_ty
...
And change callers appropriately.
2011-09-16 13:07:08 -07:00
Tim Chevalier
0d4b51d10d
Add a returns_non_ty_var predicate
...
which just calls non_ty_var on the return type of t, assuming t is
a function type.
2011-09-16 13:06:31 -07:00
Tim Chevalier
1b2c5c4c9b
Make ty_fn_ret pure and get rid of a duplicate function
2011-09-16 13:06:31 -07:00
Marijn Haverbeke
43b219dbec
Work around an apparent compiler bug to make my patch run
...
Without this, it would fail when optimization is turned on. The result of
the Load(bcx, llclosure) call would end up in llenv in a corrupted form.
2011-09-16 21:31:36 +02:00
Marijn Haverbeke
575aae407b
Saner approach to lvalues and callable values in trans
...
LValues no longer carry information about generics and objs, instead
there's an extended form of lvalue, lval_maybe_callee, only used by
call and bind, which holds this info.
This makes it possible to take the value of a method and get a working
closure, and will (with some more work) allow us to call statically
known functions without loading from their pair.
Closes #435
Closes #758
2011-09-16 21:31:36 +02:00
Tim Chevalier
172df2e3a2
Add non_ty_var precondition for type_of_fn, plus minor cleanup
2011-09-16 10:58:02 -07:00
Marijn Haverbeke
ad470d741e
Revert "Saner approach to lvalues and callable values in trans"
...
This reverts commit 66153436c9
.
2011-09-16 18:37:46 +02:00
Marijn Haverbeke
133d36f452
Require body of else-less if expressions to be a value-less block
...
For consistency with other constructs that could not possibly return a
value (say, loops).
2011-09-16 18:21:06 +02:00
Marijn Haverbeke
66153436c9
Saner approach to lvalues and callable values in trans
...
LValues no longer carry information about generics and objs, instead
there's an extended form of lvalue, lval_maybe_callee, only used by
call and bind, which holds this info.
This makes it possible to take the value of a method and get a working
closure, and will (with some more work) allow us to call statically
known functions without loading from their pair.
Closes #435
Closes #758
2011-09-16 18:21:05 +02:00
Marijn Haverbeke
639d88a693
Move expr_uniq case in trans to a saner place
...
Note that unique pointers are still broken in more ways than I can count.
2011-09-16 15:03:03 +02:00
Marijn Haverbeke
f8a35234ad
Remove autoderef for calls
...
We were only using it in a single place, and there for no discernable reason
(probably as part of the bare-fn-vals-are-not-copyable plan). It seems more
surprising than useful.
2011-09-16 14:39:30 +02:00
Marijn Haverbeke
c04490d97b
Remove unused method_ty field from lval_result
2011-09-16 14:18:49 +02:00
Marijn Haverbeke
fb42d839a0
Clean up (and optimize) root-mutability analysis in alias.rs
2011-09-16 13:46:03 +02:00
Marijn Haverbeke
d7587c1eda
Change convention for specifying referenced argument
...
It is now 1-based, rather than 0 based. (Seems more natural, and allows 0 to
be used to refer to self and maybe to closure.)
Also allows non-referenced args to be implicitly copied again.
Issue #918
2011-09-16 12:42:18 +02:00
Tim Chevalier
059b31f7a3
Actually call unreachable() in impossible case in type_of_inner
2011-09-15 23:22:12 -07:00
Tim Chevalier
57ede5f281
Added non_ty_var precondition to trans::type_of_inner
...
This allows us to legitimately call unreachable() in the ty_var case.
2011-09-15 23:22:12 -07:00
Jesse Ruderman
ce1877dc8e
Add parens, as needed, around else-if conditions.
2011-09-15 21:24:24 -07:00
Tim Chevalier
2c6eba00dd
Added an extra check in trans_alt
...
Gratuitous right now, but I'm going to change the type of trans::type_of
2011-09-15 20:32:01 -07:00
Tim Chevalier
f41f75fe53
Added more predicates in trans
...
Added the non_ty_var predicate (soon to be used)
Added a check in get_res_dtor (will be necessary for a future change
to type_of_fn)
Removed a gratuitous ret
2011-09-15 20:23:06 -07:00
Tim Chevalier
059952da5b
Change a few span_fatals to span_err
2011-09-15 19:51:27 -07:00
Graydon Hoare
1e3e7d4bc5
Update README slightly.
2011-09-15 16:31:33 -07:00
Marijn Haverbeke
7364a8c2b0
Prevent binary expressions from parsing when lhs is non-value block
2011-09-15 17:37:10 +02:00
Marijn Haverbeke
b843cf2117
Generalize expression roots in alias analysis
...
This allows calls-returning-a-reference to count as expression roots,
making it possible to return the result of such a call by reference.
Issue #918
2011-09-15 17:01:35 +02:00
Marijn Haverbeke
3abe3671bd
Require the parameter that will be referenced to be noted
...
Issue #918
2011-09-15 16:15:17 +02:00
Marijn Haverbeke
75eee8b194
Overhaul alias-checking of blocks
...
The set of active bindings has to be updated as by-reference locals are
encountered.
Issue #918
2011-09-15 15:43:15 +02:00
Marijn Haverbeke
87fa38910e
Make storing returned references in a by-reference local work
...
fn f(a: {x: str}) -> &str {
ret a.x;
}
fn main() {
let x = {x: "hi"};
let &y = f(x); // Look ma, no copy!
log_err y;
}
Issue #918 .
2011-09-15 15:17:14 +02:00
Marijn Haverbeke
25787bd2b8
Forbid assignment to by-reference bindings
...
Issue #918
2011-09-15 14:08:54 +02:00
Marijn Haverbeke
d7a1d6a1cb
Make trans understand by-ref bindings
...
Issue #918
2011-09-15 14:00:58 +02:00
Marijn Haverbeke
8aad16112b
Implement basic checking of by-reference bindings
...
Issue #918
2011-09-15 13:40:28 +02:00
Marijn Haverbeke
44c6370e6a
Move local numbering into ast_map.rs
...
This further simplifies the alias pass, which is sorely needed.
2011-09-15 13:18:32 +02:00
Marijn Haverbeke
1cda74deee
Add representation for by-ref let bindings
...
Issue #918
2011-09-15 11:42:56 +02:00
Marijn Haverbeke
197f360e30
Ensure parens are wrapped around composite exprs in call/index/field pos
...
This is needed to fix the second example in issue #919
2011-09-15 11:15:14 +02:00
Marijn Haverbeke
8c83ea564b
More thorough check for (.. 10).x in pretty-printer
...
Closes #919
2011-09-15 10:59:06 +02:00
Marijn Haverbeke
63ecc84562
Also handle fail and put in print_maybe_parens_discrim
...
Closes #920
2011-09-15 10:14:52 +02:00
Marijn Haverbeke
3798b6f780
Remove maybe_protect_block kludge from pretty-printer
...
It is no longer needed.
2011-09-15 10:14:52 +02:00
Marijn Haverbeke
0b34e0e60b
Introduce new semicolon rules
...
- Loop bodies and resource constructors aren't allowed to have
trailing expressions anymore.
- An expression that ends* in a block without trailing expression can
can not be called, indexed, or subscripted.
- Only expression-statements that end* in a block without trailing
expression can omit their semicolon.
*) 'Ending in a trailing expression' is defined as being a block or
construct-ending-in-a-block (if, alt) that either ends in an
expression itself, or ends in another block-like expression that
has a trailing expression (by these same rules).
2011-09-15 09:49:00 +02:00
Marijn Haverbeke
7298b8f4ba
Insert omitted semicolons for statements
2011-09-15 09:49:00 +02:00
Brian Anderson
31d4fe37f6
Revert "Try a little harder to avoid creating new landing pads"
...
This reverts commit b8e31ac469
.
Conflicts:
src/comp/middle/trans.rs
2011-09-14 09:19:31 -07:00
Marijn Haverbeke
93de2f0b74
Add syntax and representation for return-by-mutably-rooted-ref
...
This will be used in the near future to decide what can safely
be done with the returned reference.
Issue #918
2011-09-14 17:30:38 +02:00
Marijn Haverbeke
1cabe37155
Prevent memory errors when returning references to temp args.
...
Issue #918
2011-09-14 16:46:54 +02:00
Marijn Haverbeke
c6619f9ce0
Accept returning refs rooted in an arg from a by-ref funtion
...
Issue #918
2011-09-14 16:19:15 +02:00
Marijn Haverbeke
a3c449df74
Make ast_map.rs index function args, switch it over to simple_visitor
2011-09-14 15:30:59 +02:00
Marijn Haverbeke
cd0e7fc041
Remove some extra white-space introduced by the pretty-printer
2011-09-14 15:20:22 +02:00
Marijn Haverbeke
7d69712dee
Disallow implicit arg copying when the function returns a ref
...
Issue #918
2011-09-14 14:57:20 +02:00
Marijn Haverbeke
93d2a4f82a
Add support for basic return-by-alias to trans
...
Issue #918
2011-09-14 14:39:08 +02:00
Marijn Haverbeke
9a69ee79e0
Clean up trans_obj.rs a bit
...
As a preparation to adding an arg to type_of_fn_full
2011-09-14 13:49:22 +02:00
Marijn Haverbeke
6cd24173d4
Add a ret_style field to fn_ctxt in trans
2011-09-14 13:48:51 +02:00
Marijn Haverbeke
2aac43d809
Simplify trans::new_fn_ctxt_w_id
...
It was still living in the pre-decent-type-inference era.
2011-09-14 13:26:39 +02:00
Marijn Haverbeke
0699acb6f7
Rudimentary checking of safe alias returns
2011-09-14 13:09:45 +02:00
Marijn Haverbeke
63519d9006
Rename restrict to binding in alias.rs
...
Its role gradually changed to the point where the old name doesn't
really make sense anymore.
2011-09-14 12:06:51 +02:00
Marijn Haverbeke
44df041799
Stop needlessly boxing vectors in alias.rs
2011-09-14 11:37:52 +02:00
Marijn Haverbeke
51dae63c44
Make most of the compiler aware of return-by-reference
...
tyencode/tydecode still don't know about it. return_ref will be extended to take
arguments anyway.
2011-09-14 11:31:05 +02:00
Marijn Haverbeke
c1c083cd66
Refactor parse_ret_ty, start parsing by-alias return specs
2011-09-14 10:46:40 +02:00
Marijn Haverbeke
6eb9738a66
Rename ast::controlflow to ast::ret_style
...
It will include information about returning by alias.
2011-09-14 10:38:23 +02:00
Josh Matthews
f6fe07d1f3
Add support for negative literals.
2011-09-14 00:47:14 -04:00
Brian Anderson
6d3dd0e48c
Try harder still to generate fewer landing pads
...
Scopes that don't have cleanups don't need their own landing pads
This takes the optimized rustc bin from 4.7MB to 4.4
2011-09-13 16:52:12 -07:00
Brian Anderson
b8e31ac469
Try a little harder to avoid creating new landing pads
...
It's only when we add or revoke cleanups involving immediates that we need a
new landing pad for the scope.
Trims 5K off the optimized rustc bin
2011-09-13 16:52:12 -07:00
Brian Anderson
74c39469be
Reuse landing pads when possible
...
Cuts the optimized rustc bin from 5.2 to 4.7MB
2011-09-13 16:52:12 -07:00
Michael Sullivan
c84b8e90b8
Print something when we can't figure out a tag name. Mitigates #876 .
2011-09-13 13:14:49 -04:00
Marijn Haverbeke
b9267e8fbc
Add missing cases for machine floats in shape.rs
2011-09-13 17:46:28 +02:00
Marijn Haverbeke
577d6dd602
Improve lexing of float literals
...
Closes #575
2011-09-13 17:43:01 +02:00
Marijn Haverbeke
f72573cce8
Properly pretty-print 10.x
...
Closes #890
2011-09-13 17:08:59 +02:00
Marijn Haverbeke
e64e9792ab
Make pretty-printer wrap fail/ret/put in parens in call/index/field pos
...
Closes #764
Closes #891
2011-09-13 17:02:36 +02:00
Marijn Haverbeke
bc62b17543
Ensure that the declared type and actual type of a constant agree
...
Closes #899
2011-09-13 16:29:23 +02:00
Marijn Haverbeke
be5537e95f
Be more strict about what constitutes a block expression
...
Blocks (or statements involving blocks) that end in a semicolon are no
longer considered the block-expression of their outer block. This used
to be an expression block, but now is a statement block:
{ if foo { ret 1; } else { ret 10; } }
This helps clear up some ambiguities in our grammar.
2011-09-13 15:50:03 +02:00
Marijn Haverbeke
e945164879
Always warn when implicitly copying a generic type
2011-09-13 13:40:38 +02:00
Marijn Haverbeke
38e86d708b
Properly alias-check bindings in for-each loops
2011-09-13 13:34:08 +02:00
Marijn Haverbeke
45bdff01b2
Clean up copy bookkeeping in alias.rs
2011-09-13 13:23:32 +02:00
Marijn Haverbeke
2f402343c9
Make for loop alias-safe
2011-09-13 13:05:59 +02:00
Marijn Haverbeke
3e92f90952
Apply implicit copying for unsafe references to alt patterns
2011-09-13 12:23:36 +02:00
Graydon Hoare
7f94957721
Kill trailing whitespace.
2011-09-12 16:33:43 -07:00
Graydon Hoare
a4815b6742
Factor imports mindlessly.
2011-09-12 16:13:28 -07:00
Brian Anderson
393deeb06f
Merge branch 'unwind'
...
Conflicts:
src/comp/middle/trans.rs
src/comp/middle/trans_build.rs
src/lib/run_program.rs
src/test/compiletest/runtest.rs
2011-09-12 09:36:51 -07:00
Marijn Haverbeke
edde2e0c45
Undo some pretty-printer damage in ty.rs
2011-09-12 14:43:41 +02:00
Marijn Haverbeke
982a1a4783
Rename alias to reference in docs and error messages
...
Update docs to reflect new approach to aliases
2011-09-12 14:24:46 +02:00
Marijn Haverbeke
bcf60c6600
Warn when inserting an implicit copy that may be expensive
2011-09-12 13:54:02 +02:00
Marijn Haverbeke
8dd46d4384
Properly implement copy expressions
...
(And use them in some places that were doing {expr} before.)
2011-09-12 13:13:20 +02:00
Marijn Haverbeke
f4b6264f8c
Remove backwards-compatibility with old arg-mode syntax
2011-09-12 12:49:00 +02:00
Marijn Haverbeke
ca1df2b111
Pretty-print for new arg-mode syntax
2011-09-12 12:49:00 +02:00
Marijn Haverbeke
bfa021de0d
Switch pretty-printer to new arg-mode syntax
2011-09-12 12:48:59 +02:00
Marijn Haverbeke
3667137a41
Accept {|| ... } for argument-less block syntax
...
Closes #880
2011-09-12 12:04:41 +02:00
Marijn Haverbeke
fc6b7c8b38
Reformat for new mode syntax, step 1
...
Long lines were fixed in a very crude way, as I'll be following up
with another reformat in a bit.
2011-09-12 12:04:14 +02:00
Marijn Haverbeke
0e6e56ca60
Make the names of the arg mode tag reflect their (revised) meaning
2011-09-12 11:07:17 +02:00
Marijn Haverbeke
4be7e1e5cd
Pass all arguments by reference, make immut alias mode equiv to value
...
Arguments that can't be safely referenced will be implicitly copied.
(Warnings for expensive copies will be forthcoming.)
This will allow us to get rid of most of the ampersands in function
signatures. See [1].
[1] https://mail.mozilla.org/pipermail/rust-dev/2011-September/000759.html
2011-09-12 11:06:54 +02:00
Brian Anderson
d267e7486e
Zero locals when the initializer might call a function
...
The function might fail, leaving the local uninitialized
Issue #236
2011-09-11 17:31:40 -07:00
Brian Anderson
118194381c
Invoke put functions
...
Issue #236
2011-09-11 17:31:40 -07:00
Brian Anderson
53f7d6119a
Add some FIXMEs about unwinding implementation
...
Issue #236
2011-09-11 17:31:39 -07:00
Brian Anderson
4fba02c7e9
Invoke upcall_fail
...
This allows landing pads to be generated around fail statements
Issue #236
2011-09-11 17:31:38 -07:00
Brian Anderson
4c9eee8aa4
Run cleanups during unwinding
...
Issue #236
2011-09-11 17:31:38 -07:00
Brian Anderson
587b863772
Zero locals that have initializers that might fail
...
This will avoid running cleanups on uninitialized memory
Issue #236
2011-09-11 17:31:38 -07:00
Brian Anderson
4eb3ce3280
Add landing pads to invokes
...
Issue #236
2011-09-11 17:31:38 -07:00
Brian Anderson
5e4637b61f
Add Rust definitions for new LLVM EH instructions
...
Issue #236
2011-09-11 17:31:38 -07:00
Brian Anderson
4bced5e5f2
Use invoke to call (most) rust functions
...
No landing pads yet.
Issue #236
2011-09-11 17:31:38 -07:00
Brian Anderson
9f4b4d89ce
Add upcall_rust_personality
...
This just wraps __gxx_personality_v0 with our upcall naming convention
Issue #236
2011-09-11 17:31:38 -07:00
Jesse Ruderman
476bbca87a
Fuzzer: move tys around in addition to exprs
2011-09-10 18:55:09 -07:00
Jesse Ruderman
7182054416
Add missing arm, so pretty-printing the statement 'copy 1;' does not die.
2011-09-09 21:27:07 -07:00
Jesse Ruderman
8e00161819
Make the pretty printer disambiguatae blocks followed by vec expressions.
...
Semicolons are needed here now that postfix [] is used for vec indexing (the syntax change made in rev 518dc52f85
).
2011-09-09 19:47:40 -07:00
Marijn Haverbeke
db15591d89
Revert "Make for loops alias the vec elements, rather than copy them"
...
This reverts commit 985ef59efd
.
2011-09-09 16:53:45 +02:00
Marijn Haverbeke
3ac59b0ee0
Get rid of vp2i in object field access
...
Closes #557
2011-09-09 15:53:10 +02:00
Marijn Haverbeke
985ef59efd
Make for loops alias the vec elements, rather than copy them
...
The alias analysis was already assuming that it worked like this.
2011-09-09 15:34:13 +02:00