(
&mut self,
class: GcRefLock<'gc, Class<'gc>>,
name: InternedString<'gc>,
)
| 1259 | } |
| 1260 | |
| 1261 | fn bind_method( |
| 1262 | &mut self, |
| 1263 | class: GcRefLock<'gc, Class<'gc>>, |
| 1264 | name: InternedString<'gc>, |
| 1265 | ) -> Result<(), VmError> { |
| 1266 | if let Some(method) = class.borrow().methods.get(&name) { |
| 1267 | let bound = BoundMethod::new(*self.peek(0), (*method).as_closure()?); |
| 1268 | // pop the instance and replace the top of |
| 1269 | // the stack with the bound method. |
| 1270 | self.pop_stack(); |
| 1271 | self.push_stack(Value::from(Gc::new(self.mc, bound))); |
| 1272 | Ok(()) |
| 1273 | } else { |
| 1274 | Err(self.runtime_error(format!("Undefined property '{}'.", name).into())) |
| 1275 | } |
| 1276 | } |
| 1277 | |
| 1278 | pub(crate) fn call_constructor( |
| 1279 | &mut self, |
no test coverage detected