Skip to content

Commit

Permalink
auto merge of rust-lang#8165 : graydon/rust/2013-07-31-new-codegen-te…
Browse files Browse the repository at this point in the history
…sts, r=brson

r? @pcwalton or someone
  • Loading branch information
bors committed Aug 1, 2013
2 parents fe28ac6 + 8261f2c commit 7daea7c
Show file tree
Hide file tree
Showing 16 changed files with 268 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/test/codegen/iterate-over-array.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#include <stdlib.h>
#include <assert.h>

Expand Down
10 changes: 10 additions & 0 deletions src/test/codegen/iterate-over-array.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#[no_mangle]
fn test(x: &[int]) -> int {
let mut y = 0;
Expand Down
10 changes: 10 additions & 0 deletions src/test/codegen/scalar-function-call.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#include <stdlib.h>

size_t foo(size_t x) {
Expand Down
10 changes: 10 additions & 0 deletions src/test/codegen/scalar-function-call.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

fn foo(x: int) -> int {
x * x
}
Expand Down
10 changes: 10 additions & 0 deletions src/test/codegen/small-dense-int-switch.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#include <stdlib.h>

extern "C"
Expand Down
10 changes: 10 additions & 0 deletions src/test/codegen/small-dense-int-switch.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#[no_mangle]
fn test(x: int, y: int) -> int {
match x {
Expand Down
10 changes: 10 additions & 0 deletions src/test/codegen/stack-alloc-string-slice.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#include <stddef.h>

struct slice {
Expand Down
10 changes: 10 additions & 0 deletions src/test/codegen/stack-alloc-string-slice.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#[no_mangle]
fn test() {
let _x = "hello";
Expand Down
27 changes: 27 additions & 0 deletions src/test/codegen/static-method-call-multi.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#include <stdlib.h>

struct Struct {
size_t field;
size_t method(size_t x) {
return this->field + x;
}
};

extern "C"
size_t test(Struct &a,
Struct &b,
Struct &c,
Struct &d,
Struct &e) {
return a.method(b.method(c.method(d.method(e.method(1)))));
}
28 changes: 28 additions & 0 deletions src/test/codegen/static-method-call-multi.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

struct Struct {
field: int
}

impl Struct {
fn method(&self, x: int) -> int {
self.field + x
}
}

#[no_mangle]
fn test(a: &Struct,
b: &Struct,
c: &Struct,
d: &Struct,
e: &Struct) -> int {
a.method(b.method(c.method(d.method(e.method(1)))))
}
23 changes: 23 additions & 0 deletions src/test/codegen/static-method-call.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#include <stdlib.h>

struct Struct {
size_t field;
size_t method() {
return this->field;
}
};

extern "C"
size_t test(Struct &s) {
return s.method();
}
24 changes: 24 additions & 0 deletions src/test/codegen/static-method-call.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

struct Struct {
field: int
}

impl Struct {
fn method(&self) -> int {
self.field
}
}

#[no_mangle]
fn test(s: &Struct) -> int {
s.method()
}
25 changes: 25 additions & 0 deletions src/test/codegen/virtual-method-call-struct-return.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#include <stdlib.h>

struct Stuff {
size_t a;
double b;
};

struct Struct {
virtual Stuff method() = 0;
};

extern "C"
size_t test(Struct &s) {
return s.method().a;
}
23 changes: 23 additions & 0 deletions src/test/codegen/virtual-method-call-struct-return.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

struct Stuff {
a: int,
b: f64
}

trait Trait {
fn method(&self) -> Stuff;
}

#[no_mangle]
fn test(t: &Trait) -> int {
t.method().a
}
20 changes: 20 additions & 0 deletions src/test/codegen/virtual-method-call.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#include <stdlib.h>

struct Struct {
virtual size_t method() = 0;
};

extern "C"
size_t test(Struct &s) {
return s.method();
}
18 changes: 18 additions & 0 deletions src/test/codegen/virtual-method-call.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

trait Trait {
fn method(&self) -> int;
}

#[no_mangle]
fn test(t: &Trait) -> int {
t.method()
}

0 comments on commit 7daea7c

Please sign in to comment.