From 4a569a47e266a1945dedb65c9e6059696fbb9a7a Mon Sep 17 00:00:00 2001 From: Gregoire Geis Date: Fri, 29 Sep 2017 23:20:27 +0200 Subject: [PATCH] Values and types can now be copied and cloned. --- src/types/array_type.rs | 2 +- src/types/float_type.rs | 2 +- src/types/fn_type.rs | 2 +- src/types/int_type.rs | 2 +- src/types/mod.rs | 2 +- src/types/ptr_type.rs | 2 +- src/types/struct_type.rs | 2 +- src/types/vec_type.rs | 2 +- src/types/void_type.rs | 2 +- src/values/array_value.rs | 2 +- src/values/float_value.rs | 2 +- src/values/fn_value.rs | 2 +- src/values/int_value.rs | 2 +- src/values/metadata_value.rs | 2 +- src/values/mod.rs | 2 +- src/values/phi_value.rs | 2 +- src/values/ptr_value.rs | 2 +- src/values/struct_value.rs | 2 +- src/values/vec_value.rs | 2 +- 19 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/types/array_type.rs b/src/types/array_type.rs index 9c07da9f3d05e..f4dd734252373 100644 --- a/src/types/array_type.rs +++ b/src/types/array_type.rs @@ -8,7 +8,7 @@ use types::traits::AsTypeRef; use types::{Type, BasicType, PointerType, FunctionType}; use values::{BasicValue, ArrayValue, PointerValue, IntValue}; -#[derive(Debug, PartialEq, Eq)] +#[derive(Debug, PartialEq, Eq, Clone, Copy)] pub struct ArrayType { array_type: Type, } diff --git a/src/types/float_type.rs b/src/types/float_type.rs index a3e4b997936d2..9e7acabe6605f 100644 --- a/src/types/float_type.rs +++ b/src/types/float_type.rs @@ -9,7 +9,7 @@ use types::traits::AsTypeRef; use types::{Type, PointerType, FunctionType, BasicType, ArrayType, VectorType}; use values::{FloatValue, GenericValue, PointerValue, IntValue}; -#[derive(Debug, PartialEq, Eq)] +#[derive(Debug, PartialEq, Eq, Clone, Copy)] pub struct FloatType { float_type: Type, } diff --git a/src/types/fn_type.rs b/src/types/fn_type.rs index 6e9daa189c2db..dffab54f0b9ec 100644 --- a/src/types/fn_type.rs +++ b/src/types/fn_type.rs @@ -10,7 +10,7 @@ use types::traits::AsTypeRef; use types::{Type, BasicTypeEnum}; // use values::FunctionValue; -#[derive(PartialEq, Eq)] +#[derive(PartialEq, Eq, Clone, Copy)] pub struct FunctionType { fn_type: Type, } diff --git a/src/types/int_type.rs b/src/types/int_type.rs index 8d7097d9a4dd0..9b0bdf4ea0964 100644 --- a/src/types/int_type.rs +++ b/src/types/int_type.rs @@ -9,7 +9,7 @@ use types::traits::AsTypeRef; use types::{Type, ArrayType, BasicType, VectorType, PointerType, FunctionType}; use values::{GenericValue, IntValue, PointerValue}; -#[derive(Debug, PartialEq, Eq)] +#[derive(Debug, PartialEq, Eq, Clone, Copy)] pub struct IntType { int_type: Type, } diff --git a/src/types/mod.rs b/src/types/mod.rs index 8864a748f2b28..60419c4fb6ac3 100644 --- a/src/types/mod.rs +++ b/src/types/mod.rs @@ -34,7 +34,7 @@ use values::{IntValue, PointerValue}; // Worth noting that types seem to be singletons. At the very least, primitives are. // Though this is likely only true per thread since LLVM claims to not be very thread-safe. // REVIEW: Maybe move this into its own module? -#[derive(PartialEq, Eq)] +#[derive(PartialEq, Eq, Clone, Copy)] struct Type { type_: LLVMTypeRef, } diff --git a/src/types/ptr_type.rs b/src/types/ptr_type.rs index 30b8eab2183af..59c5980f02cc4 100644 --- a/src/types/ptr_type.rs +++ b/src/types/ptr_type.rs @@ -8,7 +8,7 @@ use types::traits::AsTypeRef; use types::{Type, BasicType, ArrayType, FunctionType, VectorType}; use values::{PointerValue, IntValue}; -#[derive(Debug, PartialEq, Eq)] +#[derive(Debug, PartialEq, Eq, Clone, Copy)] pub struct PointerType { ptr_type: Type, } diff --git a/src/types/struct_type.rs b/src/types/struct_type.rs index 22950fa85570c..39f2c040e8881 100644 --- a/src/types/struct_type.rs +++ b/src/types/struct_type.rs @@ -9,7 +9,7 @@ use types::traits::AsTypeRef; use types::{Type, BasicType, BasicTypeEnum, ArrayType, PointerType, FunctionType, VectorType}; use values::{BasicValue, StructValue, PointerValue, IntValue}; -#[derive(Debug, PartialEq, Eq)] +#[derive(Debug, PartialEq, Eq, Clone, Copy)] pub struct StructType { struct_type: Type, } diff --git a/src/types/vec_type.rs b/src/types/vec_type.rs index 0cb5e2c1f2f80..15379c42a97b5 100644 --- a/src/types/vec_type.rs +++ b/src/types/vec_type.rs @@ -9,7 +9,7 @@ use values::{BasicValue, PointerValue, VectorValue, IntValue}; // REVIEW: vec_type() is impl for IntType & FloatType. Need to // find out if it is valid for other types too. Maybe PointerType? -#[derive(Debug, PartialEq, Eq)] +#[derive(Debug, PartialEq, Eq, Clone, Copy)] pub struct VectorType { vec_type: Type, } diff --git a/src/types/void_type.rs b/src/types/void_type.rs index 565f5e51adeff..5c6772cd62c92 100644 --- a/src/types/void_type.rs +++ b/src/types/void_type.rs @@ -8,7 +8,7 @@ use values::PointerValue; use std::ffi::CStr; -#[derive(Debug, PartialEq, Eq)] +#[derive(Debug, PartialEq, Eq, Clone, Copy)] pub struct VoidType { void_type: Type, } diff --git a/src/values/array_value.rs b/src/values/array_value.rs index d920411926a07..05ea9f06fbee0 100644 --- a/src/values/array_value.rs +++ b/src/values/array_value.rs @@ -8,7 +8,7 @@ use types::ArrayType; use values::traits::AsValueRef; use values::{Value, InstructionValue, MetadataValue}; -#[derive(PartialEq, Eq)] +#[derive(PartialEq, Eq, Clone, Copy)] pub struct ArrayValue { array_value: Value } diff --git a/src/values/float_value.rs b/src/values/float_value.rs index 4820fb788f28a..2fa07f2ea3570 100644 --- a/src/values/float_value.rs +++ b/src/values/float_value.rs @@ -8,7 +8,7 @@ use types::{AsTypeRef, FloatType, IntType}; use values::traits::AsValueRef; use values::{InstructionValue, IntValue, Value, MetadataValue}; -#[derive(Debug, PartialEq, Eq)] +#[derive(Debug, PartialEq, Eq, Clone, Copy)] pub struct FloatValue { float_value: Value } diff --git a/src/values/fn_value.rs b/src/values/fn_value.rs index 84a0234d7d747..f17b3d2b17145 100644 --- a/src/values/fn_value.rs +++ b/src/values/fn_value.rs @@ -12,7 +12,7 @@ use types::{BasicTypeEnum, FunctionType}; use values::traits::AsValueRef; use values::{BasicValueEnum, Value, MetadataValue}; -#[derive(PartialEq, Eq)] +#[derive(PartialEq, Eq, Clone, Copy)] pub struct FunctionValue { fn_value: Value, } diff --git a/src/values/int_value.rs b/src/values/int_value.rs index 06584c4b53044..7ed44cf472301 100644 --- a/src/values/int_value.rs +++ b/src/values/int_value.rs @@ -8,7 +8,7 @@ use types::{AsTypeRef, FloatType, PointerType, IntType}; use values::traits::AsValueRef; use values::{FloatValue, InstructionValue, PointerValue, Value, MetadataValue}; -#[derive(Debug, PartialEq, Eq)] +#[derive(Debug, PartialEq, Eq, Clone, Copy)] pub struct IntValue { int_value: Value, } diff --git a/src/values/metadata_value.rs b/src/values/metadata_value.rs index a931653b653d3..50a44d39a349b 100644 --- a/src/values/metadata_value.rs +++ b/src/values/metadata_value.rs @@ -11,7 +11,7 @@ use std::slice::from_raw_parts; pub const FIRST_CUSTOM_METADATA_KIND_ID: u32 = 14; // TODO: Varies by version -#[derive(PartialEq, Eq)] +#[derive(PartialEq, Eq, Clone, Copy)] pub struct MetadataValue { metadata_value: Value, } diff --git a/src/values/mod.rs b/src/values/mod.rs index ff29909df6f3c..251b31bdbe32c 100644 --- a/src/values/mod.rs +++ b/src/values/mod.rs @@ -33,7 +33,7 @@ use llvm_sys::prelude::{LLVMValueRef, LLVMTypeRef}; use std::ffi::{CString, CStr}; use std::fmt; -#[derive(PartialEq, Eq)] +#[derive(PartialEq, Eq, Clone, Copy)] struct Value { value: LLVMValueRef, } diff --git a/src/values/phi_value.rs b/src/values/phi_value.rs index 0643da2b8ea13..f961f7dce4745 100644 --- a/src/values/phi_value.rs +++ b/src/values/phi_value.rs @@ -8,7 +8,7 @@ use values::traits::AsValueRef; use values::{BasicValue, BasicValueEnum, InstructionValue, Value}; // REVIEW: Metadata for phi values? -#[derive(Debug, PartialEq, Eq)] +#[derive(Debug, PartialEq, Eq, Clone, Copy)] pub struct PhiValue { phi_value: Value } diff --git a/src/values/ptr_value.rs b/src/values/ptr_value.rs index 6617215631925..40bdf7d83c0cd 100644 --- a/src/values/ptr_value.rs +++ b/src/values/ptr_value.rs @@ -6,7 +6,7 @@ use std::ffi::CStr; use types::{AsTypeRef, IntType, PointerType}; use values::{AsValueRef, InstructionValue, IntValue, Value, MetadataValue}; -#[derive(Debug, PartialEq, Eq)] +#[derive(Debug, PartialEq, Eq, Clone, Copy)] pub struct PointerValue { ptr_value: Value, } diff --git a/src/values/struct_value.rs b/src/values/struct_value.rs index 79735faeb895a..1ef14e83d0339 100644 --- a/src/values/struct_value.rs +++ b/src/values/struct_value.rs @@ -6,7 +6,7 @@ use types::StructType; use values::traits::AsValueRef; use values::{InstructionValue, Value, MetadataValue}; -#[derive(Debug, PartialEq, Eq)] +#[derive(Debug, PartialEq, Eq, Clone, Copy)] pub struct StructValue { struct_value: Value } diff --git a/src/values/vec_value.rs b/src/values/vec_value.rs index 939ea720c6742..f5d444d06cea3 100644 --- a/src/values/vec_value.rs +++ b/src/values/vec_value.rs @@ -7,7 +7,7 @@ use types::{VectorType}; use values::traits::AsValueRef; use values::{BasicValueEnum, BasicValue, InstructionValue, Value, IntValue, MetadataValue}; -#[derive(Debug, PartialEq, Eq)] +#[derive(Debug, PartialEq, Eq, Clone, Copy)] pub struct VectorValue { vec_value: Value, }