Renamings.

This commit is contained in:
Sergey Pepyakin 2019-04-15 20:17:44 +02:00
parent 0b11d665aa
commit 9935df3307
6 changed files with 24 additions and 22 deletions

View File

@ -112,7 +112,6 @@ extern crate core;
#[cfg(test)]
extern crate wabt;
#[cfg(test)]
#[macro_use]
extern crate assert_matches;
#[cfg(not(feature = "std"))]

View File

@ -8,7 +8,7 @@ use validation::func::{
};
use validation::stack::StackWithLimit;
use validation::util::Locals;
use validation::{Error, FunctionValidator};
use validation::{Error, FuncValidator};
use isa;
@ -67,7 +67,7 @@ pub struct Compiler {
label_stack: Vec<BlockFrameType>,
}
impl FunctionValidator for Compiler {
impl FuncValidator for Compiler {
type Output = isa::Instructions;
fn new(_module: &FunctionValidationContext) -> Self {
let mut compiler = Compiler {

View File

@ -26,7 +26,7 @@ pub struct WasmiValidation {
// validation time.
impl Validation for WasmiValidation {
type Output = Vec<isa::Instructions>;
type FunctionValidator = compile::Compiler;
type FuncValidator = compile::Compiler;
fn new(_module: &Module) -> Self {
WasmiValidation {
// TODO: with capacity?

View File

@ -2,7 +2,7 @@
use alloc::prelude::v1::*;
use crate::{
context::ModuleContext, stack::StackWithLimit, util::Locals, Error, FunctionValidator,
context::ModuleContext, stack::StackWithLimit, util::Locals, Error, FuncValidator,
DEFAULT_MEMORY_INDEX, DEFAULT_TABLE_INDEX,
};
@ -99,7 +99,7 @@ impl PartialEq<StackValueType> for ValueType {
}
}
pub fn drive<T: FunctionValidator>(
pub fn drive<T: FuncValidator>(
module: &ModuleContext,
func: &Func,
body: &FuncBody,

View File

@ -79,17 +79,17 @@ impl From<stack::Error> for Error {
pub trait Validation {
type Output;
type FunctionValidator: FunctionValidator;
type FuncValidator: FuncValidator;
fn new(module: &Module) -> Self;
fn on_function_validated(
&mut self,
index: u32,
output: <<Self as Validation>::FunctionValidator as FunctionValidator>::Output,
output: <<Self as Validation>::FuncValidator as FuncValidator>::Output,
);
fn finish(self) -> Self::Output;
}
pub trait FunctionValidator {
pub trait FuncValidator {
type Output;
fn new(ctx: &func::FunctionValidationContext) -> Self;
fn next_instruction(
@ -100,19 +100,19 @@ pub trait FunctionValidator {
fn finish(self) -> Self::Output;
}
pub struct SimpleValidation;
pub struct SimpleFunctionValidator;
/// A module validator that just validates modules and produces no result.
pub struct PlainValidator;
impl Validation for SimpleValidation {
impl Validation for PlainValidator {
type Output = ();
type FunctionValidator = SimpleFunctionValidator;
fn new(_module: &Module) -> SimpleValidation {
SimpleValidation
type FuncValidator = PlainFuncValidator;
fn new(_module: &Module) -> PlainValidator {
PlainValidator
}
fn on_function_validated(
&mut self,
_index: u32,
_output: <<Self as Validation>::FunctionValidator as FunctionValidator>::Output,
_output: <<Self as Validation>::FuncValidator as FuncValidator>::Output,
) -> () {
()
}
@ -121,11 +121,14 @@ impl Validation for SimpleValidation {
}
}
impl FunctionValidator for SimpleFunctionValidator {
/// A function validator that just validates modules and produces no result.
pub struct PlainFuncValidator;
impl FuncValidator for PlainFuncValidator {
type Output = ();
fn new(_ctx: &func::FunctionValidationContext) -> SimpleFunctionValidator {
SimpleFunctionValidator
fn new(_ctx: &func::FunctionValidationContext) -> PlainFuncValidator {
PlainFuncValidator
}
fn next_instruction(
@ -232,7 +235,7 @@ pub fn validate_module<V: Validation>(module: &Module) -> Result<V::Output, Erro
.get(index as usize)
.ok_or(Error(format!("Missing body for function {}", index)))?;
let output = func::drive::<V::FunctionValidator>(&context, function, function_body)
let output = func::drive::<V::FuncValidator>(&context, function, function_body)
.map_err(|Error(ref msg)| {
Error(format!(
"Function #{} reading/validation error: {}",

View File

@ -1,4 +1,4 @@
use crate::{Error, SimpleValidation};
use crate::{Error, PlainValidator};
use parity_wasm::builder::module;
use parity_wasm::elements::{
BlockType, External, GlobalEntry, GlobalType, ImportEntry, InitExpr, Instruction, Instructions,
@ -6,7 +6,7 @@ use parity_wasm::elements::{
};
fn validate_module(module: &Module) -> Result<(), Error> {
super::validate_module::<SimpleValidation>(module)
super::validate_module::<PlainValidator>(module)
}
#[test]