diff --git a/src/builtins.c b/src/builtins.c index 1533cf4..88d30b1 100644 --- a/src/builtins.c +++ b/src/builtins.c @@ -12,7 +12,7 @@ static KrkClass * property; FUNC_SIG(list,__init__); FUNC_SIG(list,sort); -KrkValue krk_dirObject(int argc, KrkValue argv[], int hasKw) { +KrkValue krk_dirObject(int argc, const KrkValue argv[], int hasKw) { if (argc != 1) return krk_runtimeError(vm.exceptions->argumentError, "%s() takes %s %d argument%s (%d given)", "dir", "exactly", 1, "", argc); @@ -679,7 +679,7 @@ KRK_FUNC(issubclass,{ } }) -static KrkValue _module_repr(int argc, KrkValue argv[], int hasKw) { +static KrkValue _module_repr(int argc, const KrkValue argv[], int hasKw) { KrkInstance * self = AS_INSTANCE(argv[0]); KrkValue name = NONE_VAL(); @@ -706,7 +706,7 @@ static KrkValue _module_repr(int argc, KrkValue argv[], int hasKw) { return out; } -static KrkValue obj_hash(int argc, KrkValue argv[], int hasKw) { +static KrkValue obj_hash(int argc, const KrkValue argv[], int hasKw) { KrkObj * self = AS_OBJECT(argv[0]); if (!(self->flags & KRK_OBJ_FLAGS_VALID_HASH)) { self->hash = INTEGER_VAL((int)(intptr_t)self); @@ -715,7 +715,7 @@ static KrkValue obj_hash(int argc, KrkValue argv[], int hasKw) { return INTEGER_VAL(self->hash); } -static KrkValue obj_eq(int argc, KrkValue argv[], int hasKw) { +static KrkValue obj_eq(int argc, const KrkValue argv[], int hasKw) { return BOOLEAN_VAL(argc == 2 && IS_OBJECT(argv[0]) && IS_OBJECT(argv[1]) && AS_OBJECT(argv[0]) == AS_OBJECT(argv[1])); } @@ -732,7 +732,7 @@ static KrkValue obj_eq(int argc, KrkValue argv[], int hasKw) { * all types should have a string representation available through * those methods. */ -static KrkValue _strBase(int argc, KrkValue argv[], int hasKw) { +static KrkValue _strBase(int argc, const KrkValue argv[], int hasKw) { KrkClass * type = krk_getType(argv[0]); KrkValue module = NONE_VAL(); diff --git a/src/exceptions.c b/src/exceptions.c index 16646bb..e54403b 100644 --- a/src/exceptions.c +++ b/src/exceptions.c @@ -26,7 +26,7 @@ * * @param arg Optional string to attach to the exception object. */ -static KrkValue krk_initException(int argc, KrkValue argv[], int hasKw) { +static KrkValue krk_initException(int argc, const KrkValue argv[], int hasKw) { KrkInstance * self = AS_INSTANCE(argv[0]); krk_attachNamedValue(&self->fields, "arg", argc > 1 ? argv[1] : NONE_VAL()); return argv[0]; @@ -39,7 +39,7 @@ static KrkValue krk_initException(int argc, KrkValue argv[], int hasKw) { * * Generates a string representation of the form @c "Exception(arg)" . */ -static KrkValue _exception_repr(int argc, KrkValue argv[], int hasKw) { +static KrkValue _exception_repr(int argc, const KrkValue argv[], int hasKw) { KrkInstance * self = AS_INSTANCE(argv[0]); KrkValue arg; struct StringBuilder sb = {0}; @@ -67,7 +67,7 @@ static KrkValue _exception_repr(int argc, KrkValue argv[], int hasKw) { * For most exceptions, this is the 'arg' value attached at initialization * and is printed during a traceback after the name of the exception type. */ -static KrkValue _exception_str(int argc, KrkValue argv[], int hasKw) { +static KrkValue _exception_str(int argc, const KrkValue argv[], int hasKw) { KrkInstance * self = AS_INSTANCE(argv[0]); KrkValue arg; if (!krk_tableGet(&self->fields, OBJECT_VAL(S("arg")), &arg) || IS_NONE(arg)) { @@ -91,7 +91,7 @@ static KrkValue _exception_str(int argc, KrkValue argv[], int hasKw) { * {str(Exception)} for syntax errors and they handle the rest. This is a bit * of a kludge, but it works for now. */ -static KrkValue _syntaxerror_str(int argc, KrkValue argv[], int hasKw) { +static KrkValue _syntaxerror_str(int argc, const KrkValue argv[], int hasKw) { KrkInstance * self = AS_INSTANCE(argv[0]); /* .arg */ KrkValue file, line, lineno, colno, arg, func; diff --git a/src/kuroko/object.h b/src/kuroko/object.h index d1a2eb3..0e63f47 100644 --- a/src/kuroko/object.h +++ b/src/kuroko/object.h @@ -239,7 +239,7 @@ typedef struct { KrkObj * method; /**< @brief Function to call */ } KrkBoundMethod; -typedef KrkValue (*NativeFn)(int argCount, KrkValue* args, int hasKwargs); +typedef KrkValue (*NativeFn)(int argCount, const KrkValue* args, int hasKwargs); /** * @brief Managed binding to a C function. diff --git a/src/kuroko/util.h b/src/kuroko/util.h index e257f36..ccd1322 100644 --- a/src/kuroko/util.h +++ b/src/kuroko/util.h @@ -63,14 +63,14 @@ ctype name __attribute__((unused)) = AS_ ## type (argv[i]) #define FUNC_NAME(klass, name) _ ## klass ## _ ## name -#define FUNC_SIG(klass, name) _noexport KrkValue FUNC_NAME(klass,name) (int argc, KrkValue argv[], int hasKw) +#define FUNC_SIG(klass, name) _noexport KrkValue FUNC_NAME(klass,name) (int argc, const KrkValue argv[], int hasKw) #define KRK_METHOD(klass, name, ...) FUNC_SIG(klass, name) { \ static __attribute__ ((unused)) const char* _method_name = # name; \ CHECK_ARG(0,klass,CURRENT_CTYPE,CURRENT_NAME); \ __VA_ARGS__ \ return NONE_VAL(); } -#define KRK_FUNC(name,...) static KrkValue _krk_ ## name (int argc, KrkValue argv[], int hasKw) { \ +#define KRK_FUNC(name,...) static KrkValue _krk_ ## name (int argc, const KrkValue argv[], int hasKw) { \ static __attribute__ ((unused)) const char* _method_name = # name; \ __VA_ARGS__ \ return NONE_VAL(); } @@ -222,11 +222,11 @@ static inline KrkValue discardStringBuilder(struct StringBuilder * sb) { #endif extern KrkValue krk_dict_nth_key_fast(size_t capacity, KrkTableEntry * entries, size_t index); -extern KrkValue FUNC_NAME(str,__getitem__)(int,KrkValue*,int); -extern KrkValue FUNC_NAME(str,__int__)(int,KrkValue*,int); -extern KrkValue FUNC_NAME(str,__float__)(int,KrkValue*,int); -extern KrkValue FUNC_NAME(str,split)(int,KrkValue*,int); -extern KrkValue FUNC_NAME(str,format)(int,KrkValue*,int); +extern KrkValue FUNC_NAME(str,__getitem__)(int,const KrkValue*,int); +extern KrkValue FUNC_NAME(str,__int__)(int,const KrkValue*,int); +extern KrkValue FUNC_NAME(str,__float__)(int,const KrkValue*,int); +extern KrkValue FUNC_NAME(str,split)(int,const KrkValue*,int); +extern KrkValue FUNC_NAME(str,format)(int,const KrkValue*,int); #define krk_string_get FUNC_NAME(str,__getitem__) #define krk_string_int FUNC_NAME(str,__int__) #define krk_string_float FUNC_NAME(str,__float__) diff --git a/src/kuroko/vm.h b/src/kuroko/vm.h index 4710f9e..d89df59 100644 --- a/src/kuroko/vm.h +++ b/src/kuroko/vm.h @@ -604,7 +604,7 @@ extern int krk_callValue(KrkValue callee, int argCount, int callableOnStack); * * This is the native function bound to @c listOf */ -extern KrkValue krk_list_of(int argc, KrkValue argv[], int hasKw); +extern KrkValue krk_list_of(int argc, const KrkValue argv[], int hasKw); /** * @brief Create a dict object. @@ -612,7 +612,7 @@ extern KrkValue krk_list_of(int argc, KrkValue argv[], int hasKw); * * This is the native function bound to @c dictOf */ -extern KrkValue krk_dict_of(int argc, KrkValue argv[], int hasKw); +extern KrkValue krk_dict_of(int argc, const KrkValue argv[], int hasKw); /** * @brief Create a tuple object. @@ -620,7 +620,7 @@ extern KrkValue krk_dict_of(int argc, KrkValue argv[], int hasKw); * * This is the native function bound to @c tupleOf */ -extern KrkValue krk_tuple_of(int argc, KrkValue argv[], int hasKw); +extern KrkValue krk_tuple_of(int argc, const KrkValue argv[], int hasKw); /** * @brief Create a set object. @@ -628,13 +628,13 @@ extern KrkValue krk_tuple_of(int argc, KrkValue argv[], int hasKw); * * This is the native function bound to @c setOf */ -extern KrkValue krk_set_of(int argc, KrkValue argv[], int hasKw); +extern KrkValue krk_set_of(int argc, const KrkValue argv[], int hasKw); /** * @brief Create a slice object. * @memberof KrkSlice */ -extern KrkValue krk_slice_of(int argc, KrkValue argv[], int hasKw); +extern KrkValue krk_slice_of(int argc, const KrkValue argv[], int hasKw); /** * @brief Call a callable on the stack with @p argCount arguments. @@ -720,7 +720,7 @@ extern KrkInstance * krk_startModule(const char * name); * * This is the native function bound to @c object.__dir__ */ -extern KrkValue krk_dirObject(int argc, KrkValue argv[], int hasKw); +extern KrkValue krk_dirObject(int argc, const KrkValue argv[], int hasKw); /** * @brief Load a module from a file with a specified name. @@ -860,4 +860,4 @@ extern void krk_setMaximumRecursionDepth(size_t maxDepth); * held stack is reallocated, it will be freed when execution returns to the call * to @c krk_callNativeOnStack that holds it. */ -KrkValue krk_callNativeOnStack(NativeFn native, size_t argCount, KrkValue *stackArgs, int hasKw); +KrkValue krk_callNativeOnStack(NativeFn native, size_t argCount, const KrkValue *stackArgs, int hasKw); diff --git a/src/modules/module_math.c b/src/modules/module_math.c index d68ddd1..37281e8 100644 --- a/src/modules/module_math.c +++ b/src/modules/module_math.c @@ -17,7 +17,8 @@ return NONE_VAL(); \ } -#define FORCE_FLOAT(arg) \ +#define FORCE_FLOAT(src,arg) \ + KrkValue arg = src; \ if (!IS_FLOATING(arg)) { switch (KRK_VAL_TYPE(arg)) { \ case KRK_VAL_INTEGER: arg = FLOATING_VAL(AS_INTEGER(arg)); break; \ case KRK_VAL_BOOLEAN: arg = FLOATING_VAL(AS_BOOLEAN(arg)); break; \ @@ -38,7 +39,7 @@ } #define MATH_DELEGATE(func) \ -static KrkValue _math_ ## func(int argc, KrkValue argv[], int hasKw) { \ +static KrkValue _math_ ## func(int argc, const KrkValue argv[], int hasKw) { \ ONE_ARGUMENT(func) \ if (IS_FLOATING(argv[0])) { \ return INTEGER_VAL(func(AS_FLOATING(argv[0]))); \ @@ -57,12 +58,12 @@ MATH_DELEGATE(floor) MATH_DELEGATE(trunc) #define MATH_ONE_NAME(func,name) \ -static KrkValue _math_ ## name(int argc, KrkValue argv[], int hasKw) { \ +static KrkValue _math_ ## name(int argc, const KrkValue argv[], int hasKw) { \ ONE_ARGUMENT(name) \ - FORCE_FLOAT(argv[0]) \ - if (IS_FLOATING(argv[0])) { \ - return FLOATING_VAL(func(AS_FLOATING(argv[0]))); \ - } else REAL_NUMBER_NOT(name,argv[0]) \ + FORCE_FLOAT(argv[0],arg_0) \ + if (IS_FLOATING(arg_0)) { \ + return FLOATING_VAL(func(AS_FLOATING(arg_0))); \ + } else REAL_NUMBER_NOT(name,arg_0) \ } #define MATH_ONE(func) MATH_ONE_NAME(func,func) @@ -93,13 +94,13 @@ MATH_ONE(lgamma) #endif #define MATH_TWO(func) \ -static KrkValue _math_ ## func(int argc, KrkValue argv[], int hasKw) { \ +static KrkValue _math_ ## func(int argc, const KrkValue argv[], int hasKw) { \ TWO_ARGUMENTS(func) \ - FORCE_FLOAT(argv[0]) \ - FORCE_FLOAT(argv[1]) \ - if (!IS_FLOATING(argv[0])) REAL_NUMBER_NOT(func,argv[0]) \ - if (!IS_FLOATING(argv[1])) REAL_NUMBER_NOT(func,argv[1]) \ - return FLOATING_VAL(func(AS_FLOATING(argv[0]),AS_FLOATING(argv[1]))); \ + FORCE_FLOAT(argv[0],arg_0) \ + FORCE_FLOAT(argv[1],arg_1) \ + if (!IS_FLOATING(arg_0)) REAL_NUMBER_NOT(func,arg_0) \ + if (!IS_FLOATING(arg_1)) REAL_NUMBER_NOT(func,arg_1) \ + return FLOATING_VAL(func(AS_FLOATING(arg_0),AS_FLOATING(arg_1))); \ } MATH_TWO(copysign) @@ -108,14 +109,14 @@ MATH_TWO(remainder) MATH_TWO(pow) MATH_TWO(atan2) -static KrkValue _math_frexp(int argc, KrkValue argv[], int hasKw) { +static KrkValue _math_frexp(int argc, const KrkValue argv[], int hasKw) { ONE_ARGUMENT(frexp) - FORCE_FLOAT(argv[0]) - if (!IS_FLOATING(argv[0])) { - REAL_NUMBER_NOT(frexp,argv[0]) + FORCE_FLOAT(argv[0],arg_0) + if (!IS_FLOATING(arg_0)) { + REAL_NUMBER_NOT(frexp,arg_0) } int exp = 0; - double result = frexp(AS_FLOATING(argv[0]), &exp); + double result = frexp(AS_FLOATING(arg_0), &exp); KrkTuple * outValue = krk_newTuple(2); outValue->values.values[0] = FLOATING_VAL(result); outValue->values.values[1] = INTEGER_VAL(exp); @@ -124,7 +125,7 @@ static KrkValue _math_frexp(int argc, KrkValue argv[], int hasKw) { } #define MATH_IS(func) \ -static KrkValue _math_ ## func(int argc, KrkValue argv[], int hasKw) { \ +static KrkValue _math_ ## func(int argc, const KrkValue argv[], int hasKw) { \ ONE_ARGUMENT(func) \ if (!IS_FLOATING(argv[0])) REAL_NUMBER_NOT(func,argv[0]) \ return BOOLEAN_VAL(func(AS_FLOATING(argv[0]))); \ diff --git a/src/obj_base.c b/src/obj_base.c index ccb5ab6..fd15fcf 100644 --- a/src/obj_base.c +++ b/src/obj_base.c @@ -4,37 +4,37 @@ #include #include -static KrkValue _type_init(int argc, KrkValue argv[], int hasKw) { +static KrkValue _type_init(int argc, const KrkValue argv[], int hasKw) { if (argc != 2) return krk_runtimeError(vm.exceptions->argumentError, "type() takes 1 argument"); return OBJECT_VAL(krk_getType(argv[1])); } /* Class.__base__ */ -static KrkValue krk_baseOfClass(int argc, KrkValue argv[], int hasKw) { +static KrkValue krk_baseOfClass(int argc, const KrkValue argv[], int hasKw) { if (!IS_CLASS(argv[0])) return krk_runtimeError(vm.exceptions->typeError, "expected class"); return AS_CLASS(argv[0])->base ? OBJECT_VAL(AS_CLASS(argv[0])->base) : NONE_VAL(); } /* Class.__name */ -static KrkValue krk_nameOfClass(int argc, KrkValue argv[], int hasKw) { +static KrkValue krk_nameOfClass(int argc, const KrkValue argv[], int hasKw) { if (!IS_CLASS(argv[0])) return krk_runtimeError(vm.exceptions->typeError, "expected class"); return AS_CLASS(argv[0])->name ? OBJECT_VAL(AS_CLASS(argv[0])->name) : NONE_VAL(); } /* Class.__file__ */ -static KrkValue krk_fileOfClass(int argc, KrkValue argv[], int hasKw) { +static KrkValue krk_fileOfClass(int argc, const KrkValue argv[], int hasKw) { if (!IS_CLASS(argv[0])) return krk_runtimeError(vm.exceptions->typeError, "expected class"); return AS_CLASS(argv[0])->filename ? OBJECT_VAL(AS_CLASS(argv[0])->filename) : NONE_VAL(); } /* Class.__doc__ */ -static KrkValue krk_docOfClass(int argc, KrkValue argv[], int hasKw) { +static KrkValue krk_docOfClass(int argc, const KrkValue argv[], int hasKw) { if (!IS_CLASS(argv[0])) return krk_runtimeError(vm.exceptions->typeError, "expected class"); return AS_CLASS(argv[0])->docstring ? OBJECT_VAL(AS_CLASS(argv[0])->docstring) : NONE_VAL(); } /* Class.__str__() (and Class.__repr__) */ -static KrkValue _class_to_str(int argc, KrkValue argv[], int hasKw) { +static KrkValue _class_to_str(int argc, const KrkValue argv[], int hasKw) { if (!IS_CLASS(argv[0])) return krk_runtimeError(vm.exceptions->typeError, "expected class"); /* Determine if this class has a module */ @@ -59,7 +59,7 @@ static KrkValue _class_to_str(int argc, KrkValue argv[], int hasKw) { return OBJECT_VAL(out); } -static KrkValue _class_subclasses(int argc, KrkValue argv[], int hasKw) { +static KrkValue _class_subclasses(int argc, const KrkValue argv[], int hasKw) { if (!IS_CLASS(argv[0])) return krk_runtimeError(vm.exceptions->typeError, "expected class"); KrkClass * _class = AS_CLASS(argv[0]); diff --git a/src/obj_dict.c b/src/obj_dict.c index 55d9349..cbf6853 100644 --- a/src/obj_dict.c +++ b/src/obj_dict.c @@ -15,7 +15,7 @@ * Exposed method called to produce dictionaries from `{expr: expr, ...}` sequences in managed code. * Presented in the global namespace as `dictOf(...)`. Expects arguments as `key,value,key,value`... */ -KrkValue krk_dict_of(int argc, KrkValue argv[], int hasKw) { +KrkValue krk_dict_of(int argc, const KrkValue argv[], int hasKw) { if (argc % 2 != 0) return krk_runtimeError(vm.exceptions->argumentError, "Expected even number of arguments to dictOf"); KrkInstance * outDict = krk_newInstance(vm.baseClasses->dictClass); krk_push(OBJECT_VAL(outDict)); diff --git a/src/obj_list.c b/src/obj_list.c index 9f83c21..4d6b3dd 100644 --- a/src/obj_list.c +++ b/src/obj_list.c @@ -28,7 +28,7 @@ static void _list_gcsweep(KrkInstance * self) { * Exposed method called to produce lists from [expr,...] sequences in managed code. * Presented in the global namespace as listOf(...) */ -KrkValue krk_list_of(int argc, KrkValue argv[], int hasKw) { +KrkValue krk_list_of(int argc, const KrkValue argv[], int hasKw) { KrkValue outList = OBJECT_VAL(krk_newInstance(vm.baseClasses->listClass)); krk_push(outList); krk_initValueArray(AS_LIST(outList)); @@ -173,10 +173,11 @@ KRK_METHOD(list,extend,{ METHOD_TAKES_EXACTLY(1); pthread_rwlock_wrlock(&self->rwlock); KrkValueArray * positionals = AS_LIST(argv[0]); - if (krk_valuesSame(argv[0],argv[1])) { - argv[1] = krk_list_of(self->values.count, self->values.values, 0); + KrkValue other = argv[1]; + if (krk_valuesSame(argv[0],other)) { + other = krk_list_of(self->values.count, self->values.values, 0); } - unpackIterableFast(argv[1]); + unpackIterableFast(other); _break_loop: pthread_rwlock_unlock(&self->rwlock); }) @@ -488,7 +489,7 @@ KRK_METHOD(listiterator,__call__,{ } }) -static KrkValue _sorted(int argc, KrkValue argv[], int hasKw) { +static KrkValue _sorted(int argc, const KrkValue argv[], int hasKw) { if (argc != 1) return krk_runtimeError(vm.exceptions->argumentError,"%s() takes %s %d argument%s (%d given)","sorted","exactly",1,"",argc); KrkValue listOut = krk_list_of(0,NULL,0); krk_push(listOut); @@ -499,7 +500,7 @@ static KrkValue _sorted(int argc, KrkValue argv[], int hasKw) { return krk_pop(); } -static KrkValue _reversed(int argc, KrkValue argv[], int hasKw) { +static KrkValue _reversed(int argc, const KrkValue argv[], int hasKw) { /* FIXME The Python reversed() function produces an iterator and only works for things with indexing or a __reversed__ method; * Building a list and reversing it like we do here is not correct! */ if (argc != 1) return krk_runtimeError(vm.exceptions->argumentError,"%s() takes %s %d argument%s (%d given)","reversed","exactly",1,"",argc); diff --git a/src/obj_set.c b/src/obj_set.c index 6512b37..40f46c2 100644 --- a/src/obj_set.c +++ b/src/obj_set.c @@ -221,7 +221,7 @@ KRK_METHOD(setiterator,__call__,{ } while (1); }) -KrkValue krk_set_of(int argc, KrkValue argv[], int hasKw) { +KrkValue krk_set_of(int argc, const KrkValue argv[], int hasKw) { KrkValue outSet = OBJECT_VAL(krk_newInstance(set)); krk_push(outSet); krk_initTable(&AS_set(outSet)->entries); diff --git a/src/obj_slice.c b/src/obj_slice.c index 4984ef6..904f359 100644 --- a/src/obj_slice.c +++ b/src/obj_slice.c @@ -11,7 +11,7 @@ static void _slice_gcscan(KrkInstance * self) { krk_markValue(((struct KrkSlice*)self)->step); } -KrkValue krk_slice_of(int argc, KrkValue argv[], int hasKw) { +KrkValue krk_slice_of(int argc, const KrkValue argv[], int hasKw) { KrkValue outSlice = OBJECT_VAL(krk_newInstance(vm.baseClasses->sliceClass)); krk_push(outSlice); diff --git a/src/obj_str.c b/src/obj_str.c index 373a998..cda65ba 100644 --- a/src/obj_str.c +++ b/src/obj_str.c @@ -4,7 +4,7 @@ #include #include -static KrkValue FUNC_NAME(striterator,__init__)(int,KrkValue[],int); +static KrkValue FUNC_NAME(striterator,__init__)(int,const KrkValue[],int); #define CURRENT_CTYPE KrkString * #define CURRENT_NAME self @@ -410,7 +410,7 @@ static int charIn(char c, const char * str) { * Implements all three of strip, lstrip, rstrip. * Set which = 0, 1, 2 respectively */ -static KrkValue _string_strip_shared(int argc, KrkValue argv[], int which) { +static KrkValue _string_strip_shared(int argc, const KrkValue argv[], int which) { if (argc > 1 && IS_STRING(argv[1]) && AS_STRING(argv[1])->type != KRK_STRING_ASCII) { return krk_runtimeError(vm.exceptions->notImplementedError, "str.strip() not implemented for Unicode strip lists"); } diff --git a/src/obj_tuple.c b/src/obj_tuple.c index aa10b9e..cc7c3a7 100644 --- a/src/obj_tuple.c +++ b/src/obj_tuple.c @@ -9,7 +9,7 @@ if (index < 0) index += self->values.count; \ if (index < 0 || index >= (krk_integer_type)self->values.count) return krk_runtimeError(vm.exceptions->indexError, "tuple index out of range: " PRIkrk_int, index) -static KrkValue _tuple_init(int argc, KrkValue argv[], int hasKw) { +static KrkValue _tuple_init(int argc, const KrkValue argv[], int hasKw) { if (argc == 1) { return OBJECT_VAL(krk_newTuple(0)); } else if (argc == 2) { @@ -30,7 +30,7 @@ static KrkValue _tuple_init(int argc, KrkValue argv[], int hasKw) { } /* tuple creator */ -KrkValue krk_tuple_of(int argc, KrkValue argv[], int hasKw) { +KrkValue krk_tuple_of(int argc, const KrkValue argv[], int hasKw) { KrkTuple * self = krk_newTuple(argc); krk_push(OBJECT_VAL(self)); for (size_t i = 0; i < (size_t)argc; ++i) { @@ -150,7 +150,7 @@ struct TupleIter { int i; }; -static KrkValue _tuple_iter_init(int argc, KrkValue argv[], int hasKw) { +static KrkValue _tuple_iter_init(int argc, const KrkValue argv[], int hasKw) { struct TupleIter * self = (struct TupleIter *)AS_OBJECT(argv[0]); self->myTuple = argv[1]; self->i = 0; @@ -161,7 +161,7 @@ static void _tuple_iter_gcscan(KrkInstance * self) { krk_markValue(((struct TupleIter*)self)->myTuple); } -static KrkValue _tuple_iter_call(int argc, KrkValue argv[], int hasKw) { +static KrkValue _tuple_iter_call(int argc, const KrkValue argv[], int hasKw) { struct TupleIter * self = (struct TupleIter *)AS_OBJECT(argv[0]); KrkValue t = self->myTuple; /* Tuple to iterate */ int i = self->i; diff --git a/src/os.c b/src/os.c index c1f280d..a9c3874 100644 --- a/src/os.c +++ b/src/os.c @@ -465,7 +465,7 @@ KRK_FUNC(get_terminal_size,{ }) #endif -static int makeArgs(int count, KrkValue * values, char *** argsOut, const char * _method_name) { +static int makeArgs(int count, const KrkValue * values, char *** argsOut, const char * _method_name) { char ** out = malloc(sizeof(char*)*(count+1)); for (int i = 0; i < count; ++i) { if (!IS_STRING(values[i])) { diff --git a/src/vm.c b/src/vm.c index e1b0c79..03cb580 100644 --- a/src/vm.c +++ b/src/vm.c @@ -790,7 +790,7 @@ _errorAfterKeywords: * If the stack is reallocated within this call, the old stack will not be freed until * all such nested calls through krk_callNativeOnStack have returned. */ -KrkValue krk_callNativeOnStack(NativeFn native, size_t argCount, KrkValue *stackArgs, int hasKw) { +KrkValue krk_callNativeOnStack(NativeFn native, size_t argCount, const KrkValue *stackArgs, int hasKw) { /** * If someone is already preserving this stack, we can just call directly.