Skip to content

Commit

Permalink
Remove either crate
Browse files Browse the repository at this point in the history
  • Loading branch information
antoyo committed Sep 7, 2019
1 parent 9e122d9 commit 43f7ebb
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 10 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Expand Up @@ -56,7 +56,6 @@ target-all = [
experimental = ["static-alloc"]

[dependencies]
either = "1.5"
libc = "0.2"
llvm-sys = "80.1"
static-alloc = { version = "0.1", optional = true }
Expand Down
2 changes: 1 addition & 1 deletion src/builder.rs
@@ -1,13 +1,13 @@
//! A `Builder` enables you to build instructions.

use either::{Either, Left, Right};
use llvm_sys::core::{LLVMBuildAdd, LLVMBuildAlloca, LLVMBuildAnd, LLVMBuildArrayAlloca, LLVMBuildArrayMalloc, LLVMBuildAtomicRMW, LLVMBuildBr, LLVMBuildCall, LLVMBuildCast, LLVMBuildCondBr, LLVMBuildExtractValue, LLVMBuildFAdd, LLVMBuildFCmp, LLVMBuildFDiv, LLVMBuildFence, LLVMBuildFMul, LLVMBuildFNeg, LLVMBuildFree, LLVMBuildFSub, LLVMBuildGEP, LLVMBuildICmp, LLVMBuildInsertValue, LLVMBuildIsNotNull, LLVMBuildIsNull, LLVMBuildLoad, LLVMBuildMalloc, LLVMBuildMul, LLVMBuildNeg, LLVMBuildNot, LLVMBuildOr, LLVMBuildPhi, LLVMBuildPointerCast, LLVMBuildRet, LLVMBuildRetVoid, LLVMBuildStore, LLVMBuildSub, LLVMBuildUDiv, LLVMBuildUnreachable, LLVMBuildXor, LLVMDisposeBuilder, LLVMGetElementType, LLVMGetInsertBlock, LLVMGetReturnType, LLVMGetTypeKind, LLVMInsertIntoBuilder, LLVMPositionBuilderAtEnd, LLVMTypeOf, LLVMBuildExtractElement, LLVMBuildInsertElement, LLVMBuildIntToPtr, LLVMBuildPtrToInt, LLVMInsertIntoBuilderWithName, LLVMClearInsertionPosition, LLVMCreateBuilder, LLVMPositionBuilder, LLVMPositionBuilderBefore, LLVMBuildAggregateRet, LLVMBuildStructGEP, LLVMBuildInBoundsGEP, LLVMBuildPtrDiff, LLVMBuildNSWAdd, LLVMBuildNUWAdd, LLVMBuildNSWSub, LLVMBuildNUWSub, LLVMBuildNSWMul, LLVMBuildNUWMul, LLVMBuildSDiv, LLVMBuildSRem, LLVMBuildURem, LLVMBuildFRem, LLVMBuildNSWNeg, LLVMBuildNUWNeg, LLVMBuildFPToUI, LLVMBuildFPToSI, LLVMBuildSIToFP, LLVMBuildUIToFP, LLVMBuildFPTrunc, LLVMBuildFPExt, LLVMBuildIntCast, LLVMBuildFPCast, LLVMBuildSExtOrBitCast, LLVMBuildZExtOrBitCast, LLVMBuildTruncOrBitCast, LLVMBuildSwitch, LLVMAddCase, LLVMBuildShl, LLVMBuildAShr, LLVMBuildLShr, LLVMBuildGlobalString, LLVMBuildGlobalStringPtr, LLVMBuildExactSDiv, LLVMBuildTrunc, LLVMBuildSExt, LLVMBuildZExt, LLVMBuildSelect, LLVMBuildAddrSpaceCast, LLVMBuildBitCast, LLVMBuildShuffleVector, LLVMBuildVAArg, LLVMBuildIndirectBr, LLVMAddDestination};
use llvm_sys::core::LLVMBuildAtomicCmpXchg;
use llvm_sys::prelude::{LLVMBuilderRef, LLVMValueRef};
use llvm_sys::{LLVMTypeKind};

use crate::{AtomicOrdering, AtomicRMWBinOp, IntPredicate, FloatPredicate};
use crate::basic_block::BasicBlock;
use crate::either::{Either, Left, Right};
use crate::values::{AggregateValue, AggregateValueEnum, AsValueRef, BasicValue, BasicValueEnum, PhiValue, FunctionValue, IntValue, PointerValue, VectorValue, InstructionValue, GlobalValue, IntMathValue, FloatMathValue, PointerMathValue, InstructionOpcode, CallSiteValue};
use crate::values::StructValue;
use crate::types::{AsTypeRef, BasicType, IntMathType, FloatMathType, PointerType, PointerMathType};
Expand Down
30 changes: 30 additions & 0 deletions src/either.rs
@@ -0,0 +1,30 @@
#[derive(Debug)]
pub enum Either<S, T> {
Left(S),
Right(T),
}

pub use Either::{Left, Right};

impl<S, T> Either<S, T> {
pub fn is_right(&self) -> bool {
match self {
Left(_) => false,
Right(_) => true,
}
}

pub fn left(self) -> Option<S> {
match self {
Left(value) => Some(value),
Right(_) => None,
}
}

pub fn right(self) -> Option<T> {
match self {
Left(_) => None,
Right(value) => Some(value),
}
}
}
2 changes: 1 addition & 1 deletion src/lib.rs
Expand Up @@ -11,7 +11,6 @@
//! * Most functions which take a string slice as input may possibly panic in the unlikely event that a c style string cannot be created based on it. (IE if your slice already has a null byte in it)

#![deny(missing_debug_implementations)]
extern crate either;
extern crate libc;
extern crate llvm_sys;
#[macro_use]
Expand All @@ -31,6 +30,7 @@ pub mod builder;
#[deny(missing_docs)]
pub mod context;
pub mod data_layout;
pub mod either;
pub mod execution_engine;
pub mod memory_buffer;
#[deny(missing_docs)]
Expand Down
2 changes: 1 addition & 1 deletion src/targets.rs
@@ -1,4 +1,3 @@
use either::Either;
use llvm_sys::target::{
LLVMABIAlignmentOfType, LLVMABISizeOfType, LLVMByteOrder, LLVMByteOrdering,
LLVMCallFrameAlignmentOfType, LLVMCopyStringRepOfTargetData, LLVMCreateTargetData,
Expand All @@ -21,6 +20,7 @@ use llvm_sys::target_machine::{

use crate::context::Context;
use crate::data_layout::DataLayout;
use crate::either::Either;
use crate::memory_buffer::MemoryBuffer;
use crate::module::Module;
use crate::passes::PassManager;
Expand Down
2 changes: 1 addition & 1 deletion src/values/basic_value_use.rs
@@ -1,8 +1,8 @@
use either::{Either, Either::{Left, Right}};
use llvm_sys::core::{LLVMGetNextUse, LLVMGetUser, LLVMGetUsedValue, LLVMIsABasicBlock, LLVMValueAsBasicBlock};
use llvm_sys::prelude::LLVMUseRef;

use crate::basic_block::BasicBlock;
use crate::either::{Either, Either::{Left, Right}};
use crate::values::{BasicValueEnum, InstructionValue};

/// A usage of a `BasicValue` in an `InstructionValue`.
Expand Down
2 changes: 1 addition & 1 deletion src/values/call_site_value.rs
@@ -1,10 +1,10 @@
use either::Either;
use llvm_sys::LLVMTypeKind;
use llvm_sys::core::{LLVMIsTailCall, LLVMSetTailCall, LLVMGetTypeKind, LLVMTypeOf, LLVMSetInstructionCallConv, LLVMGetInstructionCallConv, LLVMSetInstrParamAlignment};
use llvm_sys::prelude::LLVMValueRef;

use crate::attributes::{Attribute};
use crate::attributes::AttributeLoc;
use crate::either::Either;
use crate::support::LLVMString;
use crate::values::{AsValueRef, BasicValueEnum, InstructionValue, Value};
use crate::values::FunctionValue;
Expand Down
2 changes: 1 addition & 1 deletion src/values/instruction_value.rs
@@ -1,10 +1,10 @@
use either::{Either, Either::{Left, Right}};
use llvm_sys::core::{LLVMGetAlignment, LLVMSetAlignment, LLVMGetInstructionOpcode, LLVMIsTailCall, LLVMGetPreviousInstruction, LLVMGetNextInstruction, LLVMGetInstructionParent, LLVMInstructionEraseFromParent, LLVMInstructionClone, LLVMSetVolatile, LLVMGetVolatile, LLVMGetNumOperands, LLVMGetOperand, LLVMGetOperandUse, LLVMSetOperand, LLVMValueAsBasicBlock, LLVMIsABasicBlock, LLVMGetICmpPredicate, LLVMGetFCmpPredicate, LLVMIsAAllocaInst, LLVMIsALoadInst, LLVMIsAStoreInst};
use llvm_sys::core::LLVMInstructionRemoveFromParent;
use llvm_sys::LLVMOpcode;
use llvm_sys::prelude::LLVMValueRef;

use crate::basic_block::BasicBlock;
use crate::either::{Either, Either::{Left, Right}};
use crate::values::traits::AsValueRef;
use crate::values::{BasicValue, BasicValueEnum, BasicValueUse, Value};
use crate::{IntPredicate, FloatPredicate};
Expand Down
2 changes: 0 additions & 2 deletions tests/all/main.rs
@@ -1,7 +1,5 @@
//! Having a main.rs in a directory w/ mods will force tests to be built in a single binary

extern crate either;

mod test_attributes;
mod test_basic_block;
mod test_builder;
Expand Down
2 changes: 1 addition & 1 deletion tests/all/test_targets.rs
Expand Up @@ -120,7 +120,7 @@ fn test_target_and_target_machine() {
#[cfg(not(any(feature = "llvm3-6", feature = "llvm3-7", feature = "llvm3-8", feature = "llvm3-9",
feature = "llvm4-0", feature = "llvm5-0", feature = "llvm6-0")))]
{
use either::Either::{Left, Right};
use self::inkwell::either::Either::{Left, Right};

// TODO: Try and find a triple that actually gets normalized..
assert_eq!(*TargetMachine::normalize_target_triple(Left("x86_64-pc-linux-gnu")), *CString::new("x86_64-pc-linux-gnu").unwrap());
Expand Down

0 comments on commit 43f7ebb

Please sign in to comment.