@@ -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 );
@@ -3072,17 +3072,17 @@ basic_block_t *read_body_statement(block_t *parent, basic_block_t *bb)
30723072 mac -> num_params = 0 ;
30733073 lex_expect (T_identifier );
30743074
3075- /* 'source_idx ' has pointed at the first parameter */
3075+ /* 'size ' has pointed at the first parameter */
30763076 while (!lex_peek (T_close_bracket , NULL )) {
3077- mac -> params [mac -> num_params ++ ] = source_idx ;
3077+ mac -> params [mac -> num_params ++ ] = SOURCE -> size ;
30783078 do {
30793079 next_token = lex_token ();
30803080 } while (next_token != T_comma && next_token != T_close_bracket );
30813081 }
3082- /* move 'source_idx ' to the macro body */
3083- macro_return_idx = source_idx ;
3084- source_idx = mac -> start_source_idx ;
3085- next_char = SOURCE [ source_idx ];
3082+ /* move 'size ' to the macro body */
3083+ macro_return_idx = SOURCE -> size ;
3084+ SOURCE -> size = mac -> start_source_idx ;
3085+ next_char = SOURCE -> elements [ SOURCE -> size ];
30863086 lex_expect (T_close_bracket );
30873087
30883088 skip_newline = 0 ;
@@ -3374,8 +3374,8 @@ void parse_internal()
33743374 GLOBAL_FUNC .fn -> bbs = calloc (1 , sizeof (basic_block_t ));
33753375
33763376 /* lexer initialization */
3377- source_idx = 0 ;
3378- next_char = SOURCE [0 ];
3377+ SOURCE -> size = 0 ;
3378+ next_char = SOURCE -> elements [0 ];
33793379 lex_expect (T_start );
33803380
33813381 do {
@@ -3414,8 +3414,8 @@ void load_source_file(char *file)
34143414 strcpy (path + c , buffer + 10 );
34153415 load_source_file (path );
34163416 } else {
3417- strcpy (SOURCE + source_idx , buffer );
3418- source_idx += strlen (buffer );
3417+ strcpy (SOURCE -> elements + SOURCE -> size , buffer );
3418+ SOURCE -> size += strlen (buffer );
34193419 }
34203420 }
34213421 fclose (f );
0 commit comments