2007-12-30 17:41:49 +01:00
|
|
|
/***************************************************************************
|
|
|
|
|
2011-12-31 03:39:20 +01:00
|
|
|
gbc_compile.h
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2018-02-12 02:53:46 +01:00
|
|
|
(c) 2000-2017 Benoît Minisini <g4mba5@gmail.com>
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-31 03:39:20 +01:00
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
any later version.
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-31 03:39:20 +01:00
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2011-12-31 03:39:20 +01:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
|
|
MA 02110-1301, USA.
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#ifndef _COMPILE_H
|
|
|
|
#define _COMPILE_H
|
|
|
|
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
|
|
|
#include "gb_array.h"
|
|
|
|
#include "gb_buffer.h"
|
|
|
|
#include "gb_table.h"
|
|
|
|
#include "gb_alloc.h"
|
|
|
|
|
|
|
|
#include "gb_limit.h"
|
|
|
|
#include "gb_reserved.h"
|
|
|
|
#include "gbc_read.h"
|
2012-01-28 10:55:55 +01:00
|
|
|
#include "gbc_form.h"
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
#include "gbc_class.h"
|
|
|
|
|
2012-09-04 09:29:39 +02:00
|
|
|
enum {
|
|
|
|
MSG_ERROR = 0,
|
|
|
|
MSG_WARNING = 1
|
|
|
|
};
|
|
|
|
|
2019-05-08 06:13:04 +02:00
|
|
|
enum {
|
|
|
|
JOB_STEP_NONE = 0,
|
|
|
|
JOB_STEP_READ = 1,
|
|
|
|
JOB_STEP_CODE = 2,
|
|
|
|
JOB_STEP_TREE = 3,
|
|
|
|
JOB_STEP_OUTPUT = 4
|
|
|
|
};
|
|
|
|
|
2007-12-30 17:41:49 +01:00
|
|
|
typedef
|
2010-08-29 22:51:10 +02:00
|
|
|
struct {
|
2012-05-05 02:39:43 +02:00
|
|
|
char *name; // source file name
|
|
|
|
int line; // current line number
|
|
|
|
int first_line; // first line to compile
|
|
|
|
int max_line; // maximum line number
|
|
|
|
char *source; // source file contents
|
2019-05-08 06:13:04 +02:00
|
|
|
unsigned step : 3; // compiler step (JOB_STEP_*)
|
2012-05-05 02:39:43 +02:00
|
|
|
unsigned debug : 1; // if debugging information must be generated
|
|
|
|
unsigned trans : 1; // if translation files must be generated
|
|
|
|
unsigned is_module : 1; // if the source file is a module
|
|
|
|
unsigned is_form : 1; // if the source is a class form
|
|
|
|
unsigned declared : 1; // ?
|
|
|
|
unsigned nobreak : 1; // no breakpoint
|
|
|
|
unsigned exported : 1; // there are some exported class
|
|
|
|
unsigned all : 1; // compile everything
|
|
|
|
unsigned swap : 1; // endianness must be swapped
|
|
|
|
unsigned public_module : 1; // modules symbols are public by default
|
|
|
|
unsigned trans_error : 1; // display error messages in a translatable form
|
|
|
|
unsigned no_old_read_syntax : 1; // do not compile the old read syntax
|
|
|
|
unsigned exec : 1; // we are compiling for an executable
|
2012-09-04 09:29:39 +02:00
|
|
|
unsigned warnings : 1; // if warnings must be printed
|
2020-05-09 20:55:04 +02:00
|
|
|
unsigned _reserved : 15; // reserved
|
2012-05-05 02:39:43 +02:00
|
|
|
char *output; // output file
|
|
|
|
PATTERN *pattern; // lexical analyze
|
|
|
|
int pattern_count; // number of patterns
|
2019-05-08 06:13:04 +02:00
|
|
|
int *pattern_pos; // position of a pattern in its line
|
2012-05-05 02:39:43 +02:00
|
|
|
PATTERN *current; // current pattern
|
|
|
|
PATTERN *end; // last pattern
|
|
|
|
FUNCTION *func; // current function being compiled
|
|
|
|
CLASS *class; // current class being compiled
|
|
|
|
char *form; // form file name
|
|
|
|
const FORM_FAMILY *family; // form file family
|
|
|
|
char *tname; // translation file name
|
|
|
|
int default_library; // default library name for extern declarations
|
2012-11-10 01:19:53 +01:00
|
|
|
const char **help; // help comments array
|
|
|
|
int help_first_line; // line of the first help comment
|
|
|
|
char *hname; // help file name
|
2019-05-08 06:13:04 +02:00
|
|
|
PATTERN *column; // where to search the current column
|
2010-08-29 22:51:10 +02:00
|
|
|
}
|
|
|
|
COMPILE;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
#ifndef __GBC_COMPILE_C
|
|
|
|
|
2020-05-09 20:55:04 +02:00
|
|
|
EXTERN bool COMP_verbose;
|
2007-12-30 17:41:49 +01:00
|
|
|
EXTERN COMPILE COMP_current;
|
|
|
|
EXTERN char *COMP_root;
|
|
|
|
EXTERN char *COMP_project;
|
2010-05-03 12:19:13 +02:00
|
|
|
EXTERN char *COMP_project_name;
|
2007-12-30 17:41:49 +01:00
|
|
|
EXTERN char *COMP_info_path;
|
2012-01-28 10:55:55 +01:00
|
|
|
EXTERN FORM_FAMILY COMP_form_families[];
|
2015-01-16 01:31:59 +01:00
|
|
|
EXTERN uint COMPILE_version;
|
2007-12-30 17:41:49 +01:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define JOB (&COMP_current)
|
|
|
|
|
2008-05-11 20:07:16 +02:00
|
|
|
void COMPILE_init(void);
|
|
|
|
void COMPILE_load(void);
|
|
|
|
void COMPILE_exit(void);
|
2012-12-19 22:55:16 +01:00
|
|
|
void COMPILE_begin(const char *file, bool trans, bool debug);
|
2008-05-11 20:07:16 +02:00
|
|
|
void COMPILE_end(void);
|
|
|
|
void COMPILE_export_class(char *name);
|
2010-05-22 20:02:34 +02:00
|
|
|
void COMPILE_add_class(const char *name, int len);
|
2019-01-19 01:03:57 +01:00
|
|
|
void COMPILE_end_class(void);
|
2010-05-22 20:02:34 +02:00
|
|
|
void COMPILE_enum_class(char **name, int *len);
|
2012-09-04 09:29:39 +02:00
|
|
|
void COMPILE_print(int type, int line, const char *msg, ...);
|
2020-02-22 15:57:46 +01:00
|
|
|
void COMPILE_create_file(FILE **fw, const char *file);
|
2020-05-09 20:55:04 +02:00
|
|
|
void COMPILE_add_component(const char *name);
|
2007-12-30 17:41:49 +01:00
|
|
|
|
2019-05-08 06:13:04 +02:00
|
|
|
#define COMPILE_get_column(_pattern) (JOB->pattern_pos[(_pattern) - JOB->pattern])
|
|
|
|
|
2007-12-30 17:41:49 +01:00
|
|
|
#endif
|