Skip to content

Commit

Permalink
Merge pull request #8 from badboy/updated-nightly
Browse files Browse the repository at this point in the history
Update code to work with nightly 2016-06-04
  • Loading branch information
brson authored Jun 17, 2016
2 parents 8eca1da + 64c3d8a commit d50518a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ An experimental compiler from [Rust] to [WebAssembly], based on rustc + Rust [MI
I recommend that you install [rustup] and then use it to
install the current rustc nightly version:

**Tested with nightly 2016-06-04**

```sh
git clone https://github.com/brson/mir2wasm.git
cd mir2wasm
Expand Down
2 changes: 1 addition & 1 deletion src/bin/mir2wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl<'a> CompilerCalls<'a> for MiriCompilerCalls {
control.after_analysis.stop = rustc_driver::Compilation::Stop;
control.after_analysis.callback = Box::new(|state| {
state.session.abort_if_errors();
trans::trans_crate(state.tcx.unwrap(), state.mir_map.unwrap())
trans::trans_crate(&state.tcx.unwrap(), state.mir_map.unwrap())
.unwrap(); // FIXME
});

Expand Down
10 changes: 5 additions & 5 deletions src/monomorphize.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use rustc::ty::subst::{Subst, Substs};
use rustc::ty::{TyCtxt, TypeFoldable};
use rustc::infer::normalize_associated_type;
use rustc::infer::TransNormalize;

pub fn apply_param_substs<'tcx,T>(tcx: &TyCtxt<'tcx>,
pub fn apply_param_substs<'a, 'tcx,T>(tcx: &TyCtxt<'a, 'tcx, 'tcx>,
param_substs: &Substs<'tcx>,
value: &T)
-> T
where T : TypeFoldable<'tcx>
where T : TypeFoldable<'tcx> + TransNormalize<'tcx>
{
let substituted = value.subst(tcx, param_substs);
normalize_associated_type(tcx, &substituted)
let substituted = value.subst(*tcx, param_substs);
tcx.normalize_associated_type(&substituted)
}
10 changes: 5 additions & 5 deletions src/trans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use std::collections::HashMap;
use binaryen::*;
use monomorphize;

pub fn trans_crate<'tcx>(tcx: &TyCtxt<'tcx>,
pub fn trans_crate<'a, 'tcx>(tcx: &TyCtxt<'a, 'tcx, 'tcx>,
mir_map: &MirMap<'tcx>) -> Result<()> {

let _ignore = tcx.dep_graph.in_ignore();
Expand All @@ -40,7 +40,7 @@ pub fn trans_crate<'tcx>(tcx: &TyCtxt<'tcx>,
}

struct BinaryenModuleCtxt<'v, 'tcx: 'v> {
tcx: &'v TyCtxt<'tcx>,
tcx: &'v TyCtxt<'v, 'tcx, 'tcx>,
mir_map: &'v MirMap<'tcx>,
module: BinaryenModuleRef,
fun_types: HashMap<ty::FnSig<'tcx>, BinaryenFunctionTypeRef>,
Expand Down Expand Up @@ -84,7 +84,7 @@ impl<'v, 'tcx> Visitor<'v> for BinaryenModuleCtxt<'v, 'tcx> {
}

struct BinaryenFnCtxt<'v, 'tcx: 'v> {
tcx: &'v TyCtxt<'tcx>,
tcx: &'v TyCtxt<'v, 'tcx, 'tcx>,
mir_map: &'v MirMap<'tcx>,
mir: &'v Mir<'tcx>,
did: DefId,
Expand Down Expand Up @@ -316,8 +316,8 @@ impl<'v, 'tcx: 'v> BinaryenFnCtxt<'v, 'tcx> {
match *operand {
Operand::Consume(ref lvalue) => {
let (i, _) = self.trans_lval(lvalue);
let lval_ty = self.mir.lvalue_ty(self.tcx, lvalue);
let t = lval_ty.to_ty(self.tcx);
let lval_ty = self.mir.lvalue_ty(*self.tcx, lvalue);
let t = lval_ty.to_ty(*self.tcx);
let t = rust_ty_to_binaryen(t);
unsafe { BinaryenGetLocal(self.module, i, t) }
}
Expand Down

0 comments on commit d50518a

Please sign in to comment.