@@ -408,7 +408,7 @@ bool read_preproc_directive()
408408 if (lex_accept (T_elipsis ))
409409 macro -> is_variadic = true;
410410
411- macro -> start_source_idx = source_idx ;
411+ macro -> start_source_idx = SOURCE -> size ;
412412 skip_macro_body ();
413413 } else {
414414 /* Empty alias, may be dummy alias serves as include guard */
@@ -891,8 +891,8 @@ void read_expr_operand(block_t *parent, basic_block_t **bb)
891891 macro_t * mac = find_macro (token );
892892
893893 if (!strcmp (token , "__VA_ARGS__" )) {
894- /* 'source_idx ' has pointed at the character after __VA_ARGS__ */
895- int remainder , t = source_idx ;
894+ /* 'size ' has pointed at the character after __VA_ARGS__ */
895+ int remainder , t = SOURCE -> size ;
896896 macro_t * macro = parent -> macro ;
897897
898898 if (!macro )
@@ -902,13 +902,13 @@ void read_expr_operand(block_t *parent, basic_block_t **bb)
902902
903903 remainder = macro -> num_params - macro -> num_param_defs ;
904904 for (int i = 0 ; i < remainder ; i ++ ) {
905- source_idx = macro -> params [macro -> num_params - remainder + i ];
906- next_char = SOURCE [ source_idx ];
905+ SOURCE -> size = macro -> params [macro -> num_params - remainder + i ];
906+ next_char = SOURCE -> elements [ SOURCE -> size ];
907907 next_token = lex_token ();
908908 read_expr (parent , bb );
909909 }
910- source_idx = t ;
911- next_char = SOURCE [ source_idx ];
910+ SOURCE -> size = t ;
911+ next_char = SOURCE -> elements [ SOURCE -> size ];
912912 next_token = lex_token ();
913913 } else if (mac ) {
914914 if (parent -> macro )
@@ -918,18 +918,18 @@ void read_expr_operand(block_t *parent, basic_block_t **bb)
918918 mac -> num_params = 0 ;
919919 lex_expect (T_identifier );
920920
921- /* 'source_idx ' has pointed at the first parameter */
921+ /* 'size ' has pointed at the first parameter */
922922 while (!lex_peek (T_close_bracket , NULL )) {
923- mac -> params [mac -> num_params ++ ] = source_idx ;
923+ mac -> params [mac -> num_params ++ ] = SOURCE -> size ;
924924 do {
925925 next_token = lex_token ();
926926 } while (next_token != T_comma &&
927927 next_token != T_close_bracket );
928928 }
929- /* move 'source_idx ' to the macro body */
930- macro_return_idx = source_idx ;
931- source_idx = mac -> start_source_idx ;
932- next_char = SOURCE [ source_idx ];
929+ /* move 'size ' to the macro body */
930+ macro_return_idx = SOURCE -> size ;
931+ SOURCE -> size = mac -> start_source_idx ;
932+ next_char = SOURCE -> elements [ SOURCE -> size ];
933933 lex_expect (T_close_bracket );
934934
935935 skip_newline = 0 ;
@@ -941,13 +941,13 @@ void read_expr_operand(block_t *parent, basic_block_t **bb)
941941 macro_return_idx = 0 ;
942942 } else if (macro_param_idx ) {
943943 /* "expand" the argument from where it comes from */
944- int t = source_idx ;
945- source_idx = macro_param_idx ;
946- next_char = SOURCE [ source_idx ];
944+ int t = SOURCE -> size ;
945+ SOURCE -> size = macro_param_idx ;
946+ next_char = SOURCE -> elements [ SOURCE -> size ];
947947 next_token = lex_token ();
948948 read_expr (parent , bb );
949- source_idx = t ;
950- next_char = SOURCE [ source_idx ];
949+ SOURCE -> size = t ;
950+ next_char = SOURCE -> elements [ SOURCE -> size ];
951951 next_token = lex_token ();
952952 } else if (con ) {
953953 ph1_ir = add_ph1_ir (OP_load_constant );
@@ -3075,17 +3075,17 @@ basic_block_t *read_body_statement(block_t *parent, basic_block_t *bb)
30753075 mac -> num_params = 0 ;
30763076 lex_expect (T_identifier );
30773077
3078- /* 'source_idx ' has pointed at the first parameter */
3078+ /* 'size ' has pointed at the first parameter */
30793079 while (!lex_peek (T_close_bracket , NULL )) {
3080- mac -> params [mac -> num_params ++ ] = source_idx ;
3080+ mac -> params [mac -> num_params ++ ] = SOURCE -> size ;
30813081 do {
30823082 next_token = lex_token ();
30833083 } while (next_token != T_comma && next_token != T_close_bracket );
30843084 }
3085- /* move 'source_idx ' to the macro body */
3086- macro_return_idx = source_idx ;
3087- source_idx = mac -> start_source_idx ;
3088- next_char = SOURCE [ source_idx ];
3085+ /* move 'size ' to the macro body */
3086+ macro_return_idx = SOURCE -> size ;
3087+ SOURCE -> size = mac -> start_source_idx ;
3088+ next_char = SOURCE -> elements [ SOURCE -> size ];
30893089 lex_expect (T_close_bracket );
30903090
30913091 skip_newline = 0 ;
@@ -3377,8 +3377,8 @@ void parse_internal()
33773377 GLOBAL_FUNC .fn -> bbs = calloc (1 , sizeof (basic_block_t ));
33783378
33793379 /* lexer initialization */
3380- source_idx = 0 ;
3381- next_char = SOURCE [0 ];
3380+ SOURCE -> size = 0 ;
3381+ next_char = SOURCE -> elements [0 ];
33823382 lex_expect (T_start );
33833383
33843384 do {
@@ -3415,8 +3415,8 @@ void load_source_file(char *file)
34153415 snprintf (path + c + 1 , inclusion_path_len , "%s" , buffer + 10 );
34163416 load_source_file (path );
34173417 } else {
3418- strcpy (SOURCE + source_idx , buffer );
3419- source_idx += strlen (buffer );
3418+ strcpy (SOURCE -> elements + SOURCE -> size , buffer );
3419+ SOURCE -> size += strlen (buffer );
34203420 }
34213421 }
34223422 fclose (f );
0 commit comments