25 return OBJECT_VAL(AS_CLASS(val)->name);
26 }
else if (IS_STRING(val)) {
28 }
else if (IS_TUPLE(val)) {
32 for (
size_t i = 0; i < AS_TUPLE(val)->values.count; ++i) {
33 krk_push(typeToString(AS_TUPLE(val)->values.values[i]));
34 pushStringBuilderStr(&sb, AS_CSTRING(
krk_peek(0)), AS_STRING(
krk_peek(0))->length);
36 if (i < AS_TUPLE(val)->values.count - 1) {
37 pushStringBuilder(&sb,
',');
41 return finishStringBuilder(&sb);
50 KRK_Function(__class_getitem__) {
51 FUNCTION_TAKES_EXACTLY(2);
52 if (!IS_CLASS(argv[0]))
return TYPE_ERROR(
class,argv[0]);
57 pushStringBuilderStr(&sb, AS_CLASS(argv[0])->name->chars, AS_CLASS(argv[0])->name->length);
58 pushStringBuilder(&sb,
'[');
61 pushStringBuilderStr(&sb, AS_CSTRING(
krk_peek(0)), AS_STRING(
krk_peek(0))->length);
63 pushStringBuilder(&sb,
']');
64 return finishStringBuilder(&sb);
NativeFn krk_GenericAlias
Special value for type hint expressions.
KrkObj * _reprer
__repr__ Called to create a reproducible string representation of an instance
Stack reference or primative value.
KrkClass * krk_getType(KrkValue value)
Get the class representing a value.
Inline flexible string array.
Utilities for creating native bindings.
Definitions for primitive stack references.
Core API for the bytecode virtual machine.
KrkValue krk_pop(void)
Pop the top of the stack.
void krk_push(KrkValue value)
Push a stack value.
KrkValue krk_callDirect(KrkObj *callable, int argCount)
Call a closure or native function with argCount arguments.
KrkValue krk_peek(int distance)
Peek down from the top of the stack.