Skip to content

Commit

Permalink
Refactor: remove old code dealing with alternative file names
Browse files Browse the repository at this point in the history
  • Loading branch information
positively-charged committed Jan 27, 2017
1 parent 1d56e53 commit db9dd48
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 38 deletions.
4 changes: 2 additions & 2 deletions src/builtin.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ void init_setup( struct setup* setup, struct task* task, int lang ) {

void setup_func( struct setup* setup, int entry ) {
struct func* func = t_alloc_func();
t_init_pos_id( &func->object.pos, ALTERN_FILENAME_COMPILER );
t_init_pos_id( &func->object.pos, INTERNALFILE_COMPILER );
func->object.resolved = true;
func->name = t_extend_name( t_extend_name( setup->task->root_name, "." ),
g_funcs[ entry ].name );
Expand Down Expand Up @@ -543,7 +543,7 @@ void setup_empty_string_default_value( struct setup* setup,
struct indexed_string_usage* usage = t_alloc_indexed_string_usage();
usage->string = string;
struct expr* expr = t_alloc_expr();
t_init_pos_id( &expr->pos, ALTERN_FILENAME_COMPILER );
t_init_pos_id( &expr->pos, INTERNALFILE_COMPILER );
expr->root = &usage->node;
expr->spec = SPEC_STR;
expr->value = string->index;
Expand Down
2 changes: 1 addition & 1 deletion src/parse/dec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1750,7 +1750,7 @@ void p_init_paren_reading( struct parse* parse,
struct paren_reading* reading ) {
reading->var = NULL;
reading->func = NULL;
t_init_pos_id( &reading->cast.pos, ALTERN_FILENAME_COMPILER );
t_init_pos_id( &reading->cast.pos, INTERNALFILE_COMPILER );
reading->cast.spec = SPEC_NONE;
}

Expand Down
4 changes: 2 additions & 2 deletions src/parse/library.c
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ struct using_item* alloc_using_item( void ) {
item->name = NULL;
item->usage_name = NULL;
item->alias = NULL;
t_init_pos_id( &item->pos, ALTERN_FILENAME_COMPILER );
t_init_pos_id( &item->pos, INTERNALFILE_COMPILER );
item->type = USINGITEM_OBJECT;
return item;
}
Expand Down Expand Up @@ -770,7 +770,7 @@ void p_create_cmdline_library_links( struct parse* parse ) {
list_iter_init( &i, &parse->task->options->library_links );
while ( ! list_end( &i ) ) {
struct pos pos;
t_init_pos_id( &pos, ALTERN_FILENAME_COMMANDLINE );
t_init_pos_id( &pos, INTERNALFILE_COMMANDLINE );
add_library_link( parse, list_data( &i ), &pos );
list_next( &i );
}
Expand Down
4 changes: 2 additions & 2 deletions src/parse/token/dirc.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ struct macro* alloc_macro( struct parse* parse ) {
macro->param_tail = NULL;
macro->body = NULL;
macro->body_tail = NULL;
t_init_pos_id( &macro->pos, ALTERN_FILENAME_COMPILER );
t_init_pos_id( &macro->pos, INTERNALFILE_COMPILER );
macro->param_count = 0;
macro->predef = PREDEFMACRO_NONE;
macro->func_like = false;
Expand Down Expand Up @@ -924,7 +924,7 @@ void p_define_cmdline_macros( struct parse* parse ) {
token->length = strlen( CMDLINEMACRO_TEXT );
macro = alloc_macro( parse );
macro->name = name;
macro->pos.id = ALTERN_FILENAME_COMMANDLINE;
macro->pos.id = INTERNALFILE_COMMANDLINE;
append_token( macro, token );
append_macro( parse, macro );
}
Expand Down
2 changes: 1 addition & 1 deletion src/parse/token/stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -1007,7 +1007,7 @@ void p_init_token( struct token* token ) {
token->next = NULL;
token->modifiable_text = NULL;
token->text = "";
t_init_pos_id( &token->pos, ALTERN_FILENAME_COMPILER );
t_init_pos_id( &token->pos, INTERNALFILE_COMPILER );
token->type = TK_END;
token->length = 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/semantic/phase.c
Original file line number Diff line number Diff line change
Expand Up @@ -1511,7 +1511,7 @@ struct alias* s_alloc_alias( void ) {

void s_init_alias( struct alias* alias ) {
t_init_object( &alias->object, NODE_ALIAS );
t_init_pos_id( &alias->object.pos, ALTERN_FILENAME_COMPILER );
t_init_pos_id( &alias->object.pos, INTERNALFILE_COMPILER );
alias->target = NULL;
alias->implicit = false;
}
Expand Down
21 changes: 2 additions & 19 deletions src/task.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ void t_init( struct task* task, struct options* options, jmp_buf* bail ) {
task->empty_string = t_intern_string( task, "", 0 );
task->library_main = NULL;
list_init( &task->libraries );
list_init( &task->altern_filenames );
task->last_id = 0;
task->compile_time = time( NULL );
gbuf_init( &task->growing_buffer );
Expand Down Expand Up @@ -100,7 +99,7 @@ void t_init( struct task* task, struct options* options, jmp_buf* bail ) {

// Dummy nodes.
struct expr* expr = t_alloc_expr();
expr->pos.id = ALTERN_FILENAME_COMPILER;
expr->pos.id = INTERNALFILE_COMPILER;
expr->pos.line = 0;
expr->pos.column = 0;
expr->spec = SPEC_RAW;
Expand Down Expand Up @@ -767,22 +766,6 @@ struct indexed_string* t_lookup_string( struct task* task, int index ) {
return NULL;
}

int t_add_altern_filename( struct task* task, const char* filename ) {
int id = ALTERN_FILENAME_INITIAL_ID;
list_iter_t i;
list_iter_init( &i, &task->altern_filenames );
while ( ! list_end( &i ) ) {
const char* added_filename = list_data( &i );
if ( strcmp( filename, added_filename ) == 0 ) {
return id;
}
--id;
list_next( &i );
}
list_append( &task->altern_filenames, ( void* ) filename );
return id;
}

struct constant* t_alloc_constant( void ) {
struct constant* constant = mem_slot_alloc( sizeof( *constant ) );
t_init_object( &constant->object, NODE_CONSTANT );
Expand Down Expand Up @@ -1096,7 +1079,7 @@ struct ref_func* t_alloc_ref_func( void ) {
struct type_alias* t_alloc_type_alias( void ) {
struct type_alias* alias = mem_alloc( sizeof( *alias ) );
t_init_object( &alias->object, NODE_TYPE_ALIAS );
t_init_pos_id( &alias->object.pos, ALTERN_FILENAME_COMPILER );
t_init_pos_id( &alias->object.pos, INTERNALFILE_COMPILER );
alias->ref = NULL;
alias->structure = NULL;
alias->enumeration = NULL;
Expand Down
10 changes: 0 additions & 10 deletions src/task.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,6 @@ struct include_history_entry {
bool imported;
};

enum {
ALTERN_FILENAME_NONE,
ALTERN_FILENAME_COMPILER,
ALTERN_FILENAME_COMMANDLINE,
ALTERN_FILENAME_INITIAL_ID,
};

struct text_buffer {
struct text_buffer* prev;
char* start;
Expand Down Expand Up @@ -1183,8 +1176,6 @@ struct task {
struct library* library_main;
// Imported libraries come first, followed by the main library.
struct list libraries;
// List of alternative filenames. Each entry is a string.
struct list altern_filenames;
int last_id;
time_t compile_time;
struct gbuf growing_buffer;
Expand Down Expand Up @@ -1237,7 +1228,6 @@ struct indexed_string* t_intern_string( struct task* task,
struct indexed_string* t_intern_string_copy( struct task* task,
const char* value, int length );
struct indexed_string* t_lookup_string( struct task* task, int index );
int t_add_altern_filename( struct task* task, const char* filename );
struct ns* t_alloc_ns( struct name* name );
void t_append_unresolved_namespace_object( struct ns_fragment* fragment,
struct object* object );
Expand Down

0 comments on commit db9dd48

Please sign in to comment.