KrkClosure Struct Reference
Function object. More...
#include <object.h>
Inheritance diagram for KrkClosure:

Public Member Functions | |
| KrkInstance * | krk_buildGenerator (KrkClosure *function, KrkValue *arguments, size_t argCount) |
| Convert a function into a generator with the given arguments. More... | |
| KrkClosure * | krk_newClosure (KrkCodeObject *function, KrkValue globals) |
| Create a new function object. More... | |
Data Fields | |
| KrkCodeObject * | function |
| The codeobject containing the bytecode run when this function is called. | |
| KrkUpvalue ** | upvalues |
| Array of upvalues collected from the surrounding context when the closure was created. | |
| size_t | upvalueCount |
| Number of entries in upvalues. | |
| KrkValue | annotations |
| Dictionary of type hints. | |
| KrkTable | fields |
| Object attributes table. | |
| KrkValue | globalsOwner |
| Owner of the globals table for this function. | |
| KrkTable * | globalsTable |
| Pointer to globals table with owner object. | |
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 KrkObj * | next |
| Invasive linked list of all objects in the VM. | |
Protected Attributes | |
| KrkObj | obj |
| Base. | |
Detailed Description
Function object.
Not to be confused with code objects, a closure is a single instance of a function.
Member Function Documentation
◆ krk_buildGenerator()
| KrkInstance * krk_buildGenerator | ( | KrkClosure * | function, |
| KrkValue * | arguments, | ||
| size_t | argCount | ||
| ) |
Convert a function into a generator with the given arguments.
Converts the function function to a generator object and provides it arguments (of length argCount) as its initial arguments. The generator object is returned.
- Parameters
-
function Function to convert. arguments Arguments to pass to the generator. argCount Number of arguments in arguments
- Returns
- A new generator object.
◆ krk_newClosure()
| KrkClosure * krk_newClosure | ( | KrkCodeObject * | function, |
| KrkValue | globals | ||
| ) |
Create a new function object.
Function objects are the callable first-class objects representing functions in managed code. Each function object has an associated code object, which may be sured with other function objects, such as when a function is used to create a closure.
- Parameters
-
function Code object to assign to the new function object.
The documentation for this struct was generated from the following file:
- src/kuroko/object.h
Data Fields inherited from