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 c_null(&self, t: Self::Type) -> Self::Value;
17 fn c_undef(&self, t: Self::Type) -> Self::Value;
18 fn c_int(&self, t: Self::Type, i: i64) -> Self::Value;
19 fn c_uint(&self, t: Self::Type, i: u64) -> Self::Value;
20 fn c_uint_big(&self, t: Self::Type, u: u128) -> Self::Value;
21 fn c_bool(&self, val: bool) -> Self::Value;
22 fn c_i32(&self, i: i32) -> Self::Value;
23 fn c_u32(&self, i: u32) -> Self::Value;
24 fn c_u64(&self, i: u64) -> Self::Value;
25 fn c_usize(&self, i: u64) -> Self::Value;
26 fn c_u8(&self, i: u8) -> Self::Value;
29 s: LocalInternedString,
30 null_terminated: bool,
32 fn c_str_slice(&self, s: LocalInternedString) -> Self::Value;
43 fn c_array(&self, ty: Self::Type, elts: &[Self::Value]) -> Self::Value;
44 fn c_vector(&self, elts: &[Self::Value]) -> Self::Value;
45 fn c_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 is_const_integral(&self, v: Self::Value) -> bool;
51 fn is_const_real(&self, v: Self::Value) -> bool;
52 fn const_to_opt_u128(&self, v: Self::Value, sign_ext: bool) -> Option<u128>;
55 pub trait CommonWriteMethods : Backend {
56 fn val_ty(&self, v: Self::Value) -> Self::Type;
57 fn c_bytes_in_context(&self, llcx: Self::Context, bytes: &[u8]) -> Self::Value;
58 fn c_struct_in_context(