1515
1616#define HASH_BASE 1
1717
18+
19+
1820typedef enum {
1921 BUF_TY_BASE ,
2022 BUF_TY_SV ,
@@ -70,33 +72,25 @@ typedef enum {
7072 SCAN_RES_WHITESPACE_ADJACENT = 3 ,
7173} ScanRes ;
7274
73- typedef enum {
74- STK_TYPE_INTEGER = 0 ,
75- STK_TYPE_STRING = 1 ,
76- STK_TYPE_FUNCTION = 2 ,
77- STK_TYPE_MISSING = 3 ,
78- STK_TYPE_ILLEGAL = 4 ,
79- } StkType ;
80-
8175enum StrIlk
8276#ifdef __cplusplus
8377 : uint8_t
8478#endif // __cplusplus
8579 {
86- StrIlk_Text = 0 ,
87- StrIlk_Integer = 1 ,
88- StrIlk_AuxCommand = 2 ,
89- StrIlk_AuxFile = 3 ,
90- StrIlk_BstCommand = 4 ,
91- StrIlk_BstFile = 5 ,
92- StrIlk_BibFile = 6 ,
93- StrIlk_FileExt = 7 ,
94- StrIlk_Cite = 9 ,
95- StrIlk_LcCite = 10 ,
96- StrIlk_BstFn = 11 ,
97- StrIlk_BibCommand = 12 ,
98- StrIlk_Macro = 13 ,
99- StrIlk_ControlSeq = 14 ,
80+ STR_ILK_TEXT = 0 ,
81+ STR_ILK_INTEGER = 1 ,
82+ STR_ILK_AUX_COMMAND = 2 ,
83+ STR_ILK_AUX_FILE = 3 ,
84+ STR_ILK_BST_COMMAND = 4 ,
85+ STR_ILK_BST_FILE = 5 ,
86+ STR_ILK_BIB_FILE = 6 ,
87+ STR_ILK_FILE_EXT = 7 ,
88+ STR_ILK_CITE = 9 ,
89+ STR_ILK_LC_CITE = 10 ,
90+ STR_ILK_BST_FN = 11 ,
91+ STR_ILK_BIB_COMMAND = 12 ,
92+ STR_ILK_MACRO = 13 ,
93+ STR_ILK_CONTROL_SEQ = 14 ,
10094};
10195#ifndef __cplusplus
10296typedef uint8_t StrIlk ;
@@ -170,36 +164,27 @@ typedef uintptr_t BibNumber;
170164
171165typedef uintptr_t CiteNumber ;
172166
173- typedef uintptr_t HashPointer2 ;
174-
175167typedef struct {
176168 CiteNumber cite_loc ;
177169 CiteNumber lc_cite_loc ;
178170 bool cite_found ;
179171 bool lc_found ;
180172} FindCiteLocs ;
181173
182- typedef struct {
183- StkType typ ;
184- int32_t lit ;
185- } ExecVal ;
186-
187174typedef struct {
188175 Bibtex * glbl_ctx ;
189176 HashPointer _default ;
190- ExecVal pop1 ;
191- ExecVal pop2 ;
192- ExecVal pop3 ;
193177 XBuf_ExecVal * lit_stack ;
194178 uintptr_t lit_stk_ptr ;
195179 bool mess_with_entries ;
180+ /**
181+ * Pointer to the current top of the string pool, used to optimized certain string operations
182+ */
196183 StrNumber bib_str_ptr ;
197184} ExecCtx ;
198185
199186typedef uintptr_t FieldLoc ;
200187
201- typedef uintptr_t WizFnLoc ;
202-
203188typedef uintptr_t PoolPointer ;
204189
205190typedef struct {
@@ -251,8 +236,6 @@ extern "C" {
251236
252237extern const LexClass LEX_CLASS [256 ];
253238
254- extern const int32_t CHAR_WIDTH [256 ];
255-
256239void reset_all (void );
257240
258241bool bib_str_eq_buf (StrNumber s , BufTy buf , BufPointer ptr , BufPointer len );
@@ -293,12 +276,8 @@ void set_bib_ptr(BibNumber num);
293276
294277void check_bib_files (BibNumber ptr );
295278
296- StrNumber cur_preamble (void );
297-
298279BibNumber preamble_ptr (void );
299280
300- void set_preamble_ptr (BibNumber num );
301-
302281int32_t bib_line_num (void );
303282
304283void set_bib_line_num (int32_t num );
@@ -319,16 +298,8 @@ BufPointer bib_buf_len(BufTy ty);
319298
320299void bib_set_buf_len (BufTy ty , BufPointer len );
321300
322- BufPointer name_tok (BufPointer pos );
323-
324- void set_name_tok (BufPointer pos , BufPointer val );
325-
326301void lower_case (BufTy buf , BufPointer ptr , BufPointer len );
327302
328- void upper_case (BufTy buf , BufPointer ptr , BufPointer len );
329-
330- BufPointer int_to_ascii (int32_t the_int , BufTy int_buf , BufPointer int_begin );
331-
332303void quick_sort (CiteNumber left_end , CiteNumber right_end );
333304
334305StrNumber cite_list (CiteNumber num );
@@ -347,9 +318,9 @@ StrNumber cite_info(CiteNumber num);
347318
348319void set_cite_info (CiteNumber num , StrNumber info );
349320
350- HashPointer2 type_list (CiteNumber num );
321+ HashPointer type_list (CiteNumber num );
351322
352- void set_type_list (CiteNumber num , HashPointer2 ty );
323+ void set_type_list (CiteNumber num , HashPointer ty );
353324
354325bool entry_exists (CiteNumber num );
355326
@@ -387,81 +358,22 @@ uintptr_t num_ent_strs(void);
387358
388359void set_num_ent_strs (uintptr_t val );
389360
390- int32_t entry_ints (int32_t pos );
391-
392- void set_entry_ints (int32_t pos , int32_t val );
393-
394- ASCIICode entry_strs (int32_t pos );
395-
396- void set_entry_strs (int32_t pos , ASCIICode val );
397-
398- ExecVal int_val (int32_t lit );
399-
400- ExecVal str_val (StrNumber str );
401-
402- ExecVal func_val (HashPointer f );
403-
404- ExecVal missing_val (StrNumber f );
405-
406361ExecCtx init_exec_ctx (Bibtex * glbl_ctx );
407362
408- CResult print_lit (ExecVal val );
409-
410- CResult print_stk_lit (ExecVal val );
411-
412- CResult print_wrong_stk_lit (ExecCtx * ctx , ExecVal val , StkType typ2 );
413-
414- CResult bst_ex_warn_print (const ExecCtx * ctx );
415-
416363CResult print_bst_name (const Bibtex * glbl_ctx );
417364
418- void push_lit_stk (ExecCtx * ctx , ExecVal val );
419-
420- CResult pop_lit_stk (ExecCtx * ctx , ExecVal * out );
421-
422- CResult pop_top_and_print (ExecCtx * ctx );
423-
424- CResult pop_whole_stack (ExecCtx * ctx );
425-
426365void init_command_execution (ExecCtx * ctx );
427366
428- CResult figure_out_the_formatted_name (ExecCtx * ctx ,
429- BufPointer first_start ,
430- BufPointer first_end ,
431- BufPointer last_end ,
432- BufPointer von_start ,
433- BufPointer von_end ,
434- BufPointer * name_bf_ptr ,
435- BufPointer * name_bf_xptr ,
436- BufPointer jr_end ,
437- int32_t * brace_level );
438-
439367CResult check_command_execution (ExecCtx * ctx );
440368
441- CResult add_pool_buf_and_push (ExecCtx * ctx );
442-
443- ExecVal * cur_lit (ExecCtx * ctx );
369+ CResult execute_fn (ExecCtx * ctx , HashPointer ex_fn_loc );
444370
445371int32_t num_glb_strs (void );
446372
447373void set_num_glb_strs (int32_t val );
448374
449375void check_grow_global_strs (void );
450376
451- uintptr_t glb_bib_str_ptr (uintptr_t pos );
452-
453- void set_glb_bib_str_ptr (uintptr_t pos , uintptr_t val );
454-
455- ASCIICode global_strs (uintptr_t pos );
456-
457- void set_global_strs (uintptr_t pos , ASCIICode val );
458-
459- int32_t glb_str_end (uintptr_t pos );
460-
461- void set_glb_str_end (uintptr_t pos , int32_t val );
462-
463- uintptr_t end_of_def (void );
464-
465377uintptr_t undefined (void );
466378
467379FnClass fn_type (HashPointer pos );
@@ -532,8 +444,6 @@ CResult bst_warn_print(const Bibtex *ctx);
532444
533445void eat_bst_print (void );
534446
535- void unknwn_function_class_confusion (void );
536-
537447CResult bst_id_print (ScanRes scan_result );
538448
539449void bst_left_brace_print (void );
@@ -560,14 +470,6 @@ CResult bad_cross_reference_print(StrNumber s);
560470
561471CResult print_missing_entry (StrNumber s );
562472
563- CResult bst_cant_mess_with_entries_print (const ExecCtx * ctx );
564-
565- void bst_1print_string_size_exceeded (void );
566-
567- CResult bst_2print_string_size_exceeded (const ExecCtx * ctx );
568-
569- void case_conversion_confusion (void );
570-
571473void print_fn_class (HashPointer fn_loc );
572474
573475CResult bst_err_print_and_look_for_blank_line (Bibtex * ctx );
@@ -576,10 +478,6 @@ CResult already_seen_function_print(Bibtex *ctx, HashPointer seen_fn_loc);
576478
577479CResult nonexistent_cross_reference_error (FieldLoc field_ptr );
578480
579- void output_bbl_line (Bibtex * ctx );
580-
581- HashPointer2 wiz_functions (WizFnLoc pos );
582-
583481StrNumber field_info (FieldLoc pos );
584482
585483void set_field_info (FieldLoc pos , StrNumber val );
@@ -604,14 +502,8 @@ bool tectonic_eof(PeekableInput *peekable);
604502
605503bool input_ln (PeekableInput * peekable );
606504
607- bool bib_str_eq_str (StrNumber s1 , StrNumber s2 );
608-
609- void pool_overflow (void );
610-
611505ASCIICode bib_str_pool (PoolPointer idx );
612506
613- void bib_set_str_pool (PoolPointer idx , ASCIICode code );
614-
615507StrNumber bib_str_ptr (void );
616508
617509void bib_set_str_ptr (StrNumber ptr );
@@ -620,24 +512,14 @@ PoolPointer bib_str_start(StrNumber s);
620512
621513void bib_set_str_start (StrNumber s , PoolPointer ptr );
622514
623- uintptr_t bib_pool_size (void );
624-
625515uintptr_t bib_max_strings (void );
626516
627- PoolPointer bib_pool_ptr (void );
628-
629517void bib_set_pool_ptr (PoolPointer ptr );
630518
631- CResultStr bib_make_string (void );
632-
633- void add_buf_pool (StrNumber p_str );
634-
635519CResultLookup str_lookup (BufTy buf , BufPointer ptr , BufPointer len , StrIlk ilk , bool insert );
636520
637521CResult pre_def_certain_strings (Bibtex * ctx );
638522
639- void add_out_pool (Bibtex * ctx , StrNumber str );
640-
641523bool scan1 (ASCIICode char1 );
642524
643525bool scan1_white (ASCIICode char1 );
@@ -661,20 +543,6 @@ CResultBool scan_and_store_the_field_value_and_eat_white(Bibtex *ctx,
661543 ASCIICode right_outer_delim ,
662544 HashPointer field_name_loc );
663545
664- CResult decr_brace_level (const ExecCtx * ctx , StrNumber pop_lit_var , int32_t * brace_level );
665-
666- CResult check_brace_level (const ExecCtx * ctx , StrNumber pop_lit_var , int32_t brace_level );
667-
668- CResult name_scan_for_and (ExecCtx * ctx , StrNumber pop_lit_var , int32_t * brace_level );
669-
670- CResultBool von_token_found (BufPointer * name_bf_ptr , BufPointer name_bf_xptr );
671-
672- CResult von_name_ends_and_last_name_starts_stuff (BufPointer last_end ,
673- BufPointer von_start ,
674- BufPointer * von_end ,
675- BufPointer * name_bf_ptr ,
676- BufPointer * name_bf_xptr );
677-
678546#ifdef __cplusplus
679547} // extern "C"
680548#endif // __cplusplus
0 commit comments