update readme
[m6w6/ext-psi] / src / types / number.c
index 7c05c85b31b81487893003f4289d74728245bff3..3428905f5a031464d4896d7c0d671dd9394dcbd9 100644 (file)
  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *******************************************************************************/
 
-#include "php_psi_stdinc.h"
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#else
+# include "php_config.h"
+#endif
 
 #include <assert.h>
 #include <math.h>
@@ -32,6 +36,7 @@
 #include "calc.h"
 #include "call.h"
 #include "parser.h"
+#include "debug.h"
 
 #include "Zend/zend_constants.h"
 #include "Zend/zend_operators.h"
@@ -296,17 +301,19 @@ void psi_number_dump(struct psi_dump *dump, struct psi_number *exp)
 {
        switch (exp->type) {
        case PSI_T_DEFINED:
-       CASE_IMPLVAL_NUM_PRINTF(dump->fun, dump->ctx, exp->data.ival, 1);
+       CASE_IMPLVAL_NUM_DUMP(dump, exp->data.ival, true);
        case PSI_T_NULL:
                PSI_DUMP(dump, "NULL");
                break;
        case PSI_T_NUMBER:
        case PSI_T_NSNAME:
-       case PSI_T_DEFINE:
        case PSI_T_QUOTED_CHAR:
        case PSI_T_CPP_HEADER:
                PSI_DUMP(dump, "%s", exp->data.numb->val);
                break;
+       case PSI_T_DEFINE:
+               PSI_DUMP(dump, "%s /* DEFINE */", exp->data.numb->val);
+               break;
        case PSI_T_FUNCTION:
                psi_cpp_macro_call_dump(dump, exp->data.call);
                break;
@@ -314,7 +321,7 @@ void psi_number_dump(struct psi_dump *dump, struct psi_number *exp)
                PSI_DUMP(dump, "%s", exp->data.cnst->name->val);
                break;
        case PSI_T_ENUM:
-               PSI_DUMP(dump, "%s", exp->data.enm->name->val);
+               PSI_DUMP(dump, "%s /* ENUM */ ", exp->data.enm->name->val);
                break;
        case PSI_T_NAME:
                psi_decl_var_dump(dump, exp->data.dvar);
@@ -327,6 +334,9 @@ void psi_number_dump(struct psi_dump *dump, struct psi_number *exp)
        default:
                assert(0);
        }
+#if 0
+       PSI_DUMP(dump, "\t/* number.type=%d */ ", exp->type);
+#endif
 }
 
 static inline bool psi_number_validate_enum(struct psi_data *data,
@@ -571,7 +581,7 @@ static inline bool psi_number_validate_number(struct psi_data *data, struct psi_
                                                return true;
                                        }
                                }
-                               break;
+                               /* no break */
                        default:
                                zend_string_release(exp->data.numb);
                                exp->type = PSI_T_INT64;
@@ -620,10 +630,10 @@ bool psi_number_validate(struct psi_data *data, struct psi_number *exp,
                return true;
 
        case PSI_T_NAME:
-               if (scope && scope->cpp && zend_hash_exists(&scope->cpp->defs, exp->data.dvar->name)) {
-                       exp->type = PSI_T_DEFINE;
-                       goto define;
-               }
+               //if (scope && scope->cpp && zend_hash_exists(&scope->cpp->defs, exp->data.dvar->name)) {
+               //      exp->type = PSI_T_DEFINE;
+               //      goto define;
+               //}
                if (scope && scope->current_enum && psi_number_validate_enum(data, exp, scope)) {
                        return true;
                }
@@ -670,7 +680,6 @@ bool psi_number_validate(struct psi_data *data, struct psi_number *exp,
 
        case PSI_T_DEFINE:
                if (scope && scope->cpp && zend_hash_exists(&scope->cpp->defs, exp->data.numb)) {
-       define: ;
                        if (!scope->macro || !zend_string_equals(scope->macro->token->text, exp->data.numb)) {
                                return true;
                        }