}
while (psi_plist_get(cpp->tokens.iter, i, &T)) {
PSI_DUMP(dump, "PSI: CPP tokens %5zu %c ", i, cpp->index == i ? '*' : ' ');
- if (T) {
- psi_token_dump(dump, T);
- } else {
- PSI_DUMP(dump, "TOKEN deleted\n");
- }
+ psi_token_dump(dump, T);
if (i >= cpp->index + 40) {
PSI_DUMP(dump, "PSI: CPP tokens .....\n");
break;
void psi_cpp_tokiter_reset(struct psi_cpp *cpp)
{
-#if PSI_CPP_DEBUG
- PSI_DEBUG_PRINT(cpp->parser,
- "PSI: CPP reset -> iter.count=%zu, next.count=%zu, exec.count=%zu\n",
- psi_plist_count(cpp->tokens.iter),
- psi_plist_count(cpp->tokens.next),
- psi_plist_count(cpp->tokens.exec));
-# if PSI_CPP_DEBUG > 1
- PSI_DEBUG_DUMP(cpp->parser, psi_cpp_tokiter_dump, cpp);
-# endif
-#endif
cpp->index = 0;
cpp->expanded = 0;
cpp->skip = 0;
} else {
cpp->tokens.exec = psi_plist_init((psi_plist_dtor) psi_token_free);
}
+#if PSI_CPP_DEBUG
+ PSI_DEBUG_PRINT(cpp->parser,
+ "PSI: CPP reset -> iter.count=%zu, next.count=%zu, exec.count=%zu\n",
+ psi_plist_count(cpp->tokens.iter),
+ psi_plist_count(cpp->tokens.next),
+ psi_plist_count(cpp->tokens.exec));
+# if PSI_CPP_DEBUG > 1
+ PSI_DEBUG_DUMP(cpp->parser, psi_cpp_tokiter_dump, cpp);
+# endif
+#endif
}
bool psi_cpp_tokiter_seek(struct psi_cpp *cpp, size_t index)
bool psi_cpp_tokiter_valid(struct psi_cpp *cpp)
{
-#if 0 && PSI_CPP_DEBUG
- PSI_DEBUG_PRINT(cpp->parser, "PSI: CPP valid -> index=%zu -> %d\n",
- cpp->index, cpp->index < psi_plist_count(cpp->tokens.iter));
+#if PSI_CPP_DEBUG > 1
+ PSI_DEBUG_PRINT(cpp->parser, "PSI: CPP valid -> index=%zu -> %s\n",
+ cpp->index, cpp->index < psi_plist_count(cpp->tokens.iter)
+ ? "true" : "false");
#endif
return cpp->index < psi_plist_count(cpp->tokens.iter);
}
return false;
}
#if PSI_CPP_DEBUG
- PSI_DEBUG_PRINT(cpp->parser, "PSI: CPP del_range -> ");
- PSI_DEBUG_DUMP(cpp->parser, psi_token_dump, ptr);
+ PSI_DEBUG_LOCK(cpp->parser,
+ PSI_DEBUG_PRINT(cpp->parser, "PSI: CPP del_range -> ");
+ PSI_DEBUG_DUMP(cpp->parser, psi_token_dump, ptr);
+ );
#endif
psi_plist_unset(cpp->tokens.iter, i);
if (free_tokens && ptr) {
return false;
}
} else {
- psi_cpp_tokiter_next(cpp);
+ psi_cpp_tokiter_del_cur(cpp, false);
}
psi_cpp_tokiter_expand_builtin_tokens(cpp, target, builtin, arg_tokens_list);
static inline bool psi_cpp_tokiter_expand_def(struct psi_cpp *cpp,
struct psi_token *target, struct psi_cpp_macro_decl *macro)
{
- /* delete current token from stream */
- psi_cpp_tokiter_del_cur(cpp, false);
-
if (macro->tokens) {
struct psi_plist *tokens = psi_plist_copy(macro->tokens,
(void (*)(void *)) psi_token_copy_ctor);
++cpp->expanded;
}
- psi_token_free(&target);
+ psi_cpp_tokiter_del_cur(cpp, true);
return true;
}
return false;
}
- /* don't expand itself */
-// if (zend_string_equals(macro->token->text, target->text)) {
-// PSI_DEBUG_PRINT(cpp->parser, "PSI: CPP expand ~ skipping self token\n");
-// return false;
-// }
-
if (macro->sig) {
return psi_cpp_tokiter_expand_call(cpp, target, macro);
} else if (psi_cpp_tokiter_expand_cmp(target, macro)) {