2018-11-24 14:12:15 +01:00
|
|
|
use super::BackendTypes;
|
2018-09-20 15:47:22 +02:00
|
|
|
use mir::place::PlaceRef;
|
|
|
|
|
use rustc::mir::interpret::Allocation;
|
|
|
|
|
use rustc::mir::interpret::Scalar;
|
|
|
|
|
use rustc::ty::layout;
|
2018-08-28 17:03:46 +02:00
|
|
|
use syntax::symbol::LocalInternedString;
|
|
|
|
|
|
2018-11-24 14:12:15 +01:00
|
|
|
pub trait ConstMethods<'tcx>: BackendTypes {
|
2018-08-28 17:03:46 +02:00
|
|
|
// Constant constructors
|
2018-09-06 11:57:42 -07:00
|
|
|
fn const_null(&self, t: Self::Type) -> Self::Value;
|
|
|
|
|
fn const_undef(&self, t: Self::Type) -> Self::Value;
|
|
|
|
|
fn const_int(&self, t: Self::Type, i: i64) -> Self::Value;
|
|
|
|
|
fn const_uint(&self, t: Self::Type, i: u64) -> Self::Value;
|
|
|
|
|
fn const_uint_big(&self, t: Self::Type, u: u128) -> Self::Value;
|
|
|
|
|
fn const_bool(&self, val: bool) -> Self::Value;
|
|
|
|
|
fn const_i32(&self, i: i32) -> Self::Value;
|
|
|
|
|
fn const_u32(&self, i: u32) -> Self::Value;
|
|
|
|
|
fn const_u64(&self, i: u64) -> Self::Value;
|
|
|
|
|
fn const_usize(&self, i: u64) -> Self::Value;
|
|
|
|
|
fn const_u8(&self, i: u8) -> Self::Value;
|
2018-09-24 17:35:39 +02:00
|
|
|
|
|
|
|
|
// This is a 'c-like' raw string, which differs from
|
|
|
|
|
// our boxed-and-length-annotated strings.
|
2018-09-13 14:58:19 +02:00
|
|
|
fn const_cstr(&self, s: LocalInternedString, null_terminated: bool) -> Self::Value;
|
2018-09-24 17:35:39 +02:00
|
|
|
|
2018-09-06 11:57:42 -07:00
|
|
|
fn const_str_slice(&self, s: LocalInternedString) -> Self::Value;
|
2018-09-13 14:58:19 +02:00
|
|
|
fn const_fat_ptr(&self, ptr: Self::Value, meta: Self::Value) -> Self::Value;
|
|
|
|
|
fn const_struct(&self, elts: &[Self::Value], packed: bool) -> Self::Value;
|
2018-09-06 11:57:42 -07:00
|
|
|
fn const_array(&self, ty: Self::Type, elts: &[Self::Value]) -> Self::Value;
|
|
|
|
|
fn const_vector(&self, elts: &[Self::Value]) -> Self::Value;
|
|
|
|
|
fn const_bytes(&self, bytes: &[u8]) -> Self::Value;
|
2018-08-28 17:03:46 +02:00
|
|
|
|
2018-08-30 14:58:15 +02:00
|
|
|
fn const_get_elt(&self, v: Self::Value, idx: u64) -> Self::Value;
|
|
|
|
|
fn const_get_real(&self, v: Self::Value) -> Option<(f64, bool)>;
|
|
|
|
|
fn const_to_uint(&self, v: Self::Value) -> u64;
|
2018-08-30 15:41:59 +02:00
|
|
|
fn const_to_opt_u128(&self, v: Self::Value, sign_ext: bool) -> Option<u128>;
|
|
|
|
|
|
2018-08-30 14:58:15 +02:00
|
|
|
fn is_const_integral(&self, v: Self::Value) -> bool;
|
|
|
|
|
fn is_const_real(&self, v: Self::Value) -> bool;
|
2018-09-20 15:47:22 +02:00
|
|
|
|
|
|
|
|
fn scalar_to_backend(
|
|
|
|
|
&self,
|
|
|
|
|
cv: Scalar,
|
|
|
|
|
layout: &layout::Scalar,
|
|
|
|
|
llty: Self::Type,
|
|
|
|
|
) -> Self::Value;
|
|
|
|
|
fn from_const_alloc(
|
|
|
|
|
&self,
|
|
|
|
|
layout: layout::TyLayout<'tcx>,
|
|
|
|
|
alloc: &Allocation,
|
|
|
|
|
offset: layout::Size,
|
|
|
|
|
) -> PlaceRef<'tcx, Self::Value>;
|
2018-11-24 17:23:22 +01:00
|
|
|
|
|
|
|
|
fn const_ptrcast(&self, val: Self::Value, ty: Self::Type) -> Self::Value;
|
2018-08-28 17:03:46 +02:00
|
|
|
}
|