about summary refs log tree commit diff
path: root/src/libsyntax
AgeCommit message (Collapse)AuthorLines
2013-03-15auto merge of #5359 : luqmana/rust/inline-asm, r=pcwaltonbors-7/+47
Continuation of #5317. Actually use operands properly now, including any number of output operands. Which means you can do things like call printf: ```Rust fn main() { unsafe { do str::as_c_str(~"The answer is %d.\n") |c| { let a = 42; asm!("mov $0, %rdi\n\t\ mov $1, %rsi\n\t\ xorl %eax, %eax\n\t\ call _printf" : : "r"(c), "r"(a) : "rdi", "rsi", "eax" : "volatile","alignstack" ); } } } ``` ``` % rustc foo.rs % ./foo The answer is 42. ``` Or just add 2 numbers: ```Rust fn add(a: int, b: int) -> int { let mut c = 0; unsafe { asm!("add $2, $0" : "=r"(c) : "0"(a), "r"(b) ); } c } fn main() { io::println(fmt!("%d", add(1, 2))); } ``` ``` % rustc foo.rs % ./foo 3 ``` Multiple outputs! ```Rust fn addsub(a: int, b: int) -> (int, int) { let mut c = 0; let mut d = 0; unsafe { asm!("add $4, $0\n\t\ sub $4, $1" : "=r"(c), "=r"(d) : "0"(a), "1"(a), "r"(b) ); } (c, d) } fn main() { io::println(fmt!("%?", addsub(5, 1))); } ``` ``` % rustc foo.rs % ./foo (6, 4) ``` This also classifies inline asm as RvalueStmtExpr instead of the somewhat arbitrary kind I made it initially. There are a few XXX's regarding what to do in the liveness and move passes.
2013-03-15auto merge of #5404 : bstrie/rust/decopy, r=pcwaltonbors-1/+1
Also turn `copy` into `.clone()` in much of run-pass.
2013-03-15Fix type_use for inline asm.Luqman Aden-2/+2
2013-03-15Tidy.Luqman Aden-1/+1
2013-03-15Implicitly use addr_of for output operands in asm.Luqman Aden-0/+7
2013-03-15Actually pass inline asm operands around.Luqman Aden-7/+40
2013-03-15impl Clone for ~T, ~[T], ~strBen Striegel-1/+1
2013-03-15Update test case to conform to new restrictions on castingJohn Clements-3/+2
2013-03-15Test case fixup (old one tested the old bad behavior).John Clements-12/+12
2013-03-15add nonempty encoding for spansJohn Clements-1/+1
Before this change, encoding an object containing a codemap::span using the JSON encodeng produced invalid JSON, for instance: [{"span":,"global":false,"idents":["abc"]}] Since the decoder for codemap::span's ignores its argument, I conjecture that this will not damage decoding, and should improve it for many decoders.
2013-03-14rustdoc: Document explicit self in methods. Closes #5254Zack Corr-1/+2
2013-03-13libsyntax: Remove a use of deprecated Encodable from libsyntax. rs=burningtreePatrick Walton-1/+1
2013-03-13test: Fix tests. rs=testsPatrick Walton-2/+1
2013-03-13librustc: Don't require the "static" keyword to define a static methodPatrick Walton-10/+10
2013-03-13librustc: Remove implicit self from the language, except for old-style drop ↵Patrick Walton-1/+15
blocks.
2013-03-13librustc: Remove "base types" from the language.Patrick Walton-4/+8
2013-03-13librustc: Remove overloaded operator autoderef.Patrick Walton-1/+1
2013-03-13librustc: Don't accept `as Trait` anymore; fix all occurrences of it.Patrick Walton-310/+325
2013-03-13Remove `++` mode from the compiler (it is parsed as `+` mode)Niko Matsakis-11/+19
and obsolete `-` mode altogether (it *was* parsed as `+` mode).
2013-03-13auto merge of #5293 : brson/rust/logging, r=brsonbors-24/+23
r? @graydon This removes `log` from the language. Because we can't quite implement it as a syntax extension (probably need globals at the least) it simply renames the keyword to `__log` and hides it behind macros. After this the only way to log is with `debug!`, `info!`, etc. I figure that if there is demand for `log!` we can add it back later. I am not sure that we ever agreed on this course of action, though I *think* there is consensus that `log` shouldn't be a statement.
2013-03-12auto merge of #5320 : apasel422/rust/metaderive, r=graydonbors-0/+45
This is the first in a series of patches I'm working on to clean up the code related to `deriving`. This patch allows ``` #[deriving_eq] #[deriving_iter_bytes] #[deriving_clone] struct Foo { bar: uint } ``` to be replaced with: ``` #[deriving(Eq, IterBytes, Clone)] struct Foo { bar: uint } ``` It leaves the old attributes alone for the time being. Eventually I'd like to incorporate the new closest-match-suggestion infrastructure for mistyped trait names, and also pass the sub-attributes to the deriving code, so that the following will be possible: ``` #[deriving(TotalOrd(qux, bar))] struct Foo { bar: uint, baz: char, qux: int } ``` This says to derive an `impl` in which the objects' `qux` fields are compared first, followed by `bar`, while `baz` is ignored in the comparison. If no fields are specified explicitly, all fields will be compared in the order they're defined in the `struct`. This might also be useful for `Eq`. Coming soon.
2013-03-12syntax: implement #[deriving] meta-attributeAndrew Paseltiner-0/+45
2013-03-12Add alignstack option for inline asm.Luqman Aden-4/+7
2013-03-12Keep everything tidy.Luqman Aden-10/+9
2013-03-12Parse operands properly and add a way to indicate volatile asm.Luqman Aden-14/+137
2013-03-12Stop parsing __asm__.Luqman Aden-9/+0
2013-03-12Create asm! syntax extension.Luqman Aden-1/+58
2013-03-12Parse inline assembly.Luqman Aden-1/+22
2013-03-11Remove the log keyword (by renaming it to __log)Brian Anderson-10/+10
We can't quite remove logging from the language, but this hides the keyword.
2013-03-11core: Remove logging constantsBrian Anderson-8/+8
2013-03-11Remove uses of logBrian Anderson-14/+13
2013-03-11auto merge of #5304 : jld/rust/const-adjustments, r=graydonbors-0/+5
These changes make const translation use adjustments (autodereference, autoreference, bare-fn-to-closure), like normal code does, replacing some ad-hoc logic that wasn't always right. As a convenient side-effect, explicit dereference (both of pointers and of newtypes) is also supported in const expressions. There is also a “bonus fix” for a bug in the pretty-printer exposed by one of the added tests.
2013-03-11librustc: Lint the old `drop` destructor notation offPatrick Walton-27/+2
2013-03-11libsyntax: Stop parsing newtype enumsPatrick Walton-10/+9
2013-03-11libsyntax: Remove newtype enums from libsyntax. rs=deenumPatrick Walton-40/+14
2013-03-11libsyntax: Stop parsing bare functions in preparation for switching them overPatrick Walton-1/+16
2013-03-11librustc: Replace all uses of `fn()` with `&fn()`. rs=defunPatrick Walton-42/+42
2013-03-11Implement vector destructuring from tailSeo Sanghyeon-31/+56
2013-03-09Don't print addr_of(addr_of(e)) as `&&e`, which means something else.Jed Davis-0/+5
2013-03-09Remove @ast::Region and replace with @ast::Lifetime.Niko Matsakis-160/+117
Modify pretty-printer to emit lifetimes and fix a few minor parser bugs that this uncovered.
2013-03-08auto merge of #5278 : brson/rust/logplusplus, r=brsonbors-8/+32
r? `log` can polymorphically log anything, but debug!, etc. requires a format string. With this patch you can equivalently write `debug!(foo)` or `debug!("%?", foo)`. I'm doing this because I was trying to remove `log` (replacing it with nothing, at least temporarily), but there are a number of logging statements that just want to print an arbitrary value and don't care about the format string. I'm not entirely convinced this is a good change, since it overloads the implementation of these macros and makes their usage slightly more nuanced.
2013-03-08Fix dvec-related fallout in testsAlex Crichton-3/+3
2013-03-08syntax: Remove uses of DVecAlex Crichton-39/+29
2013-03-07test: Fix tests.Patrick Walton-2/+5
2013-03-07librustc: Stop parsing `assert`.Patrick Walton-13/+10
2013-03-07librustc: Convert all uses of `assert` over to `fail_unless!`Patrick Walton-55/+55
2013-03-07librustc: Remove record patterns from the compilerPatrick Walton-40/+12
2013-03-07libsyntax: Remove struct literal expressions from the compilerPatrick Walton-64/+5
2013-03-07librustc: Remove structural record types from the compilerPatrick Walton-23/+2
2013-03-07libsyntax: Stop parsing structural record typesPatrick Walton-8/+7