Message sending

This commit is contained in:
Tony Garnock-Jones 2021-10-07 21:28:47 +02:00
parent 3c106dcb86
commit 0837606ca7
1 changed files with 16 additions and 0 deletions

View File

@ -50,6 +50,10 @@ pub enum Instruction {
target: String,
template: AnyValue,
},
Message {
target: String,
template: AnyValue,
},
React {
target: String,
pattern_template: AnyValue,
@ -375,6 +379,9 @@ impl Env {
Instruction::Assert { target, template } => {
self.lookup_target(target)?.assert(t, &(), &self.instantiate_value(template)?);
}
Instruction::Message { target, template } => {
self.lookup_target(target)?.message(t, &(), &self.instantiate_value(template)?);
}
Instruction::React { target, pattern_template, body } => {
let (binding_names, pattern) = self.instantiate_pattern(pattern_template)?;
let observer = during::entity(self.clone())
@ -697,6 +704,15 @@ impl<'t> Parser<'t> {
} else {
return self.error("Invalid let statement");
}
} else if s == "!" {
self.drop();
if self.ateof() {
return self.error("Missing payload after '!'");
}
return Parsed::Value(Instruction::Message {
target: target.to_owned(),
template: self.shift(),
});
} else {
/* fall through */
}