2018-08-28 17:03:46 +02:00
|
|
|
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
|
//
|
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
|
// except according to those terms.
|
|
|
|
|
|
|
|
|
|
use super::Backend;
|
|
|
|
|
use syntax::symbol::LocalInternedString;
|
|
|
|
|
|
2018-08-29 16:40:47 +02:00
|
|
|
pub trait CommonMethods : Backend + CommonWriteMethods {
|
2018-08-28 17:03:46 +02:00
|
|
|
// Constant constructors
|
2018-08-29 15:56:30 +02:00
|
|
|
fn c_null(&self, t: Self::Type) -> Self::Value;
|
|
|
|
|
fn c_undef(&self, t: Self::Type) -> Self::Value;
|
|
|
|
|
fn c_int(&self, t: Self::Type, i: i64) -> Self::Value;
|
|
|
|
|
fn c_uint(&self, t: Self::Type, i: u64) -> Self::Value;
|
|
|
|
|
fn c_uint_big(&self, t: Self::Type, u: u128) -> Self::Value;
|
2018-08-28 17:03:46 +02:00
|
|
|
fn c_bool(&self, val: bool) -> Self::Value;
|
|
|
|
|
fn c_i32(&self, i: i32) -> Self::Value;
|
|
|
|
|
fn c_u32(&self, i: u32) -> Self::Value;
|
|
|
|
|
fn c_u64(&self, i: u64) -> Self::Value;
|
|
|
|
|
fn c_usize(&self, i: u64) -> Self::Value;
|
|
|
|
|
fn c_u8(&self, i: u8) -> Self::Value;
|
|
|
|
|
fn c_cstr(
|
|
|
|
|
&self,
|
|
|
|
|
s: LocalInternedString,
|
|
|
|
|
null_terminated: bool,
|
|
|
|
|
) -> Self::Value;
|
|
|
|
|
fn c_str_slice(&self, s: LocalInternedString) -> Self::Value;
|
|
|
|
|
fn c_fat_ptr(
|
|
|
|
|
&self,
|
|
|
|
|
ptr: Self::Value,
|
|
|
|
|
meta: Self::Value
|
|
|
|
|
) -> Self::Value;
|
|
|
|
|
fn c_struct(
|
|
|
|
|
&self,
|
|
|
|
|
elts: &[Self::Value],
|
|
|
|
|
packed: bool
|
|
|
|
|
) -> Self::Value;
|
|
|
|
|
fn c_struct_in_context(
|
|
|
|
|
llcx: Self::Context,
|
|
|
|
|
elts: &[Self::Value],
|
|
|
|
|
packed: bool,
|
|
|
|
|
) -> Self::Value;
|
|
|
|
|
fn c_array(ty: Self::Type, elts: &[Self::Value]) -> Self::Value;
|
|
|
|
|
fn c_vector(elts: &[Self::Value]) -> Self::Value;
|
|
|
|
|
fn c_bytes(&self, bytes: &[u8]) -> Self::Value;
|
|
|
|
|
|
|
|
|
|
fn const_get_elt(v: Self::Value, idx: u64) -> Self::Value;
|
|
|
|
|
fn const_get_real(v: Self::Value) -> Option<(f64, bool)>;
|
|
|
|
|
fn const_to_uint(v: Self::Value) -> u64;
|
|
|
|
|
fn is_const_integral(v: Self::Value) -> bool;
|
|
|
|
|
fn is_const_real(v: Self::Value) -> bool;
|
|
|
|
|
fn const_to_opt_u128(v: Self::Value, sign_ext: bool) -> Option<u128>;
|
|
|
|
|
}
|
2018-08-29 16:40:47 +02:00
|
|
|
|
|
|
|
|
pub trait CommonWriteMethods : Backend {
|
|
|
|
|
fn val_ty(v: Self::Value) -> Self::Type;
|
|
|
|
|
fn c_bytes_in_context(llcx: Self::Context, bytes: &[u8]) -> Self::Value;
|
|
|
|
|
}
|