@@ -539,7 +539,7 @@ bool read_preproc_directive(void)
539539 if (lex_accept (T_elipsis ))
540540 macro -> is_variadic = true;
541541
542- macro -> start_source_idx = SOURCE -> size ;
542+ macro -> start_source_idx = source_idx ;
543543 skip_macro_body ();
544544 } else {
545545 /* Empty alias, may be dummy alias serves as include guard */
@@ -1025,8 +1025,8 @@ void read_expr_operand(block_t *parent, basic_block_t **bb)
10251025 macro_t * mac = find_macro (token );
10261026
10271027 if (!strcmp (token , "__VA_ARGS__" )) {
1028- /* 'size ' has pointed at the character after __VA_ARGS__ */
1029- int remainder , t = SOURCE -> size ;
1028+ /* 'source_idx ' has pointed at the character after __VA_ARGS__ */
1029+ int remainder , t = source_idx ;
10301030 macro_t * macro = parent -> macro ;
10311031
10321032 if (!macro )
@@ -1036,13 +1036,13 @@ void read_expr_operand(block_t *parent, basic_block_t **bb)
10361036
10371037 remainder = macro -> num_params - macro -> num_param_defs ;
10381038 for (int i = 0 ; i < remainder ; i ++ ) {
1039- SOURCE -> size = macro -> params [macro -> num_params - remainder + i ];
1040- next_char = SOURCE -> elements [ SOURCE -> size ] ;
1039+ source_idx = macro -> params [macro -> num_params - remainder + i ];
1040+ next_char = dynarr_get_byte ( SOURCE , source_idx ) ;
10411041 next_token = lex_token ();
10421042 read_expr (parent , bb );
10431043 }
1044- SOURCE -> size = t ;
1045- next_char = SOURCE -> elements [ SOURCE -> size ] ;
1044+ source_idx = t ;
1045+ next_char = dynarr_get_byte ( SOURCE , source_idx ) ;
10461046 next_token = lex_token ();
10471047 } else if (mac ) {
10481048 if (parent -> macro )
@@ -1052,18 +1052,18 @@ void read_expr_operand(block_t *parent, basic_block_t **bb)
10521052 mac -> num_params = 0 ;
10531053 lex_expect (T_identifier );
10541054
1055- /* 'size ' has pointed at the first parameter */
1055+ /* 'source_idx ' has pointed at the first parameter */
10561056 while (!lex_peek (T_close_bracket , NULL )) {
1057- mac -> params [mac -> num_params ++ ] = SOURCE -> size ;
1057+ mac -> params [mac -> num_params ++ ] = source_idx ;
10581058 do {
10591059 next_token = lex_token ();
10601060 } while (next_token != T_comma &&
10611061 next_token != T_close_bracket );
10621062 }
1063- /* move 'size ' to the macro body */
1064- macro_return_idx = SOURCE -> size ;
1065- SOURCE -> size = mac -> start_source_idx ;
1066- next_char = SOURCE -> elements [ SOURCE -> size ] ;
1063+ /* move 'source_idx ' to the macro body */
1064+ macro_return_idx = source_idx ;
1065+ source_idx = mac -> start_source_idx ;
1066+ next_char = dynarr_get_byte ( SOURCE , source_idx ) ;
10671067 lex_expect (T_close_bracket );
10681068
10691069 skip_newline = 0 ;
@@ -1075,13 +1075,13 @@ void read_expr_operand(block_t *parent, basic_block_t **bb)
10751075 macro_return_idx = 0 ;
10761076 } else if (macro_param_idx ) {
10771077 /* "expand" the argument from where it comes from */
1078- int t = SOURCE -> size ;
1079- SOURCE -> size = macro_param_idx ;
1080- next_char = SOURCE -> elements [ SOURCE -> size ] ;
1078+ int t = source_idx ;
1079+ source_idx = macro_param_idx ;
1080+ next_char = dynarr_get_byte ( SOURCE , source_idx ) ;
10811081 next_token = lex_token ();
10821082 read_expr (parent , bb );
1083- SOURCE -> size = t ;
1084- next_char = SOURCE -> elements [ SOURCE -> size ] ;
1083+ source_idx = t ;
1084+ next_char = dynarr_get_byte ( SOURCE , source_idx ) ;
10851085 next_token = lex_token ();
10861086 } else if (con ) {
10871087 vd = require_var (parent );
@@ -2716,17 +2716,17 @@ basic_block_t *read_body_statement(block_t *parent, basic_block_t *bb)
27162716 mac -> num_params = 0 ;
27172717 lex_expect (T_identifier );
27182718
2719- /* 'size ' has pointed at the first parameter */
2719+ /* 'source_idx ' has pointed at the first parameter */
27202720 while (!lex_peek (T_close_bracket , NULL )) {
2721- mac -> params [mac -> num_params ++ ] = SOURCE -> size ;
2721+ mac -> params [mac -> num_params ++ ] = source_idx ;
27222722 do {
27232723 next_token = lex_token ();
27242724 } while (next_token != T_comma && next_token != T_close_bracket );
27252725 }
2726- /* move 'size ' to the macro body */
2727- macro_return_idx = SOURCE -> size ;
2728- SOURCE -> size = mac -> start_source_idx ;
2729- next_char = SOURCE -> elements [ SOURCE -> size ] ;
2726+ /* move 'source_idx ' to the macro body */
2727+ macro_return_idx = source_idx ;
2728+ source_idx = mac -> start_source_idx ;
2729+ next_char = dynarr_get_byte ( SOURCE , source_idx ) ;
27302730 lex_expect (T_close_bracket );
27312731
27322732 skip_newline = 0 ;
@@ -3009,8 +3009,8 @@ void parse_internal(void)
30093009 func -> bbs = arena_alloc (BB_ARENA , sizeof (basic_block_t ));
30103010
30113011 /* lexer initialization */
3012- SOURCE -> size = 0 ;
3013- next_char = SOURCE -> elements [ 0 ] ;
3012+ source_idx = 0 ;
3013+ next_char = dynarr_get_byte ( SOURCE , 0 ) ;
30143014 lex_expect (T_start );
30153015
30163016 do {
@@ -3051,7 +3051,7 @@ void load_source_file(char *file)
30513051 snprintf (path + c + 1 , inclusion_path_len , "%s" , buffer + 10 );
30523052 load_source_file (path );
30533053 } else {
3054- strbuf_puts (SOURCE , buffer );
3054+ dynarr_extend (SOURCE , buffer , strlen ( buffer ) );
30553055 }
30563056 }
30573057
0 commit comments