Skip to content

Commit

Permalink
Fixed type resolution error in math tests
Browse files Browse the repository at this point in the history
  • Loading branch information
boggle authored and graydon committed Dec 14, 2011
1 parent 50db7ce commit af8e471
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 8 deletions.
64 changes: 64 additions & 0 deletions src/libstd/mtypes.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
Module: mtypes
Machine type equivalents of rust int, uint, float, and complex.
Types useful for interop with C when writing bindings that exist
for different types (float, f32, f64, ...; cf float.rs for an example)
*/

export m_int, m_uint, m_float;

// PORT Change this when porting to a new architecture

/*
Type: m_int
Machine type equivalent of an int
*/
#[cfg(target_arch="x86")]
type m_int = i32;
#[cfg(target_arch="x86_64")]
type m_int = i64;

// PORT Change this when porting to a new architecture

/*
Type: m_uint
Machine type equivalent of a uint
*/
#[cfg(target_arch="x86")]
type m_uint = u32;
#[cfg(target_arch="x86_64")]
type m_uint = u64;

// PORT *must* match with "import m_float = fXX" in std::math per arch

/*
Type: m_float
Machine type equivalent of a float
*/
type m_float = f64;

// PORT *must* match "import m_complex = ..." in std::complex per arch

/*
FIXME Type m_complex
Machine type representing a complex value that uses floats for
both the real and the imaginary part.
*/
// type m_complex = complex_c64::t;

//
// Local Variables:
// mode: rust
// fill-column: 78;
// indent-tabs-mode: nil
// c-basic-offset: 4
// buffer-file-coding-system: utf-8-unix
// End:
//
4 changes: 1 addition & 3 deletions src/test/compile-fail/non-triv-cast-be.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// error-pattern: non-trivial cast of tail-call return value
use std;

import ctypes::*;
import core::mtypes::*;

fn foo_float() -> m_float { ret 0.0 as m_float; }
fn bar_float() -> bool { be foo_float() as bool; }
Expand Down
6 changes: 4 additions & 2 deletions src/test/run-pass/triv-cast-be.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use std;
import core::ctypes::*;

import ctypes::*;
import core::mtypes::m_float;
import core::mtypes::m_int;
import core::mtypes::m_uint;

fn foo_float() -> m_float { ret 0.0 as m_float; }
fn bar_float() -> float { be foo_float() as float; }
Expand Down
4 changes: 1 addition & 3 deletions src/test/run-pass/triv-cast-const.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use std;

import ctypes::*;
import core::mtypes::m_int;

// This will be more interesting once there is support
// for consts that refer to other consts, i.e. math_f64::consts::pi as m_float
Expand Down

0 comments on commit af8e471

Please sign in to comment.