summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Weiner <hannes@cmpxchg.org>2010-05-12 19:47:07 +0200
committerJohannes Weiner <hannes@cmpxchg.org>2010-05-12 19:47:07 +0200
commitb215cf006f82b9fa0dfe3f4925ea00641330aad3 (patch)
tree98fc2d23d1db6b643e0c05568345b1e978f30792
parentd0a2089e2bbaf5195748646c21a637e0dacee4f0 (diff)
unpack: remove caller name from arguments
This is now handled through runtime error reporting. Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
-rw-r--r--include/sheep/unpack.h8
-rw-r--r--lib/io.c10
-rw-r--r--lib/regex.c2
-rw-r--r--lib/sha1.c2
-rw-r--r--sheep/bool.c6
-rw-r--r--sheep/function.c2
-rw-r--r--sheep/list.c20
-rw-r--r--sheep/number.c44
-rw-r--r--sheep/sequence.c10
-rw-r--r--sheep/string.c10
-rw-r--r--sheep/unpack.c11
11 files changed, 60 insertions, 65 deletions
diff --git a/include/sheep/unpack.h b/include/sheep/unpack.h
index c2ccf9e..3935e23 100644
--- a/include/sheep/unpack.h
+++ b/include/sheep/unpack.h
@@ -13,10 +13,8 @@
struct sheep_vm;
-int sheep_unpack(const char *, struct sheep_vm *, sheep_t, const char, ...);
-int sheep_unpack_list(const char *, struct sheep_vm *,
- struct sheep_list *, const char *, ...);
-int sheep_unpack_stack(const char *, struct sheep_vm *, unsigned int,
- const char *, ...);
+int sheep_unpack(struct sheep_vm *, sheep_t, const char, ...);
+int sheep_unpack_list(struct sheep_vm *, struct sheep_list *, const char *, ...);
+int sheep_unpack_stack(struct sheep_vm *, unsigned int, const char *, ...);
#endif /* _SHEEP_UNPACK_H */
diff --git a/lib/io.c b/lib/io.c
index 41a5f82..81cea1e 100644
--- a/lib/io.c
+++ b/lib/io.c
@@ -54,7 +54,7 @@ static sheep_t open(struct sheep_vm *vm, unsigned int nr_args)
sheep_t write;
FILE *filp;
- if (sheep_unpack_stack("open", vm, nr_args, "Sb", &path, &write))
+ if (sheep_unpack_stack(vm, nr_args, "Sb", &path, &write))
return NULL;
if (sheep_test(write))
@@ -79,7 +79,7 @@ static sheep_t close(struct sheep_vm *vm, unsigned int nr_args)
{
struct file *file;
- if (sheep_unpack_stack("close", vm, nr_args, "T", &file_type, &file))
+ if (sheep_unpack_stack(vm, nr_args, "T", &file_type, &file))
return NULL;
if (file_close(file))
@@ -94,8 +94,7 @@ static sheep_t read(struct sheep_vm *vm, unsigned int nr_args)
struct file *file;
char *buf;
- if (sheep_unpack_stack("read", vm, nr_args, "TN",
- &file_type, &file, &nr_bytes))
+ if (sheep_unpack_stack(vm, nr_args, "TN", &file_type, &file, &nr_bytes))
return NULL;
if (!file->filp) {
@@ -117,8 +116,7 @@ static sheep_t write(struct sheep_vm *vm, unsigned int nr_args)
const char *string;
struct file *file;
- if (sheep_unpack_stack("write", vm, nr_args, "TS",
- &file_type, &file, &string))
+ if (sheep_unpack_stack(vm, nr_args, "TS", &file_type, &file, &string))
return NULL;
if (!file->filp) {
diff --git a/lib/regex.c b/lib/regex.c
index 3e89a0c..db42acb 100644
--- a/lib/regex.c
+++ b/lib/regex.c
@@ -29,7 +29,7 @@ static sheep_t match(struct sheep_vm *vm, unsigned int nr_args)
regex_t reg;
int status;
- if (sheep_unpack_stack("open", vm, nr_args, "Ss", &regex, &string_))
+ if (sheep_unpack_stack(vm, nr_args, "Ss", &regex, &string_))
return NULL;
sheep_protect(vm, string_);
diff --git a/lib/sha1.c b/lib/sha1.c
index 70fb4f9..341ad33 100644
--- a/lib/sha1.c
+++ b/lib/sha1.c
@@ -14,7 +14,7 @@ static sheep_t sha1(struct sheep_vm *vm, unsigned int nr_args)
const char *text;
unsigned int i;
- if (sheep_unpack_stack("sha1", vm, nr_args, "S", &text))
+ if (sheep_unpack_stack(vm, nr_args, "S", &text))
return NULL;
SHA1((const unsigned char *)text, strlen(text), hash);
diff --git a/sheep/bool.c b/sheep/bool.c
index 0d73cfc..7c1685d 100644
--- a/sheep/bool.c
+++ b/sheep/bool.c
@@ -45,7 +45,7 @@ static sheep_t builtin_equal(struct sheep_vm *vm, unsigned int nr_args)
{
sheep_t a, b;
- if (sheep_unpack_stack("=", vm, nr_args, "oo", &a, &b))
+ if (sheep_unpack_stack(vm, nr_args, "oo", &a, &b))
return NULL;
if (sheep_equal(a, b))
@@ -58,7 +58,7 @@ static sheep_t builtin_bool(struct sheep_vm *vm, unsigned int nr_args)
{
sheep_t sheep;
- if (sheep_unpack_stack("bool", vm, nr_args, "o", &sheep))
+ if (sheep_unpack_stack(vm, nr_args, "o", &sheep))
return NULL;
if (sheep_test(sheep))
@@ -71,7 +71,7 @@ static sheep_t builtin_not(struct sheep_vm *vm, unsigned int nr_args)
{
sheep_t sheep;
- if (sheep_unpack_stack("not", vm, nr_args, "o", &sheep))
+ if (sheep_unpack_stack(vm, nr_args, "o", &sheep))
return NULL;
if (sheep_test(sheep))
diff --git a/sheep/function.c b/sheep/function.c
index 706fadc..1e97a47 100644
--- a/sheep/function.c
+++ b/sheep/function.c
@@ -130,7 +130,7 @@ static sheep_t builtin_disassemble(struct sheep_vm *vm, unsigned int nr_args)
struct sheep_function *function;
unsigned int nr_foreigns;
- if (sheep_unpack_stack("disassemble", vm, nr_args, "F", &function))
+ if (sheep_unpack_stack(vm, nr_args, "F", &function))
return NULL;
if (function->foreign)
diff --git a/sheep/list.c b/sheep/list.c
index 595490a..eea3026 100644
--- a/sheep/list.c
+++ b/sheep/list.c
@@ -118,7 +118,7 @@ static sheep_t list_concat(struct sheep_vm *vm, sheep_t sheep,
sheep_t list;
list = vm->stack.items[vm->stack.nr_items - nr_args + i];
- if (sheep_unpack("concat", vm, list, 'l', &list))
+ if (sheep_unpack(vm, list, 'l', &list))
goto out;
pos = do_list_concat(vm, pos, list);
@@ -266,7 +266,7 @@ static sheep_t builtin_cons(struct sheep_vm *vm, unsigned int nr_args)
new = sheep_make_cons(vm, NULL, NULL);
- if (sheep_unpack_stack("cons", vm, nr_args, "ol", &item, &list))
+ if (sheep_unpack_stack(vm, nr_args, "ol", &item, &list))
return NULL;
sheep_list(new)->head = item;
@@ -305,7 +305,7 @@ static sheep_t builtin_head(struct sheep_vm *vm, unsigned int nr_args)
struct sheep_list *list;
sheep_t sheep;
- if (sheep_unpack_stack("head", vm, nr_args, "l", &sheep))
+ if (sheep_unpack_stack(vm, nr_args, "l", &sheep))
return NULL;
list = sheep_list(sheep);
@@ -320,7 +320,7 @@ static sheep_t builtin_tail(struct sheep_vm *vm, unsigned int nr_args)
struct sheep_list *list;
sheep_t sheep;
- if (sheep_unpack_stack("tail", vm, nr_args, "l", &sheep))
+ if (sheep_unpack_stack(vm, nr_args, "l", &sheep))
return NULL;
list = sheep_list(sheep);
@@ -335,7 +335,7 @@ static sheep_t builtin_find(struct sheep_vm *vm, unsigned int nr_args)
sheep_t predicate, list_, result = &sheep_nil;
struct sheep_list *list;
- if (sheep_unpack_stack("find", vm, nr_args, "cl", &predicate, &list_))
+ if (sheep_unpack_stack(vm, nr_args, "cl", &predicate, &list_))
return NULL;
sheep_protect(vm, predicate);
sheep_protect(vm, list_);
@@ -364,7 +364,7 @@ static sheep_t builtin_filter(struct sheep_vm *vm, unsigned int nr_args)
sheep_t filter, old_, new_, result = NULL;
struct sheep_list *old, *new;
- if (sheep_unpack_stack("filter", vm, nr_args, "cl", &filter, &old_))
+ if (sheep_unpack_stack(vm, nr_args, "cl", &filter, &old_))
return NULL;
sheep_protect(vm, filter);
sheep_protect(vm, old_);
@@ -403,7 +403,7 @@ static sheep_t builtin_apply(struct sheep_vm *vm, unsigned int nr_args)
struct sheep_list *list;
sheep_t callable;
- if (sheep_unpack_stack("apply", vm, nr_args, "cL", &callable, &list))
+ if (sheep_unpack_stack(vm, nr_args, "cL", &callable, &list))
return NULL;
return sheep_apply(vm, callable, list);
@@ -415,7 +415,7 @@ static sheep_t builtin_map(struct sheep_vm *vm, unsigned int nr_args)
sheep_t mapper, old_, new_, result = NULL;
struct sheep_list *old, *new;
- if (sheep_unpack_stack("map", vm, nr_args, "cl", &mapper, &old_))
+ if (sheep_unpack_stack(vm, nr_args, "cl", &mapper, &old_))
return NULL;
sheep_protect(vm, mapper);
sheep_protect(vm, old_);
@@ -449,14 +449,14 @@ static sheep_t builtin_reduce(struct sheep_vm *vm, unsigned int nr_args)
sheep_t reducer, list_, a, b, value, result = NULL;
struct sheep_list *list;
- if (sheep_unpack_stack("reduce", vm, nr_args, "cl", &reducer, &list_))
+ if (sheep_unpack_stack(vm, nr_args, "cl", &reducer, &list_))
return NULL;
sheep_protect(vm, reducer);
sheep_protect(vm, list_);
list = sheep_list(list_);
- if (sheep_unpack_list("reduce", vm, list, "oor", &a, &b, &list))
+ if (sheep_unpack_list(vm, list, "oor", &a, &b, &list))
goto out;
value = sheep_call(vm, reducer, 2, a, b);
diff --git a/sheep/number.c b/sheep/number.c
index 2fd819d..fa25a54 100644
--- a/sheep/number.c
+++ b/sheep/number.c
@@ -63,7 +63,7 @@ static sheep_t builtin_number(struct sheep_vm *vm, unsigned int nr_args)
{
sheep_t sheep;
- if (sheep_unpack_stack("number", vm, nr_args, "o", &sheep))
+ if (sheep_unpack_stack(vm, nr_args, "o", &sheep))
return NULL;
if (sheep_type(sheep) == &sheep_number_type)
@@ -94,12 +94,12 @@ enum relation {
};
static sheep_t do_cmp(struct sheep_vm *vm, unsigned int nr_args,
- const char *name, enum relation relation)
+ enum relation relation)
{
int result = result;
long a, b;
- if (sheep_unpack_stack(name, vm, nr_args, "NN", &a, &b))
+ if (sheep_unpack_stack(vm, nr_args, "NN", &a, &b))
return NULL;
switch (relation) {
@@ -125,36 +125,36 @@ static sheep_t do_cmp(struct sheep_vm *vm, unsigned int nr_args,
/* (< a b) */
static sheep_t builtin_less(struct sheep_vm *vm, unsigned int nr_args)
{
- return do_cmp(vm, nr_args, "<", LESS);
+ return do_cmp(vm, nr_args, LESS);
}
/* (<= a b) */
static sheep_t builtin_lesseq(struct sheep_vm *vm, unsigned int nr_args)
{
- return do_cmp(vm, nr_args, "<=", LESSEQ);
+ return do_cmp(vm, nr_args, LESSEQ);
}
/* (>= a b) */
static sheep_t builtin_moreeq(struct sheep_vm *vm, unsigned int nr_args)
{
- return do_cmp(vm, nr_args, ">=", MOREEQ);
+ return do_cmp(vm, nr_args, MOREEQ);
}
/* (> a b) */
static sheep_t builtin_more(struct sheep_vm *vm, unsigned int nr_args)
{
- return do_cmp(vm, nr_args, ">", MORE);
+ return do_cmp(vm, nr_args, MORE);
}
static sheep_t do_binop(struct sheep_vm *vm, unsigned int nr_args,
- const char *operation)
+ char operation)
{
long value, a, b;
- if (sheep_unpack_stack(operation, vm, nr_args, "NN", &a, &b))
+ if (sheep_unpack_stack(vm, nr_args, "NN", &a, &b))
return NULL;
- switch (*operation) {
+ switch (operation) {
case '+':
value = a + b;
break;
@@ -195,7 +195,7 @@ static sheep_t do_binop(struct sheep_vm *vm, unsigned int nr_args,
/* (+ a b) */
static sheep_t builtin_plus(struct sheep_vm *vm, unsigned int nr_args)
{
- return do_binop(vm, nr_args, "+");
+ return do_binop(vm, nr_args, '+');
}
/* (- a &optional b) */
@@ -204,30 +204,30 @@ static sheep_t builtin_minus(struct sheep_vm *vm, unsigned int nr_args)
if (nr_args == 1) {
long number;
- if (sheep_unpack_stack("-", vm, nr_args, "N", &number))
+ if (sheep_unpack_stack(vm, nr_args, "N", &number))
return NULL;
return sheep_make_number(vm, -number);
}
- return do_binop(vm, nr_args, "-");
+ return do_binop(vm, nr_args, '-');
}
/* (* a b) */
static sheep_t builtin_multiply(struct sheep_vm *vm, unsigned int nr_args)
{
- return do_binop(vm, nr_args, "*");
+ return do_binop(vm, nr_args, '*');
}
/* (/ a b) */
static sheep_t builtin_divide(struct sheep_vm *vm, unsigned int nr_args)
{
- return do_binop(vm, nr_args, "/");
+ return do_binop(vm, nr_args, '/');
}
/* (% a b) */
static sheep_t builtin_modulo(struct sheep_vm *vm, unsigned int nr_args)
{
- return do_binop(vm, nr_args, "%");
+ return do_binop(vm, nr_args, '%');
}
/* (~ number) */
@@ -235,7 +235,7 @@ static sheep_t builtin_lnot(struct sheep_vm *vm, unsigned int nr_args)
{
long number;
- if (sheep_unpack_stack("~", vm, nr_args, "N", &number))
+ if (sheep_unpack_stack(vm, nr_args, "N", &number))
return NULL;
return sheep_make_number(vm, ~number);
@@ -244,31 +244,31 @@ static sheep_t builtin_lnot(struct sheep_vm *vm, unsigned int nr_args)
/* (| a b) */
static sheep_t builtin_lor(struct sheep_vm *vm, unsigned int nr_args)
{
- return do_binop(vm, nr_args, "|");
+ return do_binop(vm, nr_args, '|');
}
/* (& a b) */
static sheep_t builtin_land(struct sheep_vm *vm, unsigned int nr_args)
{
- return do_binop(vm, nr_args, "&");
+ return do_binop(vm, nr_args, '&');
}
/* (^ a b) */
static sheep_t builtin_lxor(struct sheep_vm *vm, unsigned int nr_args)
{
- return do_binop(vm, nr_args, "^");
+ return do_binop(vm, nr_args, '^');
}
/* (<< a b) */
static sheep_t builtin_shiftl(struct sheep_vm *vm, unsigned int nr_args)
{
- return do_binop(vm, nr_args, "<<");
+ return do_binop(vm, nr_args, '<');
}
/* (>> a b) */
static sheep_t builtin_shiftr(struct sheep_vm *vm, unsigned int nr_args)
{
- return do_binop(vm, nr_args, ">>");
+ return do_binop(vm, nr_args, '>');
}
void sheep_number_builtins(struct sheep_vm *vm)
diff --git a/sheep/sequence.c b/sheep/sequence.c
index 136ab4b..2fea5dc 100644
--- a/sheep/sequence.c
+++ b/sheep/sequence.c
@@ -17,7 +17,7 @@ static sheep_t builtin_length(struct sheep_vm *vm, unsigned int nr_args)
unsigned int len;
sheep_t seq;
- if (sheep_unpack_stack("length", vm, nr_args, "q", &seq))
+ if (sheep_unpack_stack(vm, nr_args, "q", &seq))
return NULL;
len = sheep_sequence(seq)->length(seq);
@@ -35,7 +35,7 @@ static sheep_t builtin_concat(struct sheep_vm *vm, unsigned int nr_args)
}
object = vm->stack.items[vm->stack.nr_items - nr_args];
- if (sheep_unpack("concat", vm, object, 'q', &object))
+ if (sheep_unpack(vm, object, 'q', &object))
return NULL;
return sheep_sequence(object)->concat(vm, object, nr_args);
@@ -46,7 +46,7 @@ static sheep_t builtin_reverse(struct sheep_vm *vm, unsigned int nr_args)
{
sheep_t seq;
- if (sheep_unpack_stack("reverse", vm, nr_args, "q", &seq))
+ if (sheep_unpack_stack(vm, nr_args, "q", &seq))
return NULL;
return sheep_sequence(seq)->reverse(vm, seq);
@@ -58,7 +58,7 @@ static sheep_t builtin_nth(struct sheep_vm *vm, unsigned int nr_args)
unsigned long n;
sheep_t seq;
- if (sheep_unpack_stack("nth", vm, nr_args, "Nq", &n, &seq))
+ if (sheep_unpack_stack(vm, nr_args, "Nq", &n, &seq))
return NULL;
return sheep_sequence(seq)->nth(vm, n, seq);
@@ -69,7 +69,7 @@ static sheep_t builtin_position(struct sheep_vm *vm, unsigned int nr_args)
{
sheep_t item, seq;
- if (sheep_unpack_stack("position", vm, nr_args, "oq", &item, &seq))
+ if (sheep_unpack_stack(vm, nr_args, "oq", &item, &seq))
return NULL;
return sheep_sequence(seq)->position(vm, item, seq);
diff --git a/sheep/string.c b/sheep/string.c
index e994f78..5d61e2c 100644
--- a/sheep/string.c
+++ b/sheep/string.c
@@ -73,7 +73,7 @@ static sheep_t string_concat(struct sheep_vm *vm, sheep_t sheep,
sheep_t string_;
string_ = vm->stack.items[vm->stack.nr_items - nr_args + i];
- if (sheep_unpack("concat", vm, string_, 'S', &string)) {
+ if (sheep_unpack(vm, string_, 'S', &string)) {
sheep_free(sb.bytes);
return NULL;
}
@@ -190,7 +190,7 @@ static sheep_t builtin_string(struct sheep_vm *vm, unsigned int nr_args)
sheep_t sheep;
char *buf;
- if (sheep_unpack_stack("string", vm, nr_args, "o", &sheep))
+ if (sheep_unpack_stack(vm, nr_args, "o", &sheep))
return NULL;
if (sheep_type(sheep) == &sheep_string_type)
@@ -225,7 +225,7 @@ static sheep_t builtin_split(struct sheep_vm *vm, unsigned int nr_args)
char *pos, *orig;
int empty;
- if (sheep_unpack_stack("split", vm, nr_args, "ss", &delim_, &string_))
+ if (sheep_unpack_stack(vm, nr_args, "ss", &delim_, &string_))
return NULL;
sheep_protect(vm, delim_);
@@ -276,7 +276,7 @@ static sheep_t builtin_join(struct sheep_vm *vm, unsigned int nr_args)
sheep_t delim_, list_;
size_t length = 0;
- if (sheep_unpack_stack("join", vm, nr_args, "sl", &delim_, &list_))
+ if (sheep_unpack_stack(vm, nr_args, "sl", &delim_, &list_))
return NULL;
sheep_protect(vm, delim_);
@@ -289,7 +289,7 @@ static sheep_t builtin_join(struct sheep_vm *vm, unsigned int nr_args)
struct sheep_string *string;
size_t newlength;
- if (sheep_unpack_list("join", vm, list, "Sr", &string, &list))
+ if (sheep_unpack_list(vm, list, "Sr", &string, &list))
goto out;
newlength = length + string->nr_bytes;
diff --git a/sheep/unpack.c b/sheep/unpack.c
index 7c1e91d..bd5f612 100644
--- a/sheep/unpack.c
+++ b/sheep/unpack.c
@@ -94,8 +94,7 @@ static const char *unpack(int control, sheep_t object,
return NULL;
}
-int sheep_unpack(const char *caller, struct sheep_vm *vm,
- sheep_t object, const char item, ...)
+int sheep_unpack(struct sheep_vm *vm, sheep_t object, const char item, ...)
{
void **itemp, *next = NULL;
const char *wanted;
@@ -119,8 +118,8 @@ int sheep_unpack(const char *caller, struct sheep_vm *vm,
return 0;
}
-int sheep_unpack_list(const char *caller, struct sheep_vm *vm,
- struct sheep_list *list, const char *items, ...)
+int sheep_unpack_list(struct sheep_vm *vm, struct sheep_list *list,
+ const char *items, ...)
{
va_list ap;
@@ -166,8 +165,8 @@ int sheep_unpack_list(const char *caller, struct sheep_vm *vm,
return -1;
}
-int sheep_unpack_stack(const char *caller, struct sheep_vm *vm,
- unsigned int nr_args, const char *items, ...)
+int sheep_unpack_stack(struct sheep_vm *vm, unsigned int nr_args,
+ const char *items, ...)
{
unsigned long base, index;
va_list ap;