diff options
author | Gavin Howard <gavin@yzena.com> | 2021-07-21 14:50:38 -0600 |
---|---|---|
committer | Gavin Howard <gavin@yzena.com> | 2021-07-21 14:50:38 -0600 |
commit | 01f922aed25990ac1139a1be8b679a0f78ce2c9f (patch) | |
tree | dd2cdafb6179fecb2882ab4b73325d8b21c8bbea /include | |
parent | c661e02e6577bbc892bf9a002b77d302b6d01224 (diff) | |
download | platform_external_bc-01f922aed25990ac1139a1be8b679a0f78ce2c9f.tar.gz platform_external_bc-01f922aed25990ac1139a1be8b679a0f78ce2c9f.tar.bz2 platform_external_bc-01f922aed25990ac1139a1be8b679a0f78ce2c9f.zip |
Switch strings in dc to be stored per function
This requires passing the function *and* the string index in results and
numbers.
This is to simplify the code *and* to prepare for an experiment that is
coming up.
Signed-off-by: Gavin Howard <gavin@yzena.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/program.h | 12 | ||||
-rw-r--r-- | include/vm.h | 4 |
2 files changed, 10 insertions, 6 deletions
diff --git a/include/program.h b/include/program.h index c582ea67..ccfe6a1a 100644 --- a/include/program.h +++ b/include/program.h @@ -110,10 +110,6 @@ typedef struct BcProgram { #if DC_ENABLED - /// An array of strings. This is for dc only because dc does not store - /// strings in functions. - BcVec strs_v; - /// A vector of tail calls. These are just integers, which are the number of /// tail calls that have been executed for each function (string) on the /// stack for dc. This is to prevent dc from constantly growing memory use @@ -333,6 +329,14 @@ void bc_program_printStackDebug(BcProgram* p); size_t bc_program_search(BcProgram *p, const char* id, bool var); /** + * Adds a string to a function and returns the string's index in the function. + * @param p The program. + * @param str The string to add. + * @param fidx The index of the function to add to. + */ +size_t bc_program_addString(BcProgram *p, const char *str, size_t fidx); + +/** * Inserts a function into the program and returns the index of the function in * the fns array. * @param p The program. diff --git a/include/vm.h b/include/vm.h index c5b3edd7..4508f3f7 100644 --- a/include/vm.h +++ b/include/vm.h @@ -598,12 +598,12 @@ typedef struct BcVm { //// The slab for all other strings for the main function. BcVec main_slabs; -#if BC_ENABLED - /// The slab for function names, strings in other functions, and constants /// in other functions. BcVec other_slabs; +#if BC_ENABLED + /// An array of booleans for which bc keywords have been redefined if /// BC_REDEFINE_KEYWORDS is non-zero. bool redefined_kws[BC_LEX_NKWS]; |