MCPcopy Index your code
hub / github.com/aiscriptdev/aiscript / bind_method

Method bind_method

aiscript-vm/src/vm/state.rs:1261–1276  ·  view source on GitHub ↗
(
        &mut self,
        class: GcRefLock<'gc, Class<'gc>>,
        name: InternedString<'gc>,
    )

Source from the content-addressed store, hash-verified

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,

Callers 1

dispatch_nextMethod · 0.80

Calls 7

as_closureMethod · 0.80
pop_stackMethod · 0.80
push_stackMethod · 0.80
runtime_errorMethod · 0.80
getMethod · 0.45
borrowMethod · 0.45
peekMethod · 0.45

Tested by

no test coverage detected