use std::convert::TryFrom;
-use std::convert::TryInto;
use gccjit::LValue;
use gccjit::{Block, CType, RValue, Type, ToRValue};
let string = self.context.new_string_literal(&*string);
let sym = self.generate_local_symbol_name("str");
let global = self.declare_private_global(&sym, self.val_ty(string));
- global.global_set_initializer_value(string);
+ global.global_set_initializer_rvalue(string);
global
// TODO(antoyo): set linkage.
}
bytes.iter()
.map(|&byte| context.new_rvalue_from_int(byte_type, byte as i32))
.collect();
- context.new_rvalue_from_array(None, typ, &elements)
+ context.new_array_constructor(None, typ, &elements)
}
pub fn type_is_pointer<'gcc>(typ: Type<'gcc>) -> bool {
}
fn const_uint_big(&self, typ: Type<'gcc>, num: u128) -> RValue<'gcc> {
- let num64: Result<i64, _> = num.try_into();
- if let Ok(num) = num64 {
- // FIXME(antoyo): workaround for a bug where libgccjit is expecting a constant.
- // The operations >> 64 and | low are making the normal case a non-constant.
- return self.context.new_rvalue_from_long(typ, num as i64);
- }
-
if num >> 64 != 0 {
// FIXME(antoyo): use a new function new_rvalue_from_unsigned_long()?
let low = self.context.new_rvalue_from_long(self.u64_type, num as u64 as i64);
// TODO(antoyo): cache the type? It's anonymous, so probably not.
let typ = self.type_struct(&fields, packed);
let struct_type = typ.is_struct().expect("struct type");
- self.context.new_rvalue_from_struct(None, struct_type, values)
+ self.context.new_struct_constructor(None, struct_type.as_type(), None, values)
}
fn const_to_opt_uint(&self, _v: RValue<'gcc>) -> Option<u64> {