From e099fe7860f517863b59bb3e788ea1db58e5ba5a Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Thu, 22 Aug 2019 21:28:57 -0400 Subject: [PATCH] Refactoring Use a macro name that makes more sense, as we are trying to determine if obj is a closure. --- include/cyclone/types.h | 6 +++--- mstreams.c | 2 +- runtime.c | 6 +++--- scheme/cyclone/cgen.sld | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/cyclone/types.h b/include/cyclone/types.h index c1828997..5c1d065e 100644 --- a/include/cyclone/types.h +++ b/include/cyclone/types.h @@ -63,13 +63,13 @@ enum object_tag { /** * Returns a true value if object is not a closure, or false otherwise */ -#define type_is_not_closure(clo) \ - ((clo == NULL) || is_value_type(clo) || (type_of(clo) > macro_tag)) +#define obj_is_not_closure(obj) \ + ((obj == NULL) || is_value_type(obj) || (type_of(obj) > macro_tag)) /** * Returns a true value if object is not a closure, or false otherwise */ -#define type_is_pair_prim(clo) (type_is_not_closure(clo)) +#define type_is_pair_prim(clo) (obj_is_not_closure(clo)) /** diff --git a/mstreams.c b/mstreams.c index 2f43100e..69cba983 100644 --- a/mstreams.c +++ b/mstreams.c @@ -14,7 +14,7 @@ /* These macros are hardcoded here to support functions in this module. */ #define closcall1(td, clo, a1) \ -if (type_is_pair_prim(clo)) { \ +if (obj_is_not_closure(clo)) { \ Cyc_apply(td, 0, (closure)(a1), clo); \ } else { \ ((clo)->fn)(td, 1, clo, a1);\ diff --git a/runtime.c b/runtime.c index 0396d572..249319e0 100644 --- a/runtime.c +++ b/runtime.c @@ -103,7 +103,7 @@ void Cyc_check_bounds(void *data, const char *label, int len, int index) /* These macros are hardcoded here to support functions in this module. */ #define closcall1(td, clo, a1) \ -if (type_is_pair_prim(clo)) { \ +if (obj_is_not_closure(clo)) { \ Cyc_apply(td, 0, (closure)(a1), clo); \ } else { \ ((clo)->fn)(td, 1, clo, a1);\ @@ -131,7 +131,7 @@ if (type_is_pair_prim(clo)) { \ } \ } #define closcall2(td, clo, a1, a2) \ -if (type_is_pair_prim(clo)) { \ +if (obj_is_not_closure(clo)) { \ Cyc_apply(td, 1, (closure)(a1), clo,a2); \ } else { \ ((clo)->fn)(td, 2, clo, a1, a2);\ @@ -5391,7 +5391,7 @@ void Cyc_start_trampoline(gc_thread_data * thd) printf("Done with GC\n"); #endif - if (type_is_pair_prim(thd->gc_cont)) { + if (obj_is_not_closure(thd->gc_cont)) { Cyc_apply_from_buf(thd, thd->gc_num_args, thd->gc_cont, thd->gc_args); } else { do_dispatch(thd, thd->gc_num_args, ((closure) (thd->gc_cont))->fn, diff --git a/scheme/cyclone/cgen.sld b/scheme/cyclone/cgen.sld index 04c17ee4..e93fc08e 100644 --- a/scheme/cyclone/cgen.sld +++ b/scheme/cyclone/cgen.sld @@ -231,7 +231,7 @@ (wrap (lambda (s) (if (> num-args 0) s "")))) (string-append "#define closcall" n "(td, clo" args ") \\\n" - (wrap (string-append "if (type_is_pair_prim(clo)) { \\\n" + (wrap (string-append "if (obj_is_not_closure(clo)) { \\\n" " Cyc_apply(td, " n-1 ", (closure)(a1), clo" (if (> num-args 1) (substring args 3 (string-length args)) "") "); \\\n" "}")) (wrap " else { \\\n")