示例#1
0
 expression operator()(
   const types::rref< Type > &type
 ) const {
   const auto llvm_type = get_llvm_type( context, type.base );
   const std::shared_ptr< llvm::LLVMContext > &context_ = context;
   return expression(
     type.base, llvm_type,
     std::shared_ptr< llvm::Value >(
       ir_builder->CreateLoad( value.llvm_value().get(), type_traits::is_volatile( type_traits::remove_reference( type ) ) ),
       [context_]( llvm::Value* ){}
     )
   );
 }
示例#2
0
struct vm_value *
vm_value_new_from_float_constant(float float_constant)
{
   struct vm_value *vmval;

   vmval = calloc(1, sizeof(struct vm_value));
   if (!vmval) {
      fprintf(stderr, "Memory allocation request failed.\n");
      exit(EXIT_FAILURE);
   }

   vmval->type_specifier = TYPE_FLOAT;
   vmval->llvm_type = get_llvm_type(TYPE_FLOAT);
   vmval->llvm_value = LLVMConstReal(vmval->llvm_type, float_constant);

   return vmval;
}
示例#3
0
struct vm_value *
vm_value_new(int type_specifier, const char *identifier)
{
   struct vm_value *vmval;

   vmval = calloc(1, sizeof(struct vm_value));
   if (!vmval) {
      fprintf(stderr, "Memory allocation request failed.\n");
      exit(EXIT_FAILURE);
   }

   vmval->type_specifier = type_specifier;
   vmval->identifier = identifier;
   vmval->llvm_type = get_llvm_type(type_specifier);

   return vmval;
}
示例#4
0
 expression operator()(
   const Left &, const Right &,
   typename boost::enable_if<
     type_traits::meta::is_arithmetic_convertible< Left, Right >
   >::type* = 0
 ) const {
   const auto result_type = get_type< bool >();
   const auto converted_left = implicit_cast( context, ir_builder, result_type, left );
   const auto converted_right = implicit_cast( context, ir_builder, result_type, right );
   const std::shared_ptr< llvm::LLVMContext > &context_ = context;
   const auto llvm_type = get_llvm_type( context, result_type );
   return expression(
     result_type, llvm_type,
     std::shared_ptr< llvm::Value >(
       ir_builder->CreateOr(
         converted_left.llvm_value().get(),
         converted_right.llvm_value().get()
       ),
       [context_]( llvm::Value* ){}
     )
   );
 }