(&mut self, name: InternedString<'gc>, is_static: bool)
| 1227 | } |
| 1228 | |
| 1229 | fn define_method(&mut self, name: InternedString<'gc>, is_static: bool) -> Result<(), VmError> { |
| 1230 | match *self.peek(1) { |
| 1231 | Value::Class(class) => { |
| 1232 | let mut c = class.borrow_mut(self.mc); |
| 1233 | if is_static { |
| 1234 | c.static_methods.insert(name, *self.peek(0)); |
| 1235 | } else { |
| 1236 | c.methods.insert(name, *self.peek(0)); |
| 1237 | } |
| 1238 | } |
| 1239 | Value::Enum(enum_) => { |
| 1240 | let mut e = enum_.borrow_mut(self.mc); |
| 1241 | if is_static { |
| 1242 | e.static_methods.insert(name, *self.peek(0)); |
| 1243 | } else { |
| 1244 | e.methods.insert(name, *self.peek(0)); |
| 1245 | } |
| 1246 | } |
| 1247 | _ => { |
| 1248 | return Err(self.runtime_error("Only class and enum support define method.".into())); |
| 1249 | } |
| 1250 | } |
| 1251 | // pop the closure since we’re done with it. |
| 1252 | self.pop_stack(); |
| 1253 | Ok(()) |
| 1254 | } |
| 1255 | |
| 1256 | pub(crate) fn define_native_function(&mut self, name: &'static str, function: NativeFn<'gc>) { |
| 1257 | let s = self.intern_static(name); |
no test coverage detected