mirror of
https://github.com/janet-lang/janet
synced 2024-11-29 03:19:54 +00:00
Fix formatting.
Run make format.
This commit is contained in:
parent
7910a5feef
commit
944347e828
@ -227,16 +227,16 @@ JanetRange janet_getslice(int32_t argc, const Janet *argv) {
|
|||||||
range.end = length;
|
range.end = length;
|
||||||
} else if (argc == 2) {
|
} else if (argc == 2) {
|
||||||
range.start = janet_checktype(argv[1], JANET_NIL)
|
range.start = janet_checktype(argv[1], JANET_NIL)
|
||||||
? 0
|
? 0
|
||||||
: janet_gethalfrange(argv, 1, length, "start");
|
: janet_gethalfrange(argv, 1, length, "start");
|
||||||
range.end = length;
|
range.end = length;
|
||||||
} else {
|
} else {
|
||||||
range.start = janet_checktype(argv[1], JANET_NIL)
|
range.start = janet_checktype(argv[1], JANET_NIL)
|
||||||
? 0
|
? 0
|
||||||
: janet_gethalfrange(argv, 1, length, "start");
|
: janet_gethalfrange(argv, 1, length, "start");
|
||||||
range.end = janet_checktype(argv[2], JANET_NIL)
|
range.end = janet_checktype(argv[2], JANET_NIL)
|
||||||
? length
|
? length
|
||||||
: janet_gethalfrange(argv, 2, length, "end");
|
: janet_gethalfrange(argv, 2, length, "end");
|
||||||
if (range.end < range.start)
|
if (range.end < range.start)
|
||||||
range.end = range.start;
|
range.end = range.start;
|
||||||
}
|
}
|
||||||
|
@ -320,7 +320,7 @@ JanetSlot *janetc_toslotskv(JanetCompiler *c, Janet ds) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Push slots loaded via janetc_toslots. Return the minimum number of slots pushed,
|
/* Push slots loaded via janetc_toslots. Return the minimum number of slots pushed,
|
||||||
* or -1 - min_arity if there is a splice. (if there is no splice, min_arity is also
|
* or -1 - min_arity if there is a splice. (if there is no splice, min_arity is also
|
||||||
* the maximum possible arity). */
|
* the maximum possible arity). */
|
||||||
int32_t janetc_pushslots(JanetCompiler *c, JanetSlot *slots) {
|
int32_t janetc_pushslots(JanetCompiler *c, JanetSlot *slots) {
|
||||||
@ -422,56 +422,55 @@ static JanetSlot janetc_call(JanetFopts opts, JanetSlot *slots, JanetSlot fun) {
|
|||||||
|
|
||||||
/* Check for bad arity type if fun is a constant */
|
/* Check for bad arity type if fun is a constant */
|
||||||
switch (janet_type(fun.constant)) {
|
switch (janet_type(fun.constant)) {
|
||||||
case JANET_FUNCTION:
|
case JANET_FUNCTION: {
|
||||||
{
|
JanetFunction *f = janet_unwrap_function(fun.constant);
|
||||||
JanetFunction *f = janet_unwrap_function(fun.constant);
|
int32_t min = f->def->min_arity;
|
||||||
int32_t min = f->def->min_arity;
|
int32_t max = f->def->max_arity;
|
||||||
int32_t max = f->def->max_arity;
|
if (min_arity < 0) {
|
||||||
if (min_arity < 0) {
|
/* Call has splices */
|
||||||
/* Call has splices */
|
min_arity = -1 - min_arity;
|
||||||
min_arity = -1 - min_arity;
|
if (min_arity > max && max >= 0) {
|
||||||
if (min_arity > max && max >= 0) {
|
const uint8_t *es = janet_formatc(
|
||||||
const uint8_t *es = janet_formatc(
|
"%v expects at most %d argument, got at least %d",
|
||||||
"%v expects at most %d argument, got at least %d",
|
fun.constant, max, min_arity);
|
||||||
fun.constant, max, min_arity);
|
janetc_error(c, es);
|
||||||
janetc_error(c, es);
|
}
|
||||||
}
|
} else {
|
||||||
} else {
|
/* Call has no splices */
|
||||||
/* Call has no splices */
|
if (min_arity > max && max >= 0) {
|
||||||
if (min_arity > max && max >= 0) {
|
const uint8_t *es = janet_formatc(
|
||||||
const uint8_t *es = janet_formatc(
|
"%v expects at most %d argument, got %d",
|
||||||
"%v expects at most %d argument, got %d",
|
fun.constant, max, min_arity);
|
||||||
fun.constant, max, min_arity);
|
janetc_error(c, es);
|
||||||
janetc_error(c, es);
|
}
|
||||||
}
|
if (min_arity < min) {
|
||||||
if (min_arity < min) {
|
const uint8_t *es = janet_formatc(
|
||||||
const uint8_t *es = janet_formatc(
|
"%v expects at least %d argument, got %d",
|
||||||
"%v expects at least %d argument, got %d",
|
fun.constant, min, min_arity);
|
||||||
fun.constant, min, min_arity);
|
janetc_error(c, es);
|
||||||
janetc_error(c, es);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
|
break;
|
||||||
case JANET_CFUNCTION:
|
case JANET_CFUNCTION:
|
||||||
case JANET_ABSTRACT:
|
case JANET_ABSTRACT:
|
||||||
break;
|
break;
|
||||||
case JANET_KEYWORD:
|
case JANET_KEYWORD:
|
||||||
if (min_arity == 0) {
|
if (min_arity == 0) {
|
||||||
const uint8_t *es = janet_formatc("%v expects at least 1 argument, got 0",
|
const uint8_t *es = janet_formatc("%v expects at least 1 argument, got 0",
|
||||||
fun.constant);
|
fun.constant);
|
||||||
janetc_error(c, es);
|
janetc_error(c, es);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (min_arity > 1 || min_arity == 0) {
|
if (min_arity > 1 || min_arity == 0) {
|
||||||
const uint8_t *es = janet_formatc("%v expects 1 argument, got %d",
|
const uint8_t *es = janet_formatc("%v expects 1 argument, got %d",
|
||||||
fun.constant, min_arity);
|
fun.constant, min_arity);
|
||||||
janetc_error(c, es);
|
janetc_error(c, es);
|
||||||
}
|
}
|
||||||
if (min_arity < -2) {
|
if (min_arity < -2) {
|
||||||
const uint8_t *es = janet_formatc("%v expects 1 argument, got at least %d",
|
const uint8_t *es = janet_formatc("%v expects 1 argument, got at least %d",
|
||||||
fun.constant, -1 - min_arity);
|
fun.constant, -1 - min_arity);
|
||||||
janetc_error(c, es);
|
janetc_error(c, es);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user