aboutsummaryrefslogtreecommitdiff
path: root/make/types.mk
diff options
context:
space:
mode:
authorJoel Martin <github@martintribe.org>2015-01-04 15:47:20 -0600
committerJoel Martin <github@martintribe.org>2015-01-09 16:16:56 -0600
commitf4c8a091aaf662b9b544a852a728459e84e5b7f5 (patch)
treeac1df2f7549cbac089678c6b6bd92083dfa63174 /make/types.mk
parent0f352c382c7291b12da7f1800f54b9a27a27ad64 (diff)
downloadmal-f4c8a091aaf662b9b544a852a728459e84e5b7f5.tar.gz
mal-f4c8a091aaf662b9b544a852a728459e84e5b7f5.zip
Make: refactor number type. Support large numbers.
- Can support numbers up to 100 decimal digits in length. - Still no support for negative numbers or floating point. - Change time-secs to time-ms and remove conditional in perf.mal
Diffstat (limited to 'make/types.mk')
-rw-r--r--make/types.mk18
1 files changed, 10 insertions, 8 deletions
diff --git a/make/types.mk b/make/types.mk
index 02588f7..6320396 100644
--- a/make/types.mk
+++ b/make/types.mk
@@ -6,7 +6,9 @@ ifndef __mal_types_included
__mal_types_included := true
_TOP_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
+include $(_TOP_DIR)gmsl.mk
include $(_TOP_DIR)util.mk
+include $(_TOP_DIR)numbers.mk
# Low-level type implemenation
@@ -18,7 +20,7 @@ __equal = ≛
__keyword = ʞ
__obj_hash_code = 0
-__new_obj_hash_code = $(eval __obj_hash_code := $(call gmsl_plus,1,$(__obj_hash_code)))$(__obj_hash_code)
+__new_obj_hash_code = $(eval __obj_hash_code := $(call int_add,1,$(__obj_hash_code)))$(__obj_hash_code)
__new_obj = $(__obj_magic)_$(1)_$(call __new_obj_hash_code)
@@ -37,12 +39,12 @@ __var_print = $(foreach v,$(1),\
$(foreach var,$(call __var_name,$(v)),\
$(if $(or $(call _list?,$(v)),$(call _vector?,$(v))),\
$(info $(2)$(var):)\
- $(eval __var_idx := $(call gmsl_plus,1,$(__var_idx)))\
+ $(eval __var_idx := $(call int_add,1,$(__var_idx)))\
$(foreach lidx,__lidx_$(__var_idx),\
$(eval $(lidx) := 0)\
$(foreach val,$($(v)_value),\
$(call __var_print,$(val),$(2)$(SPACE)$(SPACE)$($(lidx)): )\
- $(eval $(lidx) := $(call gmsl_plus,1,$($(lidx)))))),\
+ $(eval $(lidx) := $(call int_add,1,$($(lidx)))))),\
$(if $(call _hash_map?,$(v)),\
$(info $(2)$(var):)\
$(foreach vkey,$(filter $(v)_%,$(.VARIABLES)),\
@@ -189,10 +191,10 @@ _dissoc_seq! = $(foreach key,$(2),\
$(call _dissoc!,$(1),$(call str_decode,$($(key)_value))))
# set a key/value in the hash map
-_assoc! = $(foreach k,$(subst =,$(__equal),$(2)),$(if $(call _undefined?,$(1)_$(k)_value),$(eval $(1)_size := $(call gmsl_plus,$($(1)_size),1)),)$(eval $(1)_$(k)_value := $(3))$(1))
+_assoc! = $(foreach k,$(subst =,$(__equal),$(2)),$(if $(call _undefined?,$(1)_$(k)_value),$(eval $(1)_size := $(call int_add,$($(1)_size),1)),)$(eval $(1)_$(k)_value := $(3))$(1))
# unset a key in the hash map
-_dissoc! = $(foreach k,$(subst =,$(__equal),$(2)),$(if $(call _undefined?,$(1)_$(k)_value),,$(eval $(1)_$(k)_value := $(__undefined))$(eval $(1)_size := $(call gmsl_subtract,$($(1)_size),1))))$(1)
+_dissoc! = $(foreach k,$(subst =,$(__equal),$(2)),$(if $(call _undefined?,$(1)_$(k)_value),,$(eval $(1)_$(k)_value := $(__undefined))$(eval $(1)_size := $(call int_sub,$($(1)_size),1))))$(1)
# Hash map and vector functions
@@ -202,14 +204,14 @@ _get = $(strip \
$(if $(call _hash_map?,$(1)),\
$(foreach k,$(subst =,$(__equal),$(2)),$(if $(call _undefined?,$(1)_$(k)_value),,$($(1)_$(k)_value))),\
$(if $(call _vector?,$(1)),\
- $(word $(call gmsl_plus,1,$(2)),$($(1)_value)),\
+ $(word $(call int_add,1,$(2)),$($(1)_value)),\
,)))
_contains? = $(strip \
$(if $(call _hash_map?,$(1)),\
$(foreach k,$(subst =,$(__equal),$(2)),$(if $(call _undefined?,$(1)_$(k)_value),,$(__true))),\
$(if $(call _vector?,$(1)),\
- $(if $(word $(call gmsl_plus,1,$(2)),$($(1)_value)),$(__true),),\
+ $(if $(word $(call int_add,1,$(2)),$($(1)_value)),$(__true),),\
,)))
@@ -217,7 +219,7 @@ _contains? = $(strip \
_sequential? = $(if $(filter $(__obj_magic)_list_% $(__obj_magic)_vect_%,$(1)),$(__true),)
-_nth = $(word $(call gmsl_plus,1,$(2)),$($(1)_value))
+_nth = $(word $(call int_add,1,$(2)),$($(1)_value))
# conj that mutates a sequence in-place to append the call arguments
_conj! = $(eval $(1)_value := $(strip $($(1)_value) $2 $3 $4 $5 $6 $7 $8 $9 $(10) $(11) $(12) $(13) $(14) $(15) $(16) $(17) $(18) $(19) $(20)))$(1)