Require Object declaration with BuildListNamed().

This commit is contained in:
Sage Vaillancourt 2022-04-22 16:06:45 -04:00 committed by Sage Vaillancourt
parent cb8d966a05
commit 61a402604b
5 changed files with 9 additions and 9 deletions

View File

@ -132,7 +132,7 @@ void repl(struct Environment* env)
void loadArgsIntoEnv(int argc, const char* argv[], struct Environment* env)
{
BuildListNamed(args);
Object BuildListNamed(args);
for (int i = 0; i < argc; i++) {
addToList(args, nullTerminated(argv[i]));
}

View File

@ -502,7 +502,7 @@ void deleteList(Object* dest)
*/
Object cloneList(const Object* src)
{
BuildListNamed(list);
Object BuildListNamed(list);
FOR_POINTER_IN_LIST(src) {
addToList(list, cloneObject(*POINTER));
}
@ -726,13 +726,13 @@ inline Object constructLambda(const Object* params, const Object* docs, const Ob
}
if (params->type != TYPE_LIST) {
throw(LAMBDA_ARGS_NOT_LIST, "params are %s", getTypeName(params));
throw(LAMBDA_ARGS_NOT_LIST, "fn params must be TYPE_LIST, but is %s", getTypeName(params));
}
if (body->type != TYPE_LIST) {
throw(LAMBDA_ARGS_NOT_LIST, "body is %s", getTypeName(body));
throw(LAMBDA_ARGS_NOT_LIST, "fn body must be TYPE_LIST, but is %s", getTypeName(body));
}
if (docs && docs->type != TYPE_STRING) {
throw(BAD_TYPE, "fn docstring must be a string, but received %s", getTypeName(docs));
throw(BAD_TYPE, "fn docstring must be TYPE_STRING, but is %s", getTypeName(docs));
}
Object o = newObject(TYPE_LAMBDA);

View File

@ -27,7 +27,7 @@
_element = _element->forward)
#define POINTER _element
#define BuildListNamed(LIST) Object LIST = listObject(); Object** LIST ## _LIST_ITEM = &(LIST.list)
#define BuildListNamed(LIST) LIST = listObject(); Object** LIST ## _LIST_ITEM = &(LIST.list)
#define addToList(LIST, OBJECT) allocObject(LIST ## _LIST_ITEM, OBJECT); LIST ## _LIST_ITEM = &(*LIST ## _LIST_ITEM)->forward
#ifdef PBL_PLATFORM_APLITE

View File

@ -129,7 +129,7 @@ Object mapO(Object* params, int length, struct Environment* env)
throw(BAD_TYPE, "First argument of (map) should be func-like.");
}
BuildListNamed(outputList);
Object BuildListNamed(outputList);
FOR_POINTER_IN_LIST(inputList) {
// Create a new list for each element,
// since lambda evaluation looks for a list

View File

@ -37,7 +37,7 @@ Object filter(Object* params, unused int length, struct Environment* env)
Object condition = params[0];
Object list = params[1];
BuildListNamed(filtered);
Object BuildListNamed(filtered);
FOR_POINTER_IN_LIST(&list) {
Object cloned = cloneObject(condition);
Object first_eval = eval(&cloned, env);
@ -102,7 +102,7 @@ Object rest(Object* params, unused int length, unused struct Environment* env)
checkTypes(rest)
Object list = params[0];
BuildListNamed(ret);
Object BuildListNamed(ret);
if (list.list) {
for (Object* _element = list.list->forward; _element != NULL; _element = _element->forward) {
addToList(ret, cloneObject(*POINTER));