1
Fork 0

New Backend trait containing associated types

This commit is contained in:
Denis Merigoux 2018-08-28 11:40:34 +02:00 committed by Eduard-Mihai Burtescu
parent d577ec7e5f
commit 3889c2dcfb
4 changed files with 26 additions and 9 deletions

View file

@ -18,7 +18,7 @@ use rustc::ty::TyCtxt;
use rustc::ty::layout::{Align, Size}; use rustc::ty::layout::{Align, Size};
use rustc::session::{config, Session}; use rustc::session::{config, Session};
use rustc_data_structures::small_c_str::SmallCStr; use rustc_data_structures::small_c_str::SmallCStr;
use interfaces::BuilderMethods; use interfaces::{BuilderMethods, Backend};
use syntax; use syntax;
use std::borrow::Cow; use std::borrow::Cow;
@ -55,11 +55,13 @@ bitflags! {
} }
} }
impl BuilderMethods<'a, 'll, 'tcx> for Builder<'a, 'll, 'tcx> { impl Backend for Builder<'a, 'll, 'tcx> {
type Value = &'ll Value; type Value = &'ll Value;
type BasicBlock = &'ll BasicBlock; type BasicBlock = &'ll BasicBlock;
type Type = &'ll type_::Type; type Type = &'ll type_::Type;
}
impl BuilderMethods<'a, 'll, 'tcx> for Builder<'a, 'll, 'tcx> {
fn new_block<'b>( fn new_block<'b>(
cx: &'a CodegenCx<'ll, 'tcx>, cx: &'a CodegenCx<'ll, 'tcx>,
llfn: &'ll Value, llfn: &'ll Value,

View file

@ -0,0 +1,15 @@
// 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.
pub trait Backend {
type Value;
type BasicBlock;
type Type;
}

View file

@ -14,6 +14,7 @@ use rustc::ty::TyCtxt;
use rustc::ty::layout::{Align, Size}; use rustc::ty::layout::{Align, Size};
use rustc::session::Session; use rustc::session::Session;
use builder::MemFlags; use builder::MemFlags;
use super::backend::Backend;
use std::borrow::Cow; use std::borrow::Cow;
use std::ops::Range; use std::ops::Range;
@ -21,10 +22,7 @@ use syntax::ast::AsmDialect;
pub trait BuilderMethods<'a, 'll :'a, 'tcx: 'll> { pub trait BuilderMethods<'a, 'll :'a, 'tcx: 'll> : Backend {
type Value;
type BasicBlock;
type Type;
fn new_block<'b>( fn new_block<'b>(
cx: &'a CodegenCx<'ll, 'tcx, Self::Value>, cx: &'a CodegenCx<'ll, 'tcx, Self::Value>,

View file

@ -9,5 +9,7 @@
// except according to those terms. // except according to those terms.
mod builder; mod builder;
mod backend;
pub use self::builder::BuilderMethods; pub use self::builder::BuilderMethods;
pub use self::backend::Backend;