diff options
| author | Huon Wilson <dbau.pp+github@gmail.com> | 2015-08-14 15:46:51 -0700 |
|---|---|---|
| committer | Huon Wilson <dbau.pp+github@gmail.com> | 2015-08-17 14:48:44 -0700 |
| commit | b067e4464bc8f519485476935d7d6b2bc860e569 (patch) | |
| tree | f05a5e4a370d9e8d57d13052b051cab1f186fbbb /src/libsyntax/ast.rs | |
| parent | 502f9acbe9a41c64c92a3eba8186e8b44963fc76 (diff) | |
| download | rust-b067e4464bc8f519485476935d7d6b2bc860e569.tar.gz rust-b067e4464bc8f519485476935d7d6b2bc860e569.zip | |
Clean up simd_cast translation.
Diffstat (limited to 'src/libsyntax/ast.rs')
| -rw-r--r-- | src/libsyntax/ast.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 0bcd97cfe87..2d72c8fe2a4 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -1339,6 +1339,15 @@ impl IntTy { TyI16 | TyI32 | TyI64 => 3, } } + pub fn bit_width(&self) -> Option<usize> { + Some(match *self { + TyIs => return None, + TyI8 => 8, + TyI16 => 16, + TyI32 => 32, + TyI64 => 64, + }) + } } #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy)] @@ -1357,6 +1366,15 @@ impl UintTy { TyU16 | TyU32 | TyU64 => 3, } } + pub fn bit_width(&self) -> Option<usize> { + Some(match *self { + TyUs => return None, + TyU8 => 8, + TyU16 => 16, + TyU32 => 32, + TyU64 => 64, + }) + } } impl fmt::Debug for UintTy { @@ -1395,6 +1413,12 @@ impl FloatTy { TyF32 | TyF64 => 3, // add F128 handling here } } + pub fn bit_width(&self) -> usize { + match *self { + TyF32 => 32, + TyF64 => 64, + } + } } // Bind a type to an associated type: `A=Foo`. |
