mirror of
https://github.com/fluencelabs/parity-wasm
synced 2025-06-26 21:22:13 +00:00
module level validation
This commit is contained in:
@ -32,6 +32,7 @@ pub struct VariableInstance {
|
||||
impl VariableInstance {
|
||||
/// New variable instance
|
||||
pub fn new(is_mutable: bool, variable_type: VariableType, value: RuntimeValue) -> Result<Self, Error> {
|
||||
// TODO: there is nothing about null value in specification + there is nothing about initializing missing table elements? => runtime check for nulls
|
||||
if !value.is_null() && value.variable_type() != Some(variable_type) {
|
||||
return Err(Error::Variable(format!("trying to initialize variable of type {:?} with value of type {:?}", variable_type, value.variable_type())));
|
||||
}
|
||||
@ -48,6 +49,11 @@ impl VariableInstance {
|
||||
Self::new(global_type.is_mutable(), global_type.content_type().into(), value)
|
||||
}
|
||||
|
||||
/// Is mutable
|
||||
pub fn is_mutable(&self) -> bool {
|
||||
self.is_mutable
|
||||
}
|
||||
|
||||
/// Get the value of the variable instance
|
||||
pub fn get(&self) -> RuntimeValue {
|
||||
self.value.read().clone()
|
||||
|
Reference in New Issue
Block a user