summaryrefslogtreecommitdiff
path: root/src/scheme/ao_scheme_int.c
diff options
context:
space:
mode:
authorBdale Garbee <bdale@gag.com>2017-12-21 19:05:46 -0700
committerBdale Garbee <bdale@gag.com>2017-12-21 19:05:46 -0700
commitdbb78c8222c45f4430601deee0194b0c9dc2e79a (patch)
tree6805b815727c58ad6c01f9163e42ab3177ee56d5 /src/scheme/ao_scheme_int.c
parentfe38c22595b050435dbacd35f1baae064fb7de75 (diff)
parent87aab99521dc44d1d29fbb0b7f227f868f074836 (diff)
Merge branch 'master' into branch-1.8
Diffstat (limited to 'src/scheme/ao_scheme_int.c')
-rw-r--r--src/scheme/ao_scheme_int.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/scheme/ao_scheme_int.c b/src/scheme/ao_scheme_int.c
index 350a5d35..01b571c0 100644
--- a/src/scheme/ao_scheme_int.c
+++ b/src/scheme/ao_scheme_int.c
@@ -15,23 +15,29 @@
#include "ao_scheme.h"
void
-ao_scheme_int_write(ao_poly p)
+ao_scheme_int_write(ao_poly p, bool write)
{
int i = ao_scheme_poly_int(p);
+ (void) write;
printf("%d", i);
}
+#ifdef AO_SCHEME_FEATURE_BIGINT
+
int32_t
-ao_scheme_poly_integer(ao_poly p)
+ao_scheme_poly_integer(ao_poly p, bool *fail)
{
+ if (fail)
+ *fail = false;
switch (ao_scheme_poly_base_type(p)) {
case AO_SCHEME_INT:
return ao_scheme_poly_int(p);
- case AO_SCHEME_OTHER:
- if (ao_scheme_other_type(ao_scheme_poly_other(p)) == AO_SCHEME_BIGINT)
- return ao_scheme_bigint_int(ao_scheme_poly_bigint(p)->value);
+ case AO_SCHEME_BIGINT:
+ return ao_scheme_poly_bigint(p)->value;
}
- return AO_SCHEME_NOT_INTEGER;
+ if (fail)
+ *fail = true;
+ return 0;
}
ao_poly
@@ -42,7 +48,7 @@ ao_scheme_integer_poly(int32_t p)
if (AO_SCHEME_MIN_INT <= p && p <= AO_SCHEME_MAX_INT)
return ao_scheme_int_poly(p);
bi = ao_scheme_alloc(sizeof (struct ao_scheme_bigint));
- bi->value = ao_scheme_int_bigint(p);
+ bi->value = p;
return ao_scheme_bigint_poly(bi);
}
@@ -71,9 +77,11 @@ const struct ao_scheme_type ao_scheme_bigint_type = {
};
void
-ao_scheme_bigint_write(ao_poly p)
+ao_scheme_bigint_write(ao_poly p, bool write)
{
struct ao_scheme_bigint *bi = ao_scheme_poly_bigint(p);
- printf("%d", ao_scheme_bigint_int(bi->value));
+ (void) write;
+ printf("%d", bi->value);
}
+#endif /* AO_SCHEME_FEATURE_BIGINT */