1 // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
12 use syntax::symbol::LocalInternedString;
14 pub trait CommonMethods: Backend + CommonWriteMethods {
15 // Constant constructors
16 fn const_null(&self, t: Self::Type) -> Self::Value;
17 fn const_undef(&self, t: Self::Type) -> Self::Value;
18 fn const_int(&self, t: Self::Type, i: i64) -> Self::Value;
19 fn const_uint(&self, t: Self::Type, i: u64) -> Self::Value;
20 fn const_uint_big(&self, t: Self::Type, u: u128) -> Self::Value;
21 fn const_bool(&self, val: bool) -> Self::Value;
22 fn const_i32(&self, i: i32) -> Self::Value;
23 fn const_u32(&self, i: u32) -> Self::Value;
24 fn const_u64(&self, i: u64) -> Self::Value;
25 fn const_usize(&self, i: u64) -> Self::Value;
26 fn const_u8(&self, i: u8) -> Self::Value;
29 s: LocalInternedString,
30 null_terminated: bool,
32 fn const_str_slice(&self, s: LocalInternedString) -> Self::Value;
43 fn const_array(&self, ty: Self::Type, elts: &[Self::Value]) -> Self::Value;
44 fn const_vector(&self, elts: &[Self::Value]) -> Self::Value;
45 fn const_bytes(&self, bytes: &[u8]) -> Self::Value;
47 fn const_get_elt(&self, v: Self::Value, idx: u64) -> Self::Value;
48 fn const_get_real(&self, v: Self::Value) -> Option<(f64, bool)>;
49 fn const_to_uint(&self, v: Self::Value) -> u64;
50 fn const_to_opt_u128(&self, v: Self::Value, sign_ext: bool) -> Option<u128>;
52 fn is_const_integral(&self, v: Self::Value) -> bool;
53 fn is_const_real(&self, v: Self::Value) -> bool;
56 pub trait CommonWriteMethods: Backend {
57 fn val_ty(&self, v: Self::Value) -> Self::Type;
58 fn const_bytes_in_context(&self, llcx: Self::Context, bytes: &[u8]) -> Self::Value;
59 fn const_struct_in_context(