Combine VisibleTranslationState and TranslationState (#1076)

`VisibleTranslationState` was a wrapper around a `TranslationState` that was
meant to public API consumers outside of this crate. However, the internal
`TranslationState` and all its methods were still publicly exposed! This commit
simplifies and remedies the situation by combining them into a single
`TranslationState` type. Most of its methods are only `pub(crate)` now, not
visible to the entire world. The only methods that are `pub` are the ones that
`VisibleTranslationState` exposed.
This commit is contained in:
Nick Fitzgerald
2019-09-25 12:07:54 -07:00
committed by Sean Stangl
parent 46ab1b4103
commit 8c3072c774
4 changed files with 42 additions and 50 deletions

View File

@@ -6,7 +6,7 @@
use crate::code_translator::translate_operator;
use crate::environ::{FuncEnvironment, ReturnMode, WasmResult};
use crate::state::{TranslationState, VisibleTranslationState};
use crate::state::TranslationState;
use crate::translation_utils::get_vmctx_value_label;
use crate::wasm_unsupported;
use cranelift_codegen::entity::EntityRef;
@@ -215,9 +215,9 @@ fn parse_function_body<FE: FuncEnvironment + ?Sized>(
while !state.control_stack.is_empty() {
builder.set_srcloc(cur_srcloc(&reader));
let op = reader.read_operator()?;
environ.before_translate_operator(&op, builder, &VisibleTranslationState::new(state))?;
environ.before_translate_operator(&op, builder, state)?;
translate_operator(&op, builder, state, environ)?;
environ.after_translate_operator(&op, builder, &VisibleTranslationState::new(state))?;
environ.after_translate_operator(&op, builder, state)?;
}
// The final `End` operator left us in the exit block where we need to manually add a return