Lhogho  0.0.028
 All Data Structures Files Functions Variables Typedefs Macros Pages
options.h
Go to the documentation of this file.
1 //
2 // Project: Lhogho
3 // File: options.h
4 //
5 // Copyright (C) 2007 P.Boytchev
6 //
7 // Revision history:
8 // 2007-05-31 - file created
9 // 2007-06-01 - case insensitive option
10 // 2007-06-02 - option_source_filename
11 // - OPTION_MEMORY, OPTION_MEMORY_LONG
12 // - option_variables
13 // 2007-06-07 - definitions spread to where they belong
14 // 2007-06-11 - added option -Zuv (--Zuser-variables)
15 // - added option -x (--executable)
16 // 2007-06-19 - added XALLOC() and xalloc()
17 // 2007-06-21 - OPTION_ASM, OPTION_ASM_LONG
18 // 2007-07-09 - OPTION_RUNTIME, OPTION_RUNTIME_LONG
19 // 2007-07-11 - OPTION_TRADITIONAL, OPTION_TRADITIONAL_LONG
20 // 2007-07-29 - set_options()
21 // 2007-09-23 - OPTION_MEMORY_STAT, OPTION_MEMORY_STAT_LONG
22 // 2007-10-06 - added REALLOC() and realloc()
23 // 2009-05-18 - OPTION_EXECCOMP, OPTION_EXECCOMP_LONG
24 // 2012-01-02 - Command-line options are translatable
25 // 2012-10-14 - Adding PATH_SLASH, PATH_DELIM
26 //
27 //
28 // This program is free software; you can redistribute it and/or modify
29 // it under the terms of the GNU General Public License as published by
30 // the Free Software Foundation; either version 2 of the License, or
31 // (at your option) any later version.
32 //
33 // This program is distributed in the hope that it will be useful,
34 // but WITHOUT ANY WARRANTY; without even the implied warranty of
35 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36 // GNU General Public License for more details.
37 //
38 // You should have received a copy of the GNU General Public License
39 // along with this program; if not, write to the Free Software
40 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
41 //
42 
43 
44 #ifndef LHOGHO_OPTIONS_H
45 #define LHOGHO_OPTIONS_H
46 
47 #include "atoms.h"
48 
49 
50 
51 
52 // ===========================================================
54 // ===========================================================
55 // @{
56 #define OPTION_HELP option_turned_on[0]
57 #define OPTION_MAKE_EXECUTABLE option_turned_on[1]
58 #define OPTION_MAKE_EXECUTABLE_COMPILER option_turned_on[2]
59 #define OPTION_CASE_INSENSITIVE option_turned_on[3]
60 #define OPTION_TRADITIONAL option_turned_on[4]
61 
62 #define OPTION_ASSEMBLER option_turned_on[5]
63 #define OPTION_MEMORY_STATISTICS option_turned_on[6]
64 #define OPTION_DETAILED_MEMORY_STATISTICS option_turned_on[7]
65 #define OPTION_RUNTIME option_turned_on[8]
66 #define OPTION_DUMP_AST option_turned_on[9]
67 #define OPTION_VARIABLES option_turned_on[10]
68 #define OPTION_USER_VARIABLES option_turned_on[11]
69 
70 #define FIRST_BASIC_OPTION 0
71 #define LAST_BASIC_OPTION 4
72 
73 #define FIRST_ADVANCED_OPTION 5
74 #define LAST_ADVANCED_OPTION 11
75 
76 #define OPTIONS_COUNT (LAST_ADVANCED_OPTION-FIRST_BASIC_OPTION+1)
77 
78 #ifdef ADVANCED
79  #define OPTIONS_SUPPORTED_COUNT OPTIONS_COUNT
80 #else
81  #define OPTIONS_SUPPORTED_COUNT (LAST_BASIC_OPTION-FIRST_BASIC_OPTION+1)
82 #endif
83 
84 // @}
85 
86 
87 extern int option_turned_on [OPTIONS_COUNT];
88 
89 
90 #ifdef WINDOWS
91  #define EXE_EXT ".exe"
92  #define PATH_SLASH "\\"
93  #define PATH_DELIM ";"
94 #else
95  #define EXE_EXT ""
96  #define PATH_SLASH "/"
97  #define PATH_DELIM ":"
98 #endif
99 #define EXE_EXT2 ".run"
100 
101 
102 
103 
104 extern int option_dump_ast;
105 extern int option_make_executable;
107 extern int option_case_insensitive;
108 extern int option_traditional;
109 extern int option_memory_statistics;
111 extern int option_variables;
112 extern int option_user_variables;
113 extern int option_assembler;
114 extern int option_runtime;
115 
116 extern char* option_compiler_filename;
118 extern char* option_source_filename;
120 
121 extern int standalone;
123 
124 extern void init_options( );
125 extern void finit_options( );
126 extern void set_options( int argc, char*argv[] );
127 extern void output_compiler_name( int show_help );
128 
129 #ifdef ADVANCED
130 extern void dump_statistics( );
131 #endif
132 
133 
134 // ===========================================================
141 // ===========================================================
142 #ifdef ADVANCED
143 typedef struct {
144  int allocs;
145  int deallocs;
146  int max;
147 } stats_t;
148 
149 extern int stats_allocs;
150 extern stats_t stats[MAX_ID];
151 extern void dump_statistics( );
152 #endif
153 
154 
155 
156 
157 // ===========================================================
159 // ===========================================================
160 #ifdef DEBUG_HEAP
161  #define ALLOC(size) alloc( size, \
162  __FUNCTION__, \
163  __FILE__, \
164  __LINE__)
165 
166  #define REALLOC(ptr, size) reallocate(ptr, \
167  size, \
168  __FUNCTION__, \
169  __FILE__, \
170  __LINE__)
171 
172  #define XALLOC(size) xalloc( size, \
173  __FUNCTION__, \
174  __FILE__, \
175  __LINE__)
176 
177  #define DEALLOC(ptr) dealloc( ptr, \
178  __FUNCTION__, \
179  __FILE__, \
180  __LINE__)
181 
182 
183  extern void* alloc( int size, const char* func, const char* file, const int line );
184  extern void* reallocate( void* ptr, int size, const char* func, const char* file, const int line );
185  extern void* xalloc( int size, const char* func, const char* file, const int line );
186  extern void dealloc( void* ptr, const char* func, const char* file, const int line );
187 #else
188  #define ALLOC(size) alloc(size)
189  #define REALLOC(ptr, size) reallocate(ptr, \
190  size)
191  #define XALLOC(size) xalloc(size)
192  #define DEALLOC(ptr) dealloc(ptr)
194  extern void* alloc( int size );
195  extern void* reallocate( void* ptr, int size);
196  extern void* xalloc( int size );
197  extern void dealloc( void* ptr );
198 #endif //DEBUG_HEAP
199 #endif //LHOGHO_OPTIONS_H
200 
201 
202 

[ HOME | INDEX | ATOMS | VARS | REFERENCE ]
Lhogho Developer's Documentation
Wed Jul 10 2013