diff --git a/src/protocol/mod.rs b/src/protocol/mod.rs index af9724fc4040d2aae15a500acdfcc49b4f73c19b..62481340e1b64cfaf42180b4dc1041409f4d733b 100644 --- a/src/protocol/mod.rs +++ b/src/protocol/mod.rs @@ -174,7 +174,7 @@ impl ProtocolDescription { let module_root = module_root.unwrap(); let root = &self.heap[module_root]; - let definition_id = root.get_definition_ident(&heap, identifier); + let definition_id = root.get_definition_ident(&self.heap, identifier); if definition_id.is_none() { return Err(ComponentCreationError::DefinitionDoesntExist); } @@ -210,7 +210,7 @@ impl ProtocolDescription { // By now we're sure that all of the arguments are correct. So create // the connector. return Ok(ComponentState{ - prompt: Prompt::new(&self.types, &self.heap, def, 0, arguments), + prompt: Prompt::new(&self.types, &self.heap, definition_id, 0, arguments), }); } @@ -232,24 +232,18 @@ impl ProtocolDescription { fn verify_same_type(&self, expected: &ConcreteType, expected_idx: usize, arguments: &ValueGroup, argument: &Value) -> bool { use ConcreteTypePart as CTP; - macro_rules! match_variant { - ($value:expr, $variant:expr) => { - if let $variant(_) = $value { true } else { false } - }; - } - match &expected.parts[expected_idx] { CTP::Void | CTP::Message | CTP::Slice | CTP::Function(_, _) | CTP::Component(_, _) => unreachable!(), - CTP::Bool => match_variant!(argument, Value::Bool), - CTP::UInt8 => match_variant!(argument, Value::UInt8), - CTP::UInt16 => match_variant!(argument, Value::UInt16), - CTP::UInt32 => match_variant!(argument, Value::UInt32), - CTP::UInt64 => match_variant!(argument, Value::UInt64), - CTP::SInt8 => match_variant!(argument, Value::SInt8), - CTP::SInt16 => match_variant!(argument, Value::SInt16), - CTP::SInt32 => match_variant!(argument, Value::SInt32), - CTP::SInt64 => match_variant!(argument, Value::SInt64), - CTP::Character => match_variant!(argument, Value::Char), + CTP::Bool => if let Value::Bool(_) = argument { true } else { false }, + CTP::UInt8 => if let Value::UInt8(_) = argument { true } else { false }, + CTP::UInt16 => if let Value::UInt16(_) = argument { true } else { false }, + CTP::UInt32 => if let Value::UInt32(_) = argument { true } else { false }, + CTP::UInt64 => if let Value::UInt64(_) = argument { true } else { false }, + CTP::SInt8 => if let Value::SInt8(_) = argument { true } else { false }, + CTP::SInt16 => if let Value::SInt16(_) = argument { true } else { false }, + CTP::SInt32 => if let Value::SInt32(_) = argument { true } else { false }, + CTP::SInt64 => if let Value::SInt64(_) = argument { true } else { false }, + CTP::Character => if let Value::Char(_) = argument { true } else { false }, CTP::String => { // Match outer string type and embedded character types if let Value::String(heap_pos) = argument { @@ -277,8 +271,8 @@ impl ProtocolDescription { return false; } }, - CTP::Input => match_variant!(argument, Value::Input), - CTP::Output => match_variant!(argument, Value::Output), + CTP::Input => if let Value::Input(_) = argument { true } else { false }, + CTP::Output => if let Value::Output(_) = argument { true } else { false }, CTP::Instance(_definition_id, _num_embedded) => { todo!("implement full type checking on user-supplied arguments"); return false;