WONKY



LOG | FILES | OVERVIEW


#ifndef WONKY_PROGRAM_H
#define WONKY_PROGRAM_H WONKY_PROGRAM_H
#include <program.hh>

#include <queue.h>
#include <map.h>
#include <linkage.h>

#include <scope.h>
#include <lexer.h>
#include <gcc_string.h>
#include <gcc_arguments.h>
#include <parse_translation_unit.h>
#include <common.h>
#include <ast.h>
#include <wonky_malloc.h>
#include <translation_unit.h>


struct Program
{
	/*AST*/
	struct Queue *translation_units;

	struct Queue *source_files;

	/*errors*/
	struct Queue *errors;
	size_t number_of_errors_when_last_checked;
	_Bool continue_to_parse;

	/*
	   the type node structures from 
	   all the translation units are stored here
	 */
	struct Map *types;

	struct Map *preprocessing_translation_units;
	struct Queue *preprocessing_translation_units_to_be_compiled;

	struct Linkage *external_linkage;


	/*ASTs*/
	struct Queue *functions_without_a_definition;
	struct Queue *external_objects_without_an_initialiser;
	

	size_t current_translation_unit_number;
};
struct Translation_Data
{
	struct Token_Pointer *token_pointer;
	struct Linkage *internal_linkage;
	struct Program *program;

};

struct Program* get_program();
struct Translation_Data* get_translation_data(struct Preprocessing_Translation_Unit *start_unit,struct Linkage *internal_linkage,struct Program *program);
struct Translation_Data* get_dummy_translation_data_for_parsing_const_expressions(struct Token_Pointer *ptr);
struct Program* parse_program(char **base_source_names);
struct Preprocessing_Translation_Unit* program_get_translation_unit(struct Program *program,char *filename,size_t filename_size);

void entype_program(struct Program *program);
void program_stop_parsing(struct Program *program);

_Bool has_new_errors(struct Translation_Data *translation_data);
_Bool has_no_tokens(struct Translation_Data *translation_data);

_Bool program_has_new_errors(struct Program *program);
_Bool program_has_errors(struct Program *program);


void delete_program(struct Program *program);
void delete_translation_data(struct Translation_Data *translation_data);
void destroy_translation_data(struct Translation_Data *translation_data);

void find_functions_without_definitions(struct Program *program);
void find_external_objects_without_an_initialiser(struct Program *program);

void push_if_tree_is_undefined_function(struct AST *tree,struct Queue *where_to_push);
void push_if_tree_is_uninitialised_object(struct AST *tree,struct Queue *where_to_push);

_Bool check(struct Translation_Data *translation_data,enum LEXER_TYPE kw);
_Bool get_and_check(struct Translation_Data *translation_data,enum LEXER_TYPE kw);
_Bool get_and_check_unsafe(struct Translation_Data *translation_data,enum LEXER_TYPE kw);
void chomp(struct Translation_Data *translation_data);
enum LEXER_TYPE kw_get(struct Translation_Data *translation_data);
struct token* get_next_token(struct Translation_Data *translation_data);
_Bool translation_eof(struct Translation_Data *translation_data);


#endif