fix calling convention and arg types
[m6w6/ext-psi] / src / types / number.c
index 840eb036ba29de8a89a9cb967f9da72ab502a028..10505dfe8988169b229b71de1f509d415e202038 100644 (file)
@@ -292,41 +292,46 @@ struct psi_plist *psi_number_tokens(struct psi_number *exp,
        return list;
 }
 
-void psi_number_dump(int fd, struct psi_number *exp)
+void psi_number_dump(struct psi_dump *dump, struct psi_number *exp)
 {
        switch (exp->type) {
        case PSI_T_DEFINED:
-       CASE_IMPLVAL_NUM_PRINTF(dprintf, fd, exp->data.ival)
+       CASE_IMPLVAL_NUM_DUMP(dump, exp->data.ival, true);
        case PSI_T_NULL:
-               dprintf(fd, "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:
-               dprintf(fd, "%s", exp->data.numb->val);
+               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(fd, exp->data.call);
+               psi_cpp_macro_call_dump(dump, exp->data.call);
                break;
        case PSI_T_CONST:
-               dprintf(fd, "%s", exp->data.cnst->name->val);
+               PSI_DUMP(dump, "%s", exp->data.cnst->name->val);
                break;
        case PSI_T_ENUM:
-               dprintf(fd, "%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(fd, exp->data.dvar);
+               psi_decl_var_dump(dump, exp->data.dvar);
                break;
        case PSI_T_SIZEOF:
-               dprintf(fd, "sizeof(");
-               psi_decl_type_dump(fd, exp->data.dtyp, 0);
-               dprintf(fd, ")");
+               PSI_DUMP(dump, "sizeof(");
+               psi_decl_type_dump(dump, exp->data.dtyp, 0);
+               PSI_DUMP(dump, ")");
                break;
        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,
@@ -493,7 +498,6 @@ static inline bool psi_number_validate_number(struct psi_data *data, struct psi_
                case PSI_NUMBER_FLT:
                        switch (exp->flags & 0x0ff00) {
                        case PSI_NUMBER_F:
-                       case PSI_NUMBER_DF:
                                tmp.fval = strtof(exp->data.numb->val, NULL);
                                zend_string_release(exp->data.numb);
                                exp->type = PSI_T_FLOAT;
@@ -510,6 +514,7 @@ static inline bool psi_number_validate_number(struct psi_data *data, struct psi_
 #endif
                        case PSI_NUMBER_DD:
                        default:
+                       case PSI_NUMBER_DF:
                                tmp.dval = strtod(exp->data.numb->val, NULL);
                                zend_string_release(exp->data.numb);
                                exp->type = PSI_T_DOUBLE;
@@ -571,7 +576,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;
@@ -606,6 +611,10 @@ bool psi_number_validate(struct psi_data *data, struct psi_number *exp,
        case PSI_T_UINT32:
        case PSI_T_INT64:
        case PSI_T_UINT64:
+#if HAVE_INT128
+       case PSI_T_INT128:
+       case PSI_T_UINT128:
+#endif
        case PSI_T_FLOAT:
        case PSI_T_DOUBLE:
 #if HAVE_LONG_DOUBLE
@@ -616,10 +625,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;
                }
@@ -873,7 +882,16 @@ token_t psi_number_eval(struct psi_number *exp, impl_val *res,
                *res = exp->data.ival;
                if (frame) PSI_DEBUG_PRINT(frame->context, " %" PRIu64, res->u64);
                return PSI_T_UINT64;
-
+#if HAVE_INT128
+       case PSI_T_INT128:
+               *res = exp->data.ival;
+               //if (frame) PSI_DEBUG_PRINT(frame->context, " %" PRIi128, res->i128);
+               return PSI_T_INT128;
+       case PSI_T_UINT128:
+               *res = exp->data.ival;
+               //if (frame) PSI_DEBUG_PRINT(frame->context, " %" PRIu128, res->u128);
+               return PSI_T_UINT128;
+#endif
        case PSI_T_FLOAT:
                *res = exp->data.ival;
                if (frame) PSI_DEBUG_PRINT(frame->context, " %" PRIfval, res->fval);