KrkBoundMethod Struct Reference

A function that has been attached to an object to serve as a method. More...

#include <object.h>

Inheritance diagram for KrkBoundMethod:

Public Member Functions

KrkBoundMethodkrk_newBoundMethod (KrkValue receiver, KrkObj *method)
 Create a new bound method. More...
 

Data Fields

KrkValue receiver
 Object to pass as implicit first argument.
 
KrkObjmethod
 Function to call.
 
- Data Fields inherited from KrkObj
uint16_t type
 Tag indicating core type.
 
uint16_t flags
 General object flags, mostly related to garbage collection.
 
uint32_t hash
 Cached hash value for table keys.
 
struct KrkObjnext
 Invasive linked list of all objects in the VM.
 

Protected Attributes

KrkObj obj
 Base.
 

Detailed Description

A function that has been attached to an object to serve as a method.

When a bound method is called, its receiver is implicitly extracted as the first argument. Bound methods are created whenever a method is retreived from the class of a value.

Definition at line 295 of file object.h.

Member Function Documentation

◆ krk_newBoundMethod()

KrkBoundMethod * krk_newBoundMethod ( KrkValue  receiver,
KrkObj method 
)

Create a new bound method.

Binds the callable specified by method to the value receiver and returns a method object. When a method object is called, receiver will automatically be provided as the first argument.

Definition at line 350 of file object.c.


The documentation for this struct was generated from the following file: