Skip to content

Commit 3c949ef

Browse files
author
梶塚太智
committed
It became can modify the property of object
1 parent eb847d1 commit 3c949ef

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/main.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,6 +1062,23 @@ impl Executor {
10621062
}
10631063
}
10641064

1065+
// Modify the property of object
1066+
"modify" => {
1067+
let data = self.pop_stack();
1068+
let property = self.pop_stack().get_string();
1069+
match self.pop_stack() {
1070+
Type::Object(name, mut value) => {
1071+
value
1072+
.entry(property)
1073+
.and_modify(|value| *value = data.clone())
1074+
.or_insert(data.clone());
1075+
1076+
self.stack.push(Type::Object(name, value))
1077+
}
1078+
_ => self.stack.push(Type::Error("not-object".to_string())),
1079+
}
1080+
}
1081+
10651082
// Get all of properties
10661083
"all" => match self.pop_stack() {
10671084
Type::Object(_, data) => self.stack.push(Type::List(

0 commit comments

Comments
 (0)