coan 4.2.4
|
00001 #ifndef EVAL_RESULT_H 00002 #define EVAL_RESULT_H 00003 00004 /*************************************************************************** 00005 * Copyright (C) 2007-2011 Mike Kinghan, imk@strudl.org * 00006 * All rights reserved. * 00007 * * 00008 * Originally contributed by Mike Kinghan, imk@strudl.org. * 00009 * * 00010 * Redistribution and use in source and binary forms, with or without * 00011 * modification, are permitted provided that the following conditions * 00012 * are met: * 00013 * * 00014 * Redistributions of source code must retain the above copyright * 00015 * notice, this list of conditions and the following disclaimer. * 00016 * * 00017 * Redistributions in binary form must reproduce the above copyright * 00018 * notice, this list of conditions and the following disclaimer in the * 00019 * documentation and/or other materials provided with the distribution. * 00020 * * 00021 * Neither the name of Symbian Software Ltd. nor the names of its * 00022 * contributors may be used to endorse or promote products derived from * 00023 * this software without specific prior written permission. * 00024 * * 00025 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * 00026 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * 00027 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * 00028 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * 00029 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * 00030 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * 00031 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS * 00032 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * 00033 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,* 00034 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF * 00035 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * 00036 * DAMAGE. * 00037 * * 00038 **************************************************************************/ 00039 00040 #include "canonical_string.h" 00041 #include "integer_constant.h" 00042 00052 00054 enum eval_flags { 00055 EVAL_PENDING, 00057 EVAL_CONST = 1, 00059 EVAL_KEEP = 2, 00061 EVAL_KEEP_CONST = EVAL_CONST | EVAL_KEEP, 00063 EVAL_DEL_PAREN = 4, 00065 EVAL_TRUE = 8, 00067 EVAL_FALSE = 16, 00069 EVAL_ILLEGAL = 32, 00071 EVAL_INSOURCE_SYM = 64, 00073 EVAL_GLOBAL_SYM = 128, 00075 EVAL_REPORTED_SYM = 256, 00077 EVAL_RESOLVED = EVAL_TRUE | EVAL_FALSE, 00079 EVAL_PARSED = EVAL_RESOLVED | EVAL_KEEP, 00082 }; 00083 00085 typedef enum { 00087 LT_IF, 00089 LT_TRUE, 00091 LT_FALSE, 00093 LT_ELIF, 00095 LT_ELTRUE, 00097 LT_ELFALSE, 00099 LT_ELSE, 00101 LT_ENDIF, 00103 LT_PLAIN, 00105 LT_EOF, 00107 LT_DIRECTIVE_DROP, 00109 LT_DIRECTIVE_KEEP, 00111 LT_SENTINEL 00112 00113 } line_type_t; 00114 00115 00118 typedef struct eval_result { 00119 char * sym_name; 00122 canonical_string_h sym_def; 00125 canonical_string_h most_resolved; 00128 int_spec_t value; 00131 int flags; 00133 int line; 00135 } eval_result_t; 00136 00138 #define EVAL_RESULT_INITOR {0,0,0,INT_SPEC_INITOR,EVAL_PENDING,0} 00139 00142 #define SET_FLAGS(eval_result,bits) ((eval_result).flags |= (bits)) 00143 00146 #define SET_FLAGS_IF(cond,eval_result,bits)\ 00147 (void)((cond) ? SET_FLAGS(eval_result,bits) : 0) 00148 00151 #define CLEAR_FLAGS(eval_result,bits) ((eval_result).flags &= ~(bits)) 00152 00155 #define CLEAR_FLAGS_IF(cond,eval_result,bits)\ 00156 (void)((cond) ? CLEAR_FLAGS(eval_result,bits) : 0) 00157 00161 #define FLIP_FLAGS(eval_result,bits) ((eval_result).flags ^= (bits)) 00162 00164 #define FLAGS_IN(eval_result,bits) ((eval_result).flags & (bits)) 00165 00168 #define AFFIRM_FLAGS(eval_result,bits)\ 00169 (((eval_result).flags & (bits)) == (bits)) 00170 00174 #define DENY_FLAGS(eval_result,bits)\ 00175 (((eval_result).flags & (bits)) == 0) 00176 00180 #define IS_TRUE(eval_result) AFFIRM_FLAGS(eval_result,EVAL_TRUE) 00181 00185 #define IS_FALSE(eval_result) AFFIRM_FLAGS(eval_result,EVAL_FALSE) 00186 00189 #define IS_CONST(eval_result) AFFIRM_FLAGS(eval_result,EVAL_CONST) 00190 00193 #define INT_WIDTH(eval_result) ((eval_result).value.width) 00194 00198 #define UNRESOLVED(eval_result) DENY_FLAGS(eval_result,EVAL_FALSE | EVAL_TRUE) 00199 00203 #define RESOLVED(eval_result) !UNRESOLVED(eval_result) 00204 00209 #define SET_REPORTED(eval_result) SET_FLAGS(eval_result,EVAL_REPORTED_SYM) 00210 00217 #define REPORTED(eval_result) AFFIRM_FLAGS(eval_result,EVAL_REPORTED_SYM) 00218 00222 #define DEL_PAREN(eval_result) AFFIRM_FLAGS(eval_result,EVAL_DEL_PAREN) 00223 00227 #define SET_DEL_PAREN(eval_result) SET_FLAGS(eval_result,EVAL_DEL_PAREN) 00228 00231 #define SET_KEEP_PAREN(eval_result) CLEAR_FLAGS(eval_result,EVAL_DEL_PAREN) 00232 00236 #define KEEP(eval_result) AFFIRM_FLAGS(eval_result,EVAL_KEEP) 00237 00241 #define SET_KEEP(eval_result) SET_FLAGS(eval_result,EVAL_KEEP) 00242 00245 #define KEEP_CONST(eval_result) AFFIRM_FLAGS(eval_result,EVAL_KEEP_CONST) 00246 00248 #define SET_KEEP_CONST(eval_result) SET_FLAGS(eval_result,EVAL_KEEP_CONST) 00249 00251 #define SET_CONST(eval_result) SET_FLAGS(eval_result,EVAL_CONST) 00252 00254 #define SET_ILLEGAL(eval_result) SET_FLAGS(eval_result,EVAL_ILLEGAL) 00255 00257 #define SET_LEGAL(eval_result) CLEAR_FLAGS(eval_result,EVAL_ILLEGAL) 00258 00260 #define ILLEGAL(eval_result) AFFIRM_FLAGS(eval_result,EVAL_ILLEGAL) 00261 00263 #define LEGAL(eval_result) !ILLEGAL(eval_result) 00264 00266 #define SET_UNRESOLVED(eval_result) \ 00267 CLEAR_FLAGS(eval_result,EVAL_TRUE | EVAL_FALSE) 00268 00270 #define SET_INSOURCE_SYM(eval_result) SET_FLAGS(eval_result,EVAL_INSOURCE_SYM) 00271 00273 #define INSOURCE_SYM(eval_result) AFFIRM_FLAGS(eval_result,EVAL_INSOURCE_SYM) 00274 00276 #define SET_GLOBAL_SYM(eval_result) SET_FLAGS(eval_result,EVAL_GLOBAL_SYM) 00277 00279 #define GLOBAL_SYM(eval_result) AFFIRM_FLAGS(eval_result,EVAL_GLOBAL_SYM) 00280 00282 extern int_spec_t const int_spec_false; 00283 00285 extern int_spec_t const int_spec_true; 00286 00291 extern void 00292 eval_result_set_value(eval_result_t *result, int_spec_t const * int_spec); 00293 00300 extern void 00301 eval_result_clear(eval_result_t *result); 00302 00308 extern bool 00309 eval_result_parsed(eval_result_t *result); 00310 00311 00314 #endif /* EOF*/