* fix right recursion of let_exp and set_exp
* improve varargs support, currently it's impossible to map e.g. curl_easy_setopt
* cpp: asm aliasing/redirects
+* impl_var.name: remove leading '$'
struct psi_call_frame *frame, struct psi_decl_var *dvar) {
struct psi_call_frame_symbol *frame_sym;
- frame_sym = zend_hash_str_find_ptr(&frame->symbols, dvar->fqn, strlen(dvar->fqn));
+ frame_sym = zend_hash_find_ptr(&frame->symbols, dvar->fqn);
if (!frame_sym) {
- frame_sym = zend_hash_str_add_ptr(&frame->symbols, dvar->fqn, strlen(dvar->fqn),
+ frame_sym = zend_hash_add_ptr(&frame->symbols, dvar->fqn,
psi_call_frame_symbol_init(dvar));
}
return frame_sym;
/* varargs are just appended with numeric indices */
return zend_hash_next_index_insert_ptr(&frame->arguments, frame_arg);
} else {
- return zend_hash_str_add_ptr(&frame->arguments,
- frame_arg->spec->var->name, strlen(frame_arg->spec->var->name),
- frame_arg);
+ return zend_hash_add_ptr(&frame->arguments,
+ frame_arg->spec->var->name, frame_arg);
}
}
zval *psi_call_frame_sub_argument(struct psi_call_frame *frame,
- struct psi_impl_var *inner_var, zval *outer_zval, const char *name) {
+ struct psi_impl_var *inner_var, zval *outer_zval, zend_string *name) {
struct psi_call_frame_argument *iarg;
zval *inner_zval = zend_symtable_str_find(Z_ARRVAL_P(outer_zval),
- &inner_var->name[1], strlen(&inner_var->name[1]));
+ &inner_var->name->val[1], inner_var->name->len - 1);
if (!inner_zval) {
zval empty_zval;
SEPARATE_ZVAL(outer_zval);
ZVAL_NULL(&empty_zval);
inner_zval = zend_symtable_str_update(Z_ARRVAL_P(outer_zval),
- &inner_var->name[1], strlen(&inner_var->name[1]),
+ &inner_var->name->val[1], inner_var->name->len - 1,
&empty_zval);
}
struct psi_call_frame_argument *frame_arg;
impl_val empty_val = {0};
struct psi_impl_arg *carg_spec = psi_impl_arg_init(
- psi_impl_type_init(PSI_T_MIXED, "mixed"),
+ psi_impl_type_init(PSI_T_MIXED, zend_string_init(ZEND_STRL("mixed"), 1)),
psi_impl_var_copy(inner_var), NULL);
psi_call_frame_push_auto_ex(frame, carg_spec, (void(*)(void*)) psi_impl_arg_free);
frame_arg = psi_call_frame_argument_init(carg_spec, &empty_val, inner_zval, 0);
- zend_hash_str_add_ptr(&frame->arguments, name, strlen(name), frame_arg);
+ zend_hash_add_ptr(&frame->arguments, name, frame_arg);
}
return inner_zval;
}
struct psi_call_frame_argument *psi_call_frame_get_argument(
- struct psi_call_frame *frame, const char *name) {
- return zend_hash_str_find_ptr(&frame->arguments, name, strlen(name));
+ struct psi_call_frame *frame, zend_string *name) {
+ return zend_hash_find_ptr(&frame->arguments, name);
}
size_t psi_call_frame_num_var_args(struct psi_call_frame *frame) {
memcpy(temp, &frame->temp, sizeof(*temp));
ZVAL_OBJ(&zlocal, psi_object_init_ex(NULL, temp, psi_call_frame_local_auto_dtor));
- zend_set_local_var_str(frame->impl->func->name,
- strlen(frame->impl->func->name), &zlocal, /* force */ 1);
+ zend_set_local_var(frame->impl->func->name, &zlocal, /* force */ 1);
} else {
zend_llist_destroy(&frame->temp);
}
size_t psi_call_frame_num_fixed_args(struct psi_call_frame *frame);
zval *psi_call_frame_new_argument(struct psi_call_frame *frame, struct psi_call_frame_argument *frame_arg);
-zval *psi_call_frame_sub_argument(struct psi_call_frame *frame, struct psi_impl_var *inner_var, zval *outer_zval, const char *name);
+zval *psi_call_frame_sub_argument(struct psi_call_frame *frame, struct psi_impl_var *inner_var, zval *outer_zval, zend_string *name);
-struct psi_call_frame_argument *psi_call_frame_get_argument(struct psi_call_frame *frame, const char *name);
+struct psi_call_frame_argument *psi_call_frame_get_argument(struct psi_call_frame *frame, zend_string *name);
struct psi_call_frame_argument *psi_call_frame_get_var_argument(struct psi_call_frame *frame, zend_long index);
struct psi_call_frame_symbol *psi_call_frame_fetch_symbol(struct psi_call_frame *frame, struct psi_decl_var *dvar);
while (psi_plist_get(C->consts, i++, &c)) {
- if (zend_get_constant_str(c->name, strlen(c->name))) {
+ if (zend_get_constant(c->name)) {
continue;
}
- zc.name = zend_string_init(c->name, strlen(c->name), 1);
+ zc.name = zend_string_copy(c->name);
switch (c->type->type) {
case PSI_T_BOOL:
zend_string *name;
if (psi_decl_type_is_anon(e->name, "enum")) {
- name = strpprintf(0, "psi\\%s", item->name);
+ name = strpprintf(0, "psi\\%s", item->name->val);
} else {
- name = strpprintf(0, "psi\\%s\\%s", e->name, item->name);
+ name = strpprintf(0, "psi\\%s\\%s", e->name->val, item->name->val);
}
if (zend_get_constant(name)) {
struct psi_token *no_ws = psi_token_copy(token);
no_ws->type = PSI_T_NO_WHITESPACE;
- no_ws->text[0] = '\xA0';
+ zend_string_release(no_ws->text);
+ no_ws->text = zend_string_init("\xA0", 1, 1);
psi_cpp_tokiter_ins_cur(cpp, no_ws);
continue;
}
bool defined;
if (tok->type == PSI_T_NAME) {
- defined = zend_hash_str_exists(&cpp->defs, tok->text, tok->size);
+ defined = zend_hash_exists(&cpp->defs, tok->text);
} else {
defined = false;
}
#if PSI_CPP_DEBUG
fprintf(stderr, "PSI: CPP defined -> %s ", defined ? "true" : "false");
if (defined) {
- struct psi_cpp_macro_decl *macro = zend_hash_str_find_ptr(&cpp->defs, tok->text, tok->size);
- fprintf(stderr, " @ %s:%u ", macro->token->file, macro->token->line);
+ struct psi_cpp_macro_decl *macro = zend_hash_find_ptr(&cpp->defs, tok->text);
+ fprintf(stderr, " @ %s:%u ", macro->token->file->val, macro->token->line);
}
psi_token_dump(2, tok);
#endif
void psi_cpp_define(struct psi_cpp *cpp, struct psi_cpp_macro_decl *decl)
{
- struct psi_cpp_macro_decl *old = zend_hash_str_find_ptr(&cpp->defs, decl->token->text, decl->token->size);
+ struct psi_cpp_macro_decl *old = zend_hash_find_ptr(&cpp->defs, decl->token->text);
if (old && !psi_cpp_macro_decl_equal(old, decl)) {
cpp->parser->error(PSI_DATA(cpp->parser), decl->token, PSI_WARNING,
- "'%s' redefined", decl->token->text);
+ "'%s' redefined", decl->token->text->val);
cpp->parser->error(PSI_DATA(cpp->parser), old->token, PSI_WARNING,
- "'%s' previously defined", old->token->text);
+ "'%s' previously defined", old->token->text->val);
}
#if PSI_CPP_DEBUG
if (decl->exp) {
psi_cpp_macro_decl_dump(2, decl);
fprintf(stderr, "\n");
#endif
- zend_hash_str_update_ptr(&cpp->defs, decl->token->text, decl->token->size, decl);
+ zend_hash_update_ptr(&cpp->defs, decl->token->text, decl);
}
bool psi_cpp_undef(struct psi_cpp *cpp, struct psi_token *tok)
{
- return SUCCESS == zend_hash_str_del(&cpp->defs, tok->text, tok->size);
+ return SUCCESS == zend_hash_del(&cpp->defs, tok->text);
}
bool psi_cpp_if(struct psi_cpp *cpp, struct psi_cpp_exp *exp)
static inline void include_path(const struct psi_token *file, char **path)
{
- if (*file->text == '/') {
- *path = file->text;
+ if (file->text->val[0] == '/') {
+ *path = file->text->val;
} else {
char *dir;
size_t len;
- strncpy(*path, file->file, PATH_MAX);
+ strncpy(*path, file->file->val, PATH_MAX);
dir = dirname(*path);
len = strlen(dir);
- assert(len + file->size + 1 < PATH_MAX);
+ assert(len + file->text->len + 1 < PATH_MAX);
memmove(*path, dir, len);
(*path)[len] = '/';
- memcpy(&(*path)[len + 1], file->text, file->size + 1);
+ memcpy(&(*path)[len + 1], file->text->val, file->text->len + 1);
}
}
bool psi_cpp_include(struct psi_cpp *cpp, const struct psi_token *file, unsigned flags)
{
bool parsed = false;
- int f_len = strlen(file->text);
- if (file->type == PSI_T_QUOTED_STRING && (!(flags & PSI_CPP_INCLUDE_NEXT) || *file->text == '/')) {
+ if (file->type == PSI_T_QUOTED_STRING && (!(flags & PSI_CPP_INCLUDE_NEXT) || file->text->val[0] == '/')) {
/* first try as is, full or relative path */
char temp[PATH_MAX], *path = temp;
include_path(file, &path);
- if ((flags & PSI_CPP_INCLUDE_ONCE) && zend_hash_str_exists(&cpp->once, path, f_len)) {
+ if ((flags & PSI_CPP_INCLUDE_ONCE) && zend_hash_str_exists(&cpp->once, path, strlen(path))) {
return true;
}
if (try_include(cpp, path, &parsed)) {
}
/* look through search paths */
- if (*file->text != '/') {
+ if (file->text->val[0] != '/') {
char path[PATH_MAX];
const char *sep;
int p_len;
sep = strchr(cpp->search, ':');
d_len = sep ? sep - cpp->search : strlen(cpp->search);
- if (PATH_MAX > (p_len = snprintf(path, PATH_MAX, "%.*s/%.*s", d_len, cpp->search, f_len, file->text))) {
+ if (PATH_MAX > (p_len = snprintf(path, PATH_MAX, "%.*s/%.*s", d_len, cpp->search, (int) file->text->len, file->text->val))) {
if ((flags & PSI_CPP_INCLUDE_ONCE) && zend_hash_str_exists(&cpp->once, path, p_len)) {
return true;
}
fprintf(stderr, "NULL\n");
}
#endif
- if (cur && free_token) {
- free(cur);
+ if (free_token) {
+ psi_token_free(&cur);
}
count = psi_plist_count(cpp->tokens);
if (deleted && cpp->index >= count) {
if (free_tokens) {
while (num_eles--) {
- if (ptr[num_eles]) {
- free(ptr[num_eles]);
- }
+ psi_token_free(&ptr[num_eles]);
}
free(ptr);
}
struct psi_token *tmp_tok, *old_tok = exp_tokens[n - 1];
tmp_tok = psi_token_init(old_tok->type, "", 0,
- target->col, target->line, target->file?:"");
+ target->col, target->line,
+ target->file ? target->file->val : "");
new_tok = psi_token_cat(NULL, 3, tmp_tok, old_tok, tok);
- free(old_tok);
- free(tmp_tok);
+ psi_token_free(&old_tok);
+ psi_token_free(&tmp_tok);
exp_tokens[n - 1] = new_tok;
} else {
new_tok = psi_token_init(stringify ? PSI_T_QUOTED_STRING : tok->type,
- tok->text, tok->size, target->col, target->line, target->file?:"");
+ tok->text->val, tok->text->len, target->col, target->line, target->file?:"");
exp_tokens[n++] = new_tok;
}
struct psi_token *tok;
while (psi_plist_pop(arg_tokens_list[i], &tok)) {
- free(tok);
+ psi_token_free(&tok);
}
}
psi_plist_free(arg_tokens_list[i]);
struct psi_token *arg_name;
for (s = 0; psi_plist_get(macro->sig, s, &arg_name); ++s) {
- if (arg_name->size == tok->size) {
- if (!memcmp(arg_name->text, tok->text, tok->size)) {
- arg_tokens = arg_tokens_list[s];
- break;
- }
+ if (zend_string_equals(arg_name->text, tok->text)) {
+ arg_tokens = arg_tokens_list[s];
+ break;
}
}
}
/* back to where we took off */
psi_cpp_tokiter_seek(cpp, start);
- free(target);
+ psi_token_free(&target);
++cpp->expanded;
return true;
}
/* replace with tokens from macro */
psi_cpp_tokiter_expand_tokens(cpp, target, macro->tokens);
- free(target);
+ psi_token_free(&target);
++cpp->expanded;
return true;
}
psi_plist_get(m->tokens, 0, &r);
- return strcmp(r->text, t->text);
+ return !zend_string_equals(r->text, t->text);
}
return -1;
}
struct psi_token *current = psi_cpp_tokiter_current(cpp);
if (current) {
- struct psi_cpp_macro_decl *macro = zend_hash_str_find_ptr(
- &cpp->defs, current->text, current->size);
+ struct psi_cpp_macro_decl *macro = zend_hash_find_ptr(
+ &cpp->defs, current->text);
/* don't expand itself */
if (macro && macro->token != current) {
char *libname;
if (D->file.filename) {
- dprintf(fd, "// filename=%s (%u errors)\n", D->file.filename, D->errors);
+ dprintf(fd, "// filename=%s (%u errors)\n", D->file.filename->val, D->errors);
}
while (psi_plist_get(D->file.libnames, i++, &libname)) {
dprintf(fd, "lib \"%s\";\n", libname);
}
if (t) {
- fn = t->file;
+ fn = t->file->val;
ln = t->line;
} else if (zend_is_executing()) {
fn = zend_get_executed_filename();
}
}
-static inline ffi_abi psi_ffi_abi(const char *convention) {
+static inline ffi_abi psi_ffi_abi(zend_string *convention) {
if (FFI_LAST_ABI - 2 != FFI_FIRST_ABI) {
#ifdef HAVE_FFI_STDCALL
- if (!strcasecmp(convention, "stdcall")) {
+ if (zend_string_equals_literal(convention, "stdcall")) {
return FFI_STDCALL;
}
#endif
#ifdef HAVE_FFI_FASTCALL
- if (!strcasecmp(convention, "fastcall")) {
+ if (zend_string_equals_literal(convention, "fastcall")) {
return FFI_FASTCALL;
}
#endif
continue;
}
- zf->fname = impl->func->name + (impl->func->name[0] == '\\');
+ zf->fname = impl->func->name->val + (impl->func->name->val[0] == '\\');
zf->handler = ((struct psi_ffi_impl_info *) impl->info)->code;
zf->num_args = psi_plist_count(impl->func->args);
zf->arg_info = psi_internal_arginfo(impl);
}
}
-static inline jit_abi_t psi_jit_abi(const char *convention)
+static inline jit_abi_t psi_jit_abi(zend_string *convention)
{
- if (!strcasecmp(convention, "stdcall")) {
+ if (zend_string_equals_literal(convention, "stdcall")) {
return jit_abi_stdcall;
}
- if (!strcasecmp(convention, "fastcall")) {
+ if (zend_string_equals_literal(convention, "fastcall")) {
return jit_abi_fastcall;
}
return jit_abi_cdecl;
continue;
}
- zf->fname = impl->func->name + (impl->func->name[0] == '\\');
+ zf->fname = impl->func->name->val + (impl->func->name->val[0] == '\\');
zf->handler = ((struct psi_jit_impl_info *) impl->info)->closure;
zf->num_args = psi_plist_count(impl->func->args);
zf->arg_info = psi_internal_arginfo(impl);
struct psi_impl_arg *vararg = impl->func->vararg;
zend_internal_arg_info *ai = &aip[argc];
- ai->name = vararg->var->name;
+ ai->name = vararg->var->name->val;
#ifdef ZEND_TYPE_ENCODE
ai->type = ZEND_TYPE_ENCODE(psi_internal_type(vararg->type), 1);
#else
while (psi_plist_get(impl->func->args, i++, &iarg)) {
zend_internal_arg_info *ai = &aip[i];
- ai->name = iarg->var->name;
+ ai->name = iarg->var->name->val;
#ifdef ZEND_TYPE_ENCODE
ai->type = ZEND_TYPE_ENCODE(psi_internal_type(iarg->type), 1);
#else
ZVAL_NULL(&ele);
psi_set_exp_exec_ex(sub_exp, &ele, sym->ptr, frame);
- add_assoc_zval(return_value, ivar->name + 1, &ele);
+ add_assoc_zval(return_value, ivar->name->val + 1, &ele);
}
}
-/* Generated by re2c 1.1.1 on Mon Oct 29 07:42:47 2018 */
+/* Generated by re2c 1.1.1 on Tue Oct 30 13:23:48 2018 */
#line 1 "src/parser.re"
/*******************************************************************************
Copyright (c) 2016, Michael Wallner <mike@php.net>.
#include <errno.h>
#include <stdarg.h>
+#include <Zend/zend_smart_str.h>
+
#include "parser.h"
#define YYMAXFILL 15
return NULL;
}
- if (!(fb = malloc(sizeof(*fb) + strlen(filename) + 1 + sb.st_size + YYMAXFILL))) {
+ if (!(fb = malloc(sizeof(*fb) + sb.st_size + YYMAXFILL))) {
if (report_errors) {
P->error(PSI_DATA(P), NULL, PSI_WARNING,
"Could not allocate %zu bytes for reading '%s': %s",
return NULL;
}
- memset(fb->buffer + sb.st_size, 0, YYMAXFILL);
fb->length = sb.st_size;
- fb->file = &fb->buffer[sb.st_size + YYMAXFILL];
- memcpy(fb->file, filename, strlen(filename) + 1);
+ fb->file = zend_string_init(filename, strlen(filename), 1);
return fb;
}
{
struct psi_parser_input *sb;
- if (!(sb = malloc(sizeof(*sb) + sizeof("<stdin>") + length + YYMAXFILL))) {
+ if (!(sb = malloc(sizeof(*sb) + length + YYMAXFILL))) {
P->error(PSI_DATA(P), NULL, PSI_WARNING,
"Could not allocate %zu bytes: %s",
length + YYMAXFILL, strerror(errno));
memset(sb->buffer + length, 0, YYMAXFILL);
sb->length = length;
- sb->file = &sb->buffer[length + YYMAXFILL];
- memcpy(sb->file, "<stdin>", sizeof("<stdin>"));
+ sb->file = zend_string_init("<stdin>", strlen("<stdin>"), 1);
return sb;
}
-#if 0
-static void psi_parser_register_constants(struct psi_parser *P)
-{
- zend_string *key;
- zval *val;
-
- ZEND_HASH_FOREACH_STR_KEY_VAL(&P->cpp.defs, key, val)
- {
- struct psi_impl_def_val *iv;
- struct psi_const_type *ct;
- struct psi_const *c;
- const char *ctn;
- token_t ctt;
- impl_val tmp;
- zend_string *str;
-
- ZVAL_DEREF(val);
- switch (Z_TYPE_P(val)) {
- case IS_TRUE:
- case IS_FALSE:
- ctt = PSI_T_BOOL;
- ctn = "bool";
- tmp.zend.bval = Z_TYPE_P(val) == IS_TRUE;
- break;
- case IS_LONG:
- ctt = PSI_T_INT;
- ctn = "int";
- tmp.zend.lval = Z_LVAL_P(val);
- break;
- case IS_DOUBLE:
- ctt = PSI_T_FLOAT;
- ctn = "float";
- tmp.dval = Z_DVAL_P(val);
- break;
- default:
- ctt = PSI_T_STRING;
- ctn = "string";
- str = zval_get_string(val);
- tmp.zend.str = zend_string_dup(str, 1);
- zend_string_release(str);
- break;
- }
-
- iv = psi_impl_def_val_init(ctt, NULL);
- iv->ival = tmp;
- ct = psi_const_type_init(ctt, ctn);
- c = psi_const_init(ct, key->val, iv);
- if (!P->consts) {
- P->consts = psi_plist_init((psi_plist_dtor) psi_const_free);
- }
- P->consts = psi_plist_add(P->consts, &c);
- }
- ZEND_HASH_FOREACH_END();
-}
-#endif
-
struct psi_plist *psi_parser_preprocess(struct psi_parser *P, struct psi_plist **tokens)
{
if (psi_cpp_process(P->preproc, tokens)) {
struct psi_impl_def_val *def;
struct psi_const *cnst;
struct psi_num_exp *num;
- char *name_str = malloc(name->len + sizeof("psi\\"));
+ smart_str ns_name = {0};
+ zend_string *name_str;
+
+ smart_str_appendl_ex(&ns_name, ZEND_STRL("psi\\"), 1);
+ smart_str_append_ex(&ns_name, name, 1);
+ name_str = smart_str_extract(&ns_name);
- strcat(strcpy(name_str, "psi\\"), name->val);
num = psi_num_exp_copy(scope.macro->exp);
def = psi_impl_def_val_init(PSI_T_NUMBER, num);
- type = psi_impl_type_init(PSI_T_NUMBER, "<eval number>");
+ type = psi_impl_type_init(PSI_T_NUMBER,
+ zend_string_init(ZEND_STRL("<eval number>"), 1));
cnst = psi_const_init(type, name_str, def);
P->consts = psi_plist_add(P->consts, &cnst);
- free(name_str);
+ zend_string_release(name_str);
}
} else {
if (psi_plist_count(scope.macro->tokens) == 1) {
struct psi_impl_type *type;
struct psi_impl_def_val *def;
struct psi_const *cnst;
- char *name_str = malloc(name->len + sizeof("psi\\"));
+ smart_str ns_name = {0};
+ zend_string *name_str;
+
+ smart_str_appendl_ex(&ns_name, ZEND_STRL("psi\\"), 1);
+ smart_str_append_ex(&ns_name, name, 1);
+ name_str = smart_str_extract(&ns_name);
- strcat(strcpy(name_str, "psi\\"), name->val);
- type = psi_impl_type_init(PSI_T_STRING, "string");
+ type = psi_impl_type_init(PSI_T_STRING,
+ zend_string_init(ZEND_STRL("string"), 1));
def = psi_impl_def_val_init(PSI_T_QUOTED_STRING, t->text);
cnst = psi_const_init(type, name_str, def);
P->consts = psi_plist_add(P->consts, &cnst);
- free(name_str);
+ zend_string_release(name_str);
}
}
}
bool escaped;
token_t char_width;
- PSI_DEBUG_PRINT(P, "PSI: scanning %s\n", I->file);
+ PSI_DEBUG_PRINT(P, "PSI: scanning %s\n", I->file->val);
tok = mrk = eol = cur = I->buffer;
lim = I->buffer + I->length;
(void) ctxmrk;
-#line 349 "src/parser.c"
+#line 302 "src/parser.c"
{
unsigned char yych;
unsigned int yyaccept = 0;
yy2:
++cur;
yy3:
-#line 514 "src/parser.re"
+#line 467 "src/parser.re"
{ NEWTOKEN(-2); goto error; }
-#line 476 "src/parser.c"
+#line 429 "src/parser.c"
yy4:
++cur;
if (lim <= cur) if (cur >= lim) goto done;;
default: goto yy6;
}
yy6:
-#line 513 "src/parser.re"
+#line 466 "src/parser.re"
{ NEWTOKEN(PSI_T_WHITESPACE); goto start; }
-#line 490 "src/parser.c"
+#line 443 "src/parser.c"
yy7:
++cur;
-#line 512 "src/parser.re"
+#line 465 "src/parser.re"
{ NEWTOKEN(PSI_T_EOL); NEWLINE(); goto start; }
-#line 495 "src/parser.c"
+#line 448 "src/parser.c"
yy9:
yych = *++cur;
switch (yych) {
default: goto yy10;
}
yy10:
-#line 415 "src/parser.re"
+#line 368 "src/parser.re"
{ NEWTOKEN(PSI_T_NOT); goto start; }
-#line 505 "src/parser.c"
+#line 458 "src/parser.c"
yy11:
++cur;
-#line 388 "src/parser.re"
+#line 341 "src/parser.re"
{ escaped = false; tok += 1; goto string; }
-#line 510 "src/parser.c"
+#line 463 "src/parser.c"
yy13:
yych = *++cur;
switch (yych) {
default: goto yy14;
}
yy14:
-#line 398 "src/parser.re"
+#line 351 "src/parser.re"
{ NEWTOKEN(PSI_T_HASH); goto start; }
-#line 520 "src/parser.c"
+#line 473 "src/parser.c"
yy15:
yych = *++cur;
switch (yych) {
}
yy16:
++cur;
-#line 416 "src/parser.re"
+#line 369 "src/parser.re"
{ NEWTOKEN(PSI_T_MODULO); goto start; }
-#line 595 "src/parser.c"
+#line 548 "src/parser.c"
yy18:
yych = *++cur;
switch (yych) {
default: goto yy19;
}
yy19:
-#line 417 "src/parser.re"
+#line 370 "src/parser.re"
{ NEWTOKEN(PSI_T_AMPERSAND); goto start; }
-#line 605 "src/parser.c"
+#line 558 "src/parser.c"
yy20:
++cur;
-#line 387 "src/parser.re"
+#line 340 "src/parser.re"
{ escaped = false; tok += 1; goto character; }
-#line 610 "src/parser.c"
+#line 563 "src/parser.c"
yy22:
++cur;
-#line 399 "src/parser.re"
+#line 352 "src/parser.re"
{ NEWTOKEN(PSI_T_LPAREN); goto start; }
-#line 615 "src/parser.c"
+#line 568 "src/parser.c"
yy24:
++cur;
-#line 400 "src/parser.re"
+#line 353 "src/parser.re"
{ NEWTOKEN(PSI_T_RPAREN); goto start; }
-#line 620 "src/parser.c"
+#line 573 "src/parser.c"
yy26:
++cur;
-#line 413 "src/parser.re"
+#line 366 "src/parser.re"
{ NEWTOKEN(PSI_T_ASTERISK); goto start; }
-#line 625 "src/parser.c"
+#line 578 "src/parser.c"
yy28:
yyaccept = 0;
yych = *(mrk = ++cur);
default: goto yy29;
}
yy29:
-#line 418 "src/parser.re"
+#line 371 "src/parser.re"
{ NEWTOKEN(PSI_T_PLUS); goto start; }
-#line 646 "src/parser.c"
+#line 599 "src/parser.c"
yy30:
++cur;
-#line 402 "src/parser.re"
+#line 355 "src/parser.re"
{ NEWTOKEN(PSI_T_COMMA); goto start; }
-#line 651 "src/parser.c"
+#line 604 "src/parser.c"
yy32:
yyaccept = 1;
yych = *(mrk = ++cur);
default: goto yy33;
}
yy33:
-#line 419 "src/parser.re"
+#line 372 "src/parser.re"
{ NEWTOKEN(PSI_T_MINUS); goto start; }
-#line 672 "src/parser.c"
+#line 625 "src/parser.c"
yy34:
yyaccept = 2;
yych = *(mrk = ++cur);
default: goto yy35;
}
yy35:
-#line 430 "src/parser.re"
+#line 383 "src/parser.re"
{ NEWTOKEN(PSI_T_PERIOD); goto start; }
-#line 693 "src/parser.c"
+#line 646 "src/parser.c"
yy36:
yych = *++cur;
switch (yych) {
default: goto yy37;
}
yy37:
-#line 420 "src/parser.re"
+#line 373 "src/parser.re"
{ NEWTOKEN(PSI_T_SLASH); goto start; }
-#line 704 "src/parser.c"
+#line 657 "src/parser.c"
yy38:
yyaccept = 3;
yych = *(mrk = ++cur);
default: goto yy126;
}
yy39:
-#line 374 "src/parser.re"
+#line 327 "src/parser.re"
{ NEWTOKEN(PSI_T_NUMBER); token->flags = PSI_NUMBER_INT; goto start; }
-#line 719 "src/parser.c"
+#line 672 "src/parser.c"
yy40:
yyaccept = 3;
mrk = ++cur;
}
yy42:
++cur;
-#line 403 "src/parser.re"
+#line 356 "src/parser.re"
{ NEWTOKEN(PSI_T_COLON); goto start; }
-#line 749 "src/parser.c"
+#line 702 "src/parser.c"
yy44:
++cur;
-#line 401 "src/parser.re"
+#line 354 "src/parser.re"
{ NEWTOKEN(PSI_T_EOS); goto start; }
-#line 754 "src/parser.c"
+#line 707 "src/parser.c"
yy46:
yyaccept = 4;
yych = *(mrk = ++cur);
default: goto yy47;
}
yy47:
-#line 428 "src/parser.re"
+#line 381 "src/parser.re"
{ NEWTOKEN(PSI_T_LCHEVR); goto start; }
-#line 832 "src/parser.c"
+#line 785 "src/parser.c"
yy48:
yych = *++cur;
switch (yych) {
default: goto yy49;
}
yy49:
-#line 412 "src/parser.re"
+#line 365 "src/parser.re"
{ NEWTOKEN(PSI_T_EQUALS); goto start; }
-#line 842 "src/parser.c"
+#line 795 "src/parser.c"
yy50:
yych = *++cur;
switch (yych) {
default: goto yy51;
}
yy51:
-#line 429 "src/parser.re"
+#line 382 "src/parser.re"
{ NEWTOKEN(PSI_T_RCHEVR); goto start; }
-#line 853 "src/parser.c"
+#line 806 "src/parser.c"
yy52:
++cur;
-#line 432 "src/parser.re"
+#line 385 "src/parser.re"
{ NEWTOKEN(PSI_T_IIF); goto start; }
-#line 858 "src/parser.c"
+#line 811 "src/parser.c"
yy54:
yyaccept = 5;
yych = *(mrk = ++cur);
default: goto yy62;
}
yy55:
-#line 507 "src/parser.re"
+#line 460 "src/parser.re"
{ NEWTOKEN(PSI_T_NAME); goto start; }
-#line 872 "src/parser.c"
+#line 825 "src/parser.c"
yy56:
yyaccept = 5;
yych = *(mrk = ++cur);
}
yy75:
++cur;
-#line 406 "src/parser.re"
+#line 359 "src/parser.re"
{ NEWTOKEN(PSI_T_LBRACKET); goto start; }
-#line 1117 "src/parser.c"
+#line 1070 "src/parser.c"
yy77:
yych = *++cur;
switch (yych) {
default: goto yy184;
}
yy78:
-#line 421 "src/parser.re"
+#line 374 "src/parser.re"
{ NEWTOKEN(PSI_T_BSLASH); goto start; }
-#line 1201 "src/parser.c"
+#line 1154 "src/parser.c"
yy79:
++cur;
-#line 407 "src/parser.re"
+#line 360 "src/parser.re"
{ NEWTOKEN(PSI_T_RBRACKET); goto start; }
-#line 1206 "src/parser.c"
+#line 1159 "src/parser.c"
yy81:
++cur;
-#line 423 "src/parser.re"
+#line 376 "src/parser.re"
{ NEWTOKEN(PSI_T_CARET); goto start; }
-#line 1211 "src/parser.c"
+#line 1164 "src/parser.c"
yy83:
yyaccept = 5;
yych = *(mrk = ++cur);
}
yy96:
++cur;
-#line 404 "src/parser.re"
+#line 357 "src/parser.re"
{ NEWTOKEN(PSI_T_LBRACE); goto start; }
-#line 1353 "src/parser.c"
+#line 1306 "src/parser.c"
yy98:
yych = *++cur;
switch (yych) {
default: goto yy99;
}
yy99:
-#line 422 "src/parser.re"
+#line 375 "src/parser.re"
{ NEWTOKEN(PSI_T_PIPE); goto start; }
-#line 1363 "src/parser.c"
+#line 1316 "src/parser.c"
yy100:
++cur;
-#line 405 "src/parser.re"
+#line 358 "src/parser.re"
{ NEWTOKEN(PSI_T_RBRACE); goto start; }
-#line 1368 "src/parser.c"
+#line 1321 "src/parser.c"
yy102:
++cur;
-#line 414 "src/parser.re"
+#line 367 "src/parser.re"
{ NEWTOKEN(PSI_T_TILDE); goto start; }
-#line 1373 "src/parser.c"
+#line 1326 "src/parser.c"
yy104:
++cur;
-#line 408 "src/parser.re"
+#line 361 "src/parser.re"
{ NEWTOKEN(PSI_T_CMP_NE); goto start; }
-#line 1378 "src/parser.c"
+#line 1331 "src/parser.c"
yy106:
++cur;
-#line 397 "src/parser.re"
+#line 350 "src/parser.re"
{ NEWTOKEN(PSI_T_CPP_PASTE); goto start; }
-#line 1383 "src/parser.c"
+#line 1336 "src/parser.c"
yy108:
++cur;
if (lim <= cur) if (cur >= lim) goto done;;
default: goto yy108;
}
yy110:
-#line 509 "src/parser.re"
+#line 462 "src/parser.re"
{ NEWTOKEN(PSI_T_DOLLAR_NAME); goto start; }
-#line 1459 "src/parser.c"
+#line 1412 "src/parser.c"
yy111:
++cur;
-#line 410 "src/parser.re"
+#line 363 "src/parser.re"
{ NEWTOKEN(PSI_T_AND); goto start; }
-#line 1464 "src/parser.c"
+#line 1417 "src/parser.c"
yy113:
yych = *++cur;
switch (yych) {
default: goto yy118;
}
yy118:
-#line 380 "src/parser.re"
+#line 333 "src/parser.re"
{ NEWTOKEN(PSI_T_NUMBER); token->flags = PSI_NUMBER_FLT; goto start; }
-#line 1600 "src/parser.c"
+#line 1553 "src/parser.c"
yy119:
++cur;
-#line 394 "src/parser.re"
+#line 347 "src/parser.re"
{ goto comment; }
-#line 1605 "src/parser.c"
+#line 1558 "src/parser.c"
yy121:
++cur;
-#line 395 "src/parser.re"
+#line 348 "src/parser.re"
{ goto comment_sl; }
-#line 1610 "src/parser.c"
+#line 1563 "src/parser.c"
yy123:
yyaccept = 6;
mrk = ++cur;
}
yy129:
cur -= 1;
-#line 376 "src/parser.re"
+#line 329 "src/parser.re"
{ NEWTOKEN(PSI_T_NUMBER); token->flags = PSI_NUMBER_INT | PSI_NUMBER_L; cur += 1; goto start; }
-#line 1688 "src/parser.c"
+#line 1641 "src/parser.c"
yy130:
yych = *++cur;
switch (yych) {
}
yy131:
cur -= 1;
-#line 375 "src/parser.re"
+#line 328 "src/parser.re"
{ NEWTOKEN(PSI_T_NUMBER); token->flags = PSI_NUMBER_INT | PSI_NUMBER_U; cur += 1; goto start; }
-#line 1700 "src/parser.c"
+#line 1653 "src/parser.c"
yy132:
yych = *++cur;
switch (yych) {
}
yy135:
++cur;
-#line 424 "src/parser.re"
+#line 377 "src/parser.re"
{ NEWTOKEN(PSI_T_LSHIFT); goto start; }
-#line 1806 "src/parser.c"
+#line 1759 "src/parser.c"
yy137:
++cur;
-#line 426 "src/parser.re"
+#line 379 "src/parser.re"
{ NEWTOKEN(PSI_T_CMP_LE); goto start; }
-#line 1811 "src/parser.c"
+#line 1764 "src/parser.c"
yy139:
++cur;
-#line 409 "src/parser.re"
+#line 362 "src/parser.re"
{ NEWTOKEN(PSI_T_CMP_EQ); goto start; }
-#line 1816 "src/parser.c"
+#line 1769 "src/parser.c"
yy141:
++cur;
-#line 427 "src/parser.re"
+#line 380 "src/parser.re"
{ NEWTOKEN(PSI_T_CMP_GE); goto start; }
-#line 1821 "src/parser.c"
+#line 1774 "src/parser.c"
yy143:
++cur;
-#line 425 "src/parser.re"
+#line 378 "src/parser.re"
{ NEWTOKEN(PSI_T_RSHIFT); goto start; }
-#line 1826 "src/parser.c"
+#line 1779 "src/parser.c"
yy145:
yyaccept = 5;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy147:
-#line 487 "src/parser.re"
+#line 440 "src/parser.re"
{ NEWTOKEN(PSI_T_AS); goto start; }
-#line 1909 "src/parser.c"
+#line 1862 "src/parser.c"
yy148:
++cur;
if (lim <= cur) if (cur >= lim) goto done;;
default: goto yy61;
}
yy161:
-#line 457 "src/parser.re"
+#line 410 "src/parser.re"
{ NEWTOKEN(PSI_T_IF); goto start; }
-#line 2160 "src/parser.c"
+#line 2113 "src/parser.c"
yy162:
yyaccept = 5;
yych = *(mrk = ++cur);
yy163:
++cur;
cur -= 1;
-#line 392 "src/parser.re"
+#line 345 "src/parser.re"
{ char_width = sizeof(wchar_t)/8; }
-#line 2176 "src/parser.c"
+#line 2129 "src/parser.c"
yy165:
yyaccept = 5;
yych = *(mrk = ++cur);
yy179:
++cur;
cur -= 1;
-#line 391 "src/parser.re"
+#line 344 "src/parser.re"
{ char_width = 4; }
-#line 2295 "src/parser.c"
+#line 2248 "src/parser.c"
yy181:
yyaccept = 5;
yych = *(mrk = ++cur);
default: goto yy184;
}
yy186:
-#line 508 "src/parser.re"
+#line 461 "src/parser.re"
{ NEWTOKEN(PSI_T_NSNAME); goto start; }
-#line 2396 "src/parser.c"
+#line 2349 "src/parser.c"
yy187:
yyaccept = 5;
yych = *(mrk = ++cur);
yy202:
++cur;
cur -= 1;
-#line 390 "src/parser.re"
+#line 343 "src/parser.re"
{ char_width = 2; }
-#line 2527 "src/parser.c"
+#line 2480 "src/parser.c"
yy204:
yyaccept = 5;
yych = *(mrk = ++cur);
}
yy207:
++cur;
-#line 411 "src/parser.re"
+#line 364 "src/parser.re"
{ NEWTOKEN(PSI_T_OR); goto start; }
-#line 2557 "src/parser.c"
+#line 2510 "src/parser.c"
yy209:
++cur;
-#line 431 "src/parser.re"
+#line 384 "src/parser.re"
{ NEWTOKEN(PSI_T_ELLIPSIS); goto start; }
-#line 2562 "src/parser.c"
+#line 2515 "src/parser.c"
yy211:
yych = *++cur;
switch (yych) {
yy212:
++cur;
cur -= 1;
-#line 381 "src/parser.re"
+#line 334 "src/parser.re"
{ NEWTOKEN(PSI_T_NUMBER); token->flags = PSI_NUMBER_FLT | PSI_NUMBER_F; cur += 1; goto start; }
-#line 2579 "src/parser.c"
+#line 2532 "src/parser.c"
yy214:
++cur;
cur -= 1;
-#line 382 "src/parser.re"
+#line 335 "src/parser.re"
{ NEWTOKEN(PSI_T_NUMBER); token->flags = PSI_NUMBER_FLT | PSI_NUMBER_L; cur += 1; goto start; }
-#line 2585 "src/parser.c"
+#line 2538 "src/parser.c"
yy216:
yych = *++cur;
switch (yych) {
++cur;
yy218:
cur -= 2;
-#line 377 "src/parser.re"
+#line 330 "src/parser.re"
{ NEWTOKEN(PSI_T_NUMBER); token->flags = PSI_NUMBER_INT | PSI_NUMBER_UL; cur += 2; goto start; }
-#line 2599 "src/parser.c"
+#line 2552 "src/parser.c"
yy219:
yych = *++cur;
switch (yych) {
}
yy222:
++cur;
-#line 510 "src/parser.re"
+#line 463 "src/parser.re"
{ tok += 1; cur -= 1; NEWTOKEN(PSI_T_CPP_HEADER); cur += 1; goto start; }
-#line 2648 "src/parser.c"
+#line 2601 "src/parser.c"
yy224:
yyaccept = 5;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy242:
-#line 482 "src/parser.re"
+#line 435 "src/parser.re"
{ NEWTOKEN(PSI_T_LET); goto start; }
-#line 2861 "src/parser.c"
+#line 2814 "src/parser.c"
yy243:
yyaccept = 12;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy244:
-#line 481 "src/parser.re"
+#line 434 "src/parser.re"
{ NEWTOKEN(PSI_T_LIB); goto start; }
-#line 2936 "src/parser.c"
+#line 2889 "src/parser.c"
yy245:
yyaccept = 5;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy253:
-#line 483 "src/parser.re"
+#line 436 "src/parser.re"
{ NEWTOKEN(PSI_T_SET); goto start; }
-#line 3068 "src/parser.c"
+#line 3021 "src/parser.c"
yy254:
yyaccept = 5;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy273:
-#line 451 "src/parser.re"
+#line 404 "src/parser.re"
{ NEWTOKEN(PSI_T_INT); goto start; }
-#line 3296 "src/parser.c"
+#line 3249 "src/parser.c"
yy274:
yyaccept = 5;
yych = *(mrk = ++cur);
yy282:
++cur;
cur -= 1;
-#line 389 "src/parser.re"
+#line 342 "src/parser.re"
{ char_width = 1; }
-#line 3364 "src/parser.c"
+#line 3317 "src/parser.c"
yy284:
yyaccept = 5;
yych = *(mrk = ++cur);
yy288:
++cur;
cur -= 2;
-#line 384 "src/parser.re"
+#line 337 "src/parser.re"
{ NEWTOKEN(PSI_T_NUMBER); token->flags = PSI_NUMBER_FLT | PSI_NUMBER_DD; cur += 2; goto start; }
-#line 3398 "src/parser.c"
+#line 3351 "src/parser.c"
yy290:
++cur;
cur -= 2;
-#line 383 "src/parser.re"
+#line 336 "src/parser.re"
{ NEWTOKEN(PSI_T_NUMBER); token->flags = PSI_NUMBER_FLT | PSI_NUMBER_DF; cur += 2; goto start; }
-#line 3404 "src/parser.c"
+#line 3357 "src/parser.c"
yy292:
++cur;
cur -= 2;
-#line 385 "src/parser.re"
+#line 338 "src/parser.re"
{ NEWTOKEN(PSI_T_NUMBER); token->flags = PSI_NUMBER_FLT | PSI_NUMBER_DL; cur += 2; goto start; }
-#line 3410 "src/parser.c"
+#line 3363 "src/parser.c"
yy294:
++cur;
cur -= 3;
-#line 378 "src/parser.re"
+#line 331 "src/parser.re"
{ NEWTOKEN(PSI_T_NUMBER); token->flags = PSI_NUMBER_INT | PSI_NUMBER_ULL; cur += 3; goto start; }
-#line 3416 "src/parser.c"
+#line 3369 "src/parser.c"
yy296:
++cur;
if ((lim - cur) < 3) if (cur >= lim) goto done;;
default: goto yy61;
}
yy305:
-#line 461 "src/parser.re"
+#line 414 "src/parser.re"
{ NEWTOKEN(PSI_T_ELIF); goto start; }
-#line 3574 "src/parser.c"
+#line 3527 "src/parser.c"
yy306:
yyaccept = 16;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy307:
-#line 460 "src/parser.re"
+#line 413 "src/parser.re"
{ NEWTOKEN(PSI_T_ELSE); goto start; }
-#line 3649 "src/parser.c"
+#line 3602 "src/parser.c"
yy308:
yyaccept = 5;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy313:
-#line 488 "src/parser.re"
+#line 441 "src/parser.re"
{ NEWTOKEN(PSI_T_FREE); goto start; }
-#line 3756 "src/parser.c"
+#line 3709 "src/parser.c"
yy314:
yyaccept = 5;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy321:
-#line 472 "src/parser.re"
+#line 425 "src/parser.re"
{ NEWTOKEN(PSI_T_NULL); goto start; }
-#line 3879 "src/parser.c"
+#line 3832 "src/parser.c"
yy322:
yyaccept = 5;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy333:
-#line 489 "src/parser.re"
+#line 442 "src/parser.re"
{ NEWTOKEN(PSI_T_TEMP); goto start; }
-#line 4033 "src/parser.c"
+#line 3986 "src/parser.c"
yy334:
yyaccept = 5;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy341:
-#line 470 "src/parser.re"
+#line 423 "src/parser.re"
{ NEWTOKEN(PSI_T_TRUE); goto start; }
-#line 4156 "src/parser.c"
+#line 4109 "src/parser.c"
yy342:
yyaccept = 5;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy345:
-#line 498 "src/parser.re"
+#line 451 "src/parser.re"
{ NEWTOKEN(PSI_T_ZVAL); goto start; }
-#line 4247 "src/parser.c"
+#line 4200 "src/parser.c"
yy346:
yyaccept = 5;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy352:
-#line 448 "src/parser.re"
+#line 401 "src/parser.re"
{ NEWTOKEN(PSI_T_BOOL); goto start; }
-#line 4359 "src/parser.c"
+#line 4312 "src/parser.c"
yy353:
yyaccept = 23;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy354:
-#line 449 "src/parser.re"
+#line 402 "src/parser.re"
{ NEWTOKEN(PSI_T_CHAR); goto start; }
-#line 4434 "src/parser.c"
+#line 4387 "src/parser.c"
yy355:
yyaccept = 5;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy358:
-#line 445 "src/parser.re"
+#line 398 "src/parser.re"
{ NEWTOKEN(PSI_T_ENUM); goto start; }
-#line 4523 "src/parser.c"
+#line 4476 "src/parser.c"
yy359:
yyaccept = 5;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy361:
-#line 441 "src/parser.re"
+#line 394 "src/parser.re"
{ NEWTOKEN(PSI_T_LINE); goto start; }
-#line 4606 "src/parser.c"
+#line 4559 "src/parser.c"
yy362:
yyaccept = 26;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy363:
-#line 452 "src/parser.re"
+#line 405 "src/parser.re"
{ NEWTOKEN(PSI_T_LONG); goto start; }
-#line 4681 "src/parser.c"
+#line 4634 "src/parser.c"
yy364:
yyaccept = 5;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy373:
-#line 447 "src/parser.re"
+#line 400 "src/parser.re"
{ NEWTOKEN(PSI_T_VOID); goto start; }
-#line 4812 "src/parser.c"
+#line 4765 "src/parser.c"
yy374:
yyaccept = 5;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy376:
-#line 476 "src/parser.re"
+#line 429 "src/parser.re"
{ NEWTOKEN(PSI_T_ARRAY); goto start; }
-#line 4894 "src/parser.c"
+#line 4847 "src/parser.c"
yy377:
yyaccept = 5;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy383:
-#line 499 "src/parser.re"
+#line 452 "src/parser.re"
{ NEWTOKEN(PSI_T_COUNT); goto start; }
-#line 5009 "src/parser.c"
+#line 4962 "src/parser.c"
yy384:
yyaccept = 5;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy386:
-#line 462 "src/parser.re"
+#line 415 "src/parser.re"
{ NEWTOKEN(PSI_T_ENDIF); goto start; }
-#line 5092 "src/parser.c"
+#line 5045 "src/parser.c"
yy387:
yyaccept = 31;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy388:
-#line 467 "src/parser.re"
+#line 420 "src/parser.re"
{ NEWTOKEN(PSI_T_ERROR); goto start; }
-#line 5167 "src/parser.c"
+#line 5120 "src/parser.c"
yy389:
yyaccept = 32;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy390:
-#line 471 "src/parser.re"
+#line 424 "src/parser.re"
{ NEWTOKEN(PSI_T_FALSE); goto start; }
-#line 5242 "src/parser.c"
+#line 5195 "src/parser.c"
yy391:
yyaccept = 5;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy394:
-#line 458 "src/parser.re"
+#line 411 "src/parser.re"
{ NEWTOKEN(PSI_T_IFDEF); goto start; }
-#line 5333 "src/parser.c"
+#line 5286 "src/parser.c"
yy395:
yyaccept = 5;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy399:
-#line 473 "src/parser.re"
+#line 426 "src/parser.re"
{ NEWTOKEN(PSI_T_MIXED); goto start; }
-#line 5432 "src/parser.c"
+#line 5385 "src/parser.c"
yy400:
yyaccept = 5;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy417:
-#line 465 "src/parser.re"
+#line 418 "src/parser.re"
{ NEWTOKEN(PSI_T_UNDEF); goto start; }
-#line 5635 "src/parser.c"
+#line 5588 "src/parser.c"
yy418:
yyaccept = 5;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy425:
-#line 446 "src/parser.re"
+#line 399 "src/parser.re"
{ NEWTOKEN(PSI_T_CONST); goto start; }
-#line 5753 "src/parser.c"
+#line 5706 "src/parser.c"
yy426:
yyaccept = 5;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy428:
-#line 453 "src/parser.re"
+#line 406 "src/parser.re"
{ NEWTOKEN(PSI_T_FLOAT); goto start; }
-#line 5837 "src/parser.c"
+#line 5790 "src/parser.c"
yy429:
yyaccept = 5;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy431:
-#line 450 "src/parser.re"
+#line 403 "src/parser.re"
{ NEWTOKEN(PSI_T_SHORT); goto start; }
-#line 5919 "src/parser.c"
+#line 5872 "src/parser.c"
yy432:
yyaccept = 5;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy437:
-#line 444 "src/parser.re"
+#line 397 "src/parser.re"
{ NEWTOKEN(PSI_T_UNION); goto start; }
-#line 6022 "src/parser.c"
+#line 5975 "src/parser.c"
yy438:
yyaccept = 5;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy441:
-#line 496 "src/parser.re"
+#line 449 "src/parser.re"
{ NEWTOKEN(PSI_T_ARRVAL); goto start; }
-#line 6111 "src/parser.c"
+#line 6064 "src/parser.c"
yy442:
yyaccept = 5;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy446:
-#line 500 "src/parser.re"
+#line 453 "src/parser.re"
{ NEWTOKEN(PSI_T_CALLOC); goto start; }
-#line 6210 "src/parser.c"
+#line 6163 "src/parser.c"
yy447:
yyaccept = 42;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy448:
-#line 463 "src/parser.re"
+#line 416 "src/parser.re"
{ NEWTOKEN(PSI_T_DEFINE); goto start; }
-#line 6287 "src/parser.c"
+#line 6240 "src/parser.c"
yy449:
yyaccept = 5;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy452:
-#line 459 "src/parser.re"
+#line 412 "src/parser.re"
{ NEWTOKEN(PSI_T_IFNDEF); goto start; }
-#line 6378 "src/parser.c"
+#line 6331 "src/parser.c"
yy453:
yyaccept = 5;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy455:
-#line 493 "src/parser.re"
+#line 446 "src/parser.re"
{ NEWTOKEN(PSI_T_INTVAL); goto start; }
-#line 6461 "src/parser.c"
+#line 6414 "src/parser.c"
yy456:
yyaccept = 45;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy457:
-#line 477 "src/parser.re"
+#line 430 "src/parser.re"
{ NEWTOKEN(PSI_T_OBJECT); goto start; }
-#line 6536 "src/parser.c"
+#line 6489 "src/parser.c"
yy458:
yyaccept = 46;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy459:
-#line 497 "src/parser.re"
+#line 450 "src/parser.re"
{ NEWTOKEN(PSI_T_OBJVAL); goto start; }
-#line 6611 "src/parser.c"
+#line 6564 "src/parser.c"
yy460:
yyaccept = 5;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy464:
-#line 486 "src/parser.re"
+#line 439 "src/parser.re"
{ NEWTOKEN(PSI_T_RETURN); goto start; }
-#line 6710 "src/parser.c"
+#line 6663 "src/parser.c"
yy465:
yyaccept = 48;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy466:
-#line 479 "src/parser.re"
+#line 432 "src/parser.re"
{ NEWTOKEN(PSI_T_STATIC); goto start; }
-#line 6785 "src/parser.c"
+#line 6738 "src/parser.c"
yy467:
yyaccept = 49;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy468:
-#line 475 "src/parser.re"
+#line 428 "src/parser.re"
{ NEWTOKEN(PSI_T_STRING); goto start; }
-#line 6860 "src/parser.c"
+#line 6813 "src/parser.c"
yy469:
yyaccept = 50;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy470:
-#line 490 "src/parser.re"
+#line 443 "src/parser.re"
{ NEWTOKEN(PSI_T_STRLEN); goto start; }
-#line 6935 "src/parser.c"
+#line 6888 "src/parser.c"
yy471:
yyaccept = 51;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy472:
-#line 491 "src/parser.re"
+#line 444 "src/parser.re"
{ NEWTOKEN(PSI_T_STRVAL); goto start; }
-#line 7010 "src/parser.c"
+#line 6963 "src/parser.c"
yy473:
yyaccept = 5;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy477:
-#line 504 "src/parser.re"
+#line 457 "src/parser.re"
{ NEWTOKEN(PSI_T_TO_INT); goto start; }
-#line 7109 "src/parser.c"
+#line 7062 "src/parser.c"
yy478:
yyaccept = 5;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy487:
-#line 454 "src/parser.re"
+#line 407 "src/parser.re"
{ NEWTOKEN(PSI_T_DOUBLE); goto start; }
-#line 7243 "src/parser.c"
+#line 7196 "src/parser.c"
yy488:
yyaccept = 54;
yych = *(mrk = ++cur);
default: goto yy527;
}
yy489:
-#line 433 "src/parser.re"
+#line 386 "src/parser.re"
{ NEWTOKEN(PSI_T_PRAGMA); goto start; }
-#line 7318 "src/parser.c"
+#line 7271 "src/parser.c"
yy490:
yyaccept = 55;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy491:
-#line 456 "src/parser.re"
+#line 409 "src/parser.re"
{ NEWTOKEN(PSI_T_SIGNED); goto start; }
-#line 7393 "src/parser.c"
+#line 7346 "src/parser.c"
yy492:
yyaccept = 56;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy493:
-#line 440 "src/parser.re"
+#line 393 "src/parser.re"
{ NEWTOKEN(PSI_T_SIZEOF); goto start; }
-#line 7468 "src/parser.c"
+#line 7421 "src/parser.c"
yy494:
yyaccept = 57;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy495:
-#line 443 "src/parser.re"
+#line 396 "src/parser.re"
{ NEWTOKEN(PSI_T_STRUCT); goto start; }
-#line 7543 "src/parser.c"
+#line 7496 "src/parser.c"
yy496:
yyaccept = 5;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy500:
-#line 495 "src/parser.re"
+#line 448 "src/parser.re"
{ NEWTOKEN(PSI_T_BOOLVAL); goto start; }
-#line 7639 "src/parser.c"
+#line 7592 "src/parser.c"
yy501:
yyaccept = 5;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy504:
-#line 464 "src/parser.re"
+#line 417 "src/parser.re"
{ NEWTOKEN(PSI_T_DEFINED); goto start; }
-#line 7730 "src/parser.c"
+#line 7683 "src/parser.c"
yy505:
yyaccept = 5;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy508:
-#line 468 "src/parser.re"
+#line 421 "src/parser.re"
{ NEWTOKEN(PSI_T_INCLUDE); goto start; }
-#line 7822 "src/parser.c"
+#line 7775 "src/parser.c"
yy509:
yyaccept = 61;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy510:
-#line 492 "src/parser.re"
+#line 445 "src/parser.re"
{ NEWTOKEN(PSI_T_PATHVAL); goto start; }
-#line 7897 "src/parser.c"
+#line 7850 "src/parser.c"
yy511:
yyaccept = 5;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy515:
-#line 506 "src/parser.re"
+#line 459 "src/parser.re"
{ NEWTOKEN(PSI_T_TO_BOOL); goto start; }
-#line 7996 "src/parser.c"
+#line 7949 "src/parser.c"
yy516:
yyaccept = 5;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy520:
-#line 466 "src/parser.re"
+#line 419 "src/parser.re"
{ NEWTOKEN(PSI_T_WARNING); goto start; }
-#line 8095 "src/parser.c"
+#line 8048 "src/parser.c"
yy521:
yyaccept = 64;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy522:
-#line 438 "src/parser.re"
+#line 391 "src/parser.re"
{ NEWTOKEN(PSI_T_CPP_ASM); goto start; }
-#line 8170 "src/parser.c"
+#line 8123 "src/parser.c"
yy523:
yyaccept = 5;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy530:
-#line 442 "src/parser.re"
+#line 395 "src/parser.re"
{ NEWTOKEN(PSI_T_TYPEDEF); goto start; }
-#line 8347 "src/parser.c"
+#line 8300 "src/parser.c"
yy531:
yyaccept = 5;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy534:
-#line 474 "src/parser.re"
+#line 427 "src/parser.re"
{ NEWTOKEN(PSI_T_CALLABLE); goto start; }
-#line 8436 "src/parser.c"
+#line 8389 "src/parser.c"
yy535:
yyaccept = 67;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy536:
-#line 478 "src/parser.re"
+#line 431 "src/parser.re"
{ NEWTOKEN(PSI_T_CALLBACK); goto start; }
-#line 8511 "src/parser.c"
+#line 8464 "src/parser.c"
yy537:
yyaccept = 68;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy538:
-#line 494 "src/parser.re"
+#line 447 "src/parser.re"
{ NEWTOKEN(PSI_T_FLOATVAL); goto start; }
-#line 8586 "src/parser.c"
+#line 8539 "src/parser.c"
yy539:
yyaccept = 69;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy540:
-#line 480 "src/parser.re"
+#line 433 "src/parser.re"
{ NEWTOKEN(PSI_T_FUNCTION); goto start; }
-#line 8661 "src/parser.c"
+#line 8614 "src/parser.c"
yy541:
yyaccept = 5;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy545:
-#line 502 "src/parser.re"
+#line 455 "src/parser.re"
{ NEWTOKEN(PSI_T_TO_ARRAY); goto start; }
-#line 8760 "src/parser.c"
+#line 8713 "src/parser.c"
yy546:
yyaccept = 71;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy547:
-#line 505 "src/parser.re"
+#line 458 "src/parser.re"
{ NEWTOKEN(PSI_T_TO_FLOAT); goto start; }
-#line 8835 "src/parser.c"
+#line 8788 "src/parser.c"
yy548:
yyaccept = 5;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy553:
-#line 435 "src/parser.re"
+#line 388 "src/parser.re"
{ NEWTOKEN(PSI_T_CPP_INLINE); goto start; }
-#line 8940 "src/parser.c"
+#line 8893 "src/parser.c"
yy554:
yyaccept = 5;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy558:
-#line 455 "src/parser.re"
+#line 408 "src/parser.re"
{ NEWTOKEN(PSI_T_UNSIGNED); goto start; }
-#line 9097 "src/parser.c"
+#line 9050 "src/parser.c"
yy559:
yyaccept = 74;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy560:
-#line 439 "src/parser.re"
+#line 392 "src/parser.re"
{ NEWTOKEN(PSI_T_VOLATILE); goto start; }
-#line 9172 "src/parser.c"
+#line 9125 "src/parser.c"
yy561:
yyaccept = 5;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy565:
-#line 501 "src/parser.re"
+#line 454 "src/parser.re"
{ NEWTOKEN(PSI_T_TO_OBJECT); goto start; }
-#line 9271 "src/parser.c"
+#line 9224 "src/parser.c"
yy566:
yyaccept = 76;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy567:
-#line 503 "src/parser.re"
+#line 456 "src/parser.re"
{ NEWTOKEN(PSI_T_TO_STRING); goto start; }
-#line 9346 "src/parser.c"
+#line 9299 "src/parser.c"
yy568:
yyaccept = 5;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy575:
-#line 484 "src/parser.re"
+#line 437 "src/parser.re"
{ NEWTOKEN(PSI_T_PRE_ASSERT); goto start; }
-#line 9533 "src/parser.c"
+#line 9486 "src/parser.c"
yy576:
yyaccept = 5;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy579:
-#line 436 "src/parser.re"
+#line 389 "src/parser.re"
{ NEWTOKEN(PSI_T_CPP_RESTRICT); goto start; }
-#line 9622 "src/parser.c"
+#line 9575 "src/parser.c"
yy580:
yyaccept = 5;
mrk = ++cur;
default: goto yy61;
}
yy583:
-#line 485 "src/parser.re"
+#line 438 "src/parser.re"
{ NEWTOKEN(PSI_T_POST_ASSERT); goto start; }
-#line 9780 "src/parser.c"
+#line 9733 "src/parser.c"
yy584:
yyaccept = 5;
yych = *(mrk = ++cur);
default: goto yy527;
}
yy587:
-#line 434 "src/parser.re"
+#line 387 "src/parser.re"
{ NEWTOKEN(PSI_T_PRAGMA_ONCE); goto start; }
-#line 9872 "src/parser.c"
+#line 9825 "src/parser.c"
yy588:
yyaccept = 81;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy589:
-#line 469 "src/parser.re"
+#line 422 "src/parser.re"
{ NEWTOKEN(PSI_T_INCLUDE_NEXT); goto start; }
-#line 9947 "src/parser.c"
+#line 9900 "src/parser.c"
yy590:
yyaccept = 5;
yych = *(mrk = ++cur);
default: goto yy61;
}
yy594:
-#line 437 "src/parser.re"
+#line 390 "src/parser.re"
{ NEWTOKEN(PSI_T_CPP_EXTENSION); goto start; }
-#line 10046 "src/parser.c"
+#line 9999 "src/parser.c"
yy595:
++cur;
if ((lim - cur) < 2) if (cur >= lim) goto done;;
}
yy598:
++cur;
-#line 511 "src/parser.re"
+#line 464 "src/parser.re"
{ parens = 2; goto cpp_attribute; }
-#line 10068 "src/parser.c"
+#line 10021 "src/parser.c"
}
-#line 517 "src/parser.re"
+#line 470 "src/parser.re"
character: ;
-#line 10075 "src/parser.c"
+#line 10028 "src/parser.c"
{
unsigned char yych;
if (lim <= cur) if (cur >= lim) goto done;;
}
yy602:
++cur;
-#line 535 "src/parser.re"
+#line 488 "src/parser.re"
{ escaped = false; goto character; }
-#line 10091 "src/parser.c"
+#line 10044 "src/parser.c"
yy604:
++cur;
-#line 522 "src/parser.re"
+#line 475 "src/parser.re"
{ NEWLINE(); goto character; }
-#line 10096 "src/parser.c"
+#line 10049 "src/parser.c"
yy606:
++cur;
-#line 524 "src/parser.re"
+#line 477 "src/parser.re"
{
if (escaped) {
escaped = false;
token->flags = char_width;
goto start;
}
-#line 10111 "src/parser.c"
+#line 10064 "src/parser.c"
yy608:
++cur;
-#line 523 "src/parser.re"
+#line 476 "src/parser.re"
{ escaped = !escaped; goto character; }
-#line 10116 "src/parser.c"
+#line 10069 "src/parser.c"
}
-#line 537 "src/parser.re"
+#line 490 "src/parser.re"
string: ;
-#line 10123 "src/parser.c"
+#line 10076 "src/parser.c"
{
unsigned char yych;
if (lim <= cur) if (cur >= lim) goto done;;
}
yy612:
++cur;
-#line 555 "src/parser.re"
+#line 508 "src/parser.re"
{ escaped = false; goto string; }
-#line 10139 "src/parser.c"
+#line 10092 "src/parser.c"
yy614:
++cur;
-#line 542 "src/parser.re"
+#line 495 "src/parser.re"
{ NEWLINE(); goto string; }
-#line 10144 "src/parser.c"
+#line 10097 "src/parser.c"
yy616:
++cur;
-#line 544 "src/parser.re"
+#line 497 "src/parser.re"
{
if (escaped) {
escaped = false;
token->flags = char_width;
goto start;
}
-#line 10159 "src/parser.c"
+#line 10112 "src/parser.c"
yy618:
++cur;
-#line 543 "src/parser.re"
+#line 496 "src/parser.re"
{ escaped = !escaped; goto string; }
-#line 10164 "src/parser.c"
+#line 10117 "src/parser.c"
}
-#line 557 "src/parser.re"
+#line 510 "src/parser.re"
comment: ;
-#line 10171 "src/parser.c"
+#line 10124 "src/parser.c"
{
unsigned char yych;
if ((lim - cur) < 2) if (cur >= lim) goto done;;
yy622:
++cur;
yy623:
-#line 564 "src/parser.re"
+#line 517 "src/parser.re"
{ goto comment; }
-#line 10187 "src/parser.c"
+#line 10140 "src/parser.c"
yy624:
++cur;
-#line 562 "src/parser.re"
+#line 515 "src/parser.re"
{ NEWLINE(); goto comment; }
-#line 10192 "src/parser.c"
+#line 10145 "src/parser.c"
yy626:
yych = *++cur;
switch (yych) {
}
yy627:
++cur;
-#line 563 "src/parser.re"
+#line 516 "src/parser.re"
{ NEWTOKEN(PSI_T_COMMENT); goto start; }
-#line 10203 "src/parser.c"
+#line 10156 "src/parser.c"
}
-#line 566 "src/parser.re"
+#line 519 "src/parser.re"
comment_sl: ;
-#line 10210 "src/parser.c"
+#line 10163 "src/parser.c"
{
unsigned char yych;
if (lim <= cur) if (cur >= lim) goto done;;
}
yy631:
++cur;
-#line 572 "src/parser.re"
+#line 525 "src/parser.re"
{ goto comment_sl; }
-#line 10224 "src/parser.c"
+#line 10177 "src/parser.c"
yy633:
++cur;
-#line 571 "src/parser.re"
+#line 524 "src/parser.re"
{ NEWTOKEN(PSI_T_COMMENT); NEWLINE(); goto start; }
-#line 10229 "src/parser.c"
+#line 10182 "src/parser.c"
}
-#line 574 "src/parser.re"
+#line 527 "src/parser.re"
cpp_attribute: ;
-#line 10237 "src/parser.c"
+#line 10190 "src/parser.c"
{
unsigned char yych;
if (lim <= cur) if (cur >= lim) goto done;;
}
yy637:
++cur;
-#line 583 "src/parser.re"
+#line 536 "src/parser.re"
{ goto cpp_attribute; }
-#line 10253 "src/parser.c"
+#line 10206 "src/parser.c"
yy639:
++cur;
-#line 582 "src/parser.re"
+#line 535 "src/parser.re"
{ NEWLINE(); goto cpp_attribute; }
-#line 10258 "src/parser.c"
+#line 10211 "src/parser.c"
yy641:
++cur;
-#line 580 "src/parser.re"
+#line 533 "src/parser.re"
{ ++parens; goto cpp_attribute; }
-#line 10263 "src/parser.c"
+#line 10216 "src/parser.c"
yy643:
++cur;
-#line 581 "src/parser.re"
+#line 534 "src/parser.re"
{ if (parens == 1) { NEWTOKEN(PSI_T_CPP_ATTRIBUTE); goto start; } else { --parens; goto cpp_attribute; } }
-#line 10268 "src/parser.c"
+#line 10221 "src/parser.c"
}
-#line 585 "src/parser.re"
+#line 538 "src/parser.re"
error: ;
P->error(PSI_DATA(P), token, PSI_WARNING, "PSI syntax error: unexpected input (%d) '%.*s' at col %tu",
- token->type, token->size, token->text, tok - eol + 1);
+ token->type, token->text->len, token->text->val, tok - eol + 1);
psi_plist_free(tokens);
return NULL;
struct psi_parser_input {
size_t length;
- char *file;
+ zend_string *file;
unsigned lines;
char buffer[1];
};
#include <errno.h>
#include <stdarg.h>
+#include <Zend/zend_smart_str.h>
+
#include "parser.h"
/*!max:re2c*/
return NULL;
}
- if (!(fb = malloc(sizeof(*fb) + strlen(filename) + 1 + sb.st_size + YYMAXFILL))) {
+ if (!(fb = malloc(sizeof(*fb) + sb.st_size + YYMAXFILL))) {
if (report_errors) {
P->error(PSI_DATA(P), NULL, PSI_WARNING,
"Could not allocate %zu bytes for reading '%s': %s",
return NULL;
}
- memset(fb->buffer + sb.st_size, 0, YYMAXFILL);
fb->length = sb.st_size;
- fb->file = &fb->buffer[sb.st_size + YYMAXFILL];
- memcpy(fb->file, filename, strlen(filename) + 1);
+ fb->file = zend_string_init(filename, strlen(filename), 1);
return fb;
}
{
struct psi_parser_input *sb;
- if (!(sb = malloc(sizeof(*sb) + sizeof("<stdin>") + length + YYMAXFILL))) {
+ if (!(sb = malloc(sizeof(*sb) + length + YYMAXFILL))) {
P->error(PSI_DATA(P), NULL, PSI_WARNING,
"Could not allocate %zu bytes: %s",
length + YYMAXFILL, strerror(errno));
memset(sb->buffer + length, 0, YYMAXFILL);
sb->length = length;
- sb->file = &sb->buffer[length + YYMAXFILL];
- memcpy(sb->file, "<stdin>", sizeof("<stdin>"));
+ sb->file = zend_string_init("<stdin>", strlen("<stdin>"), 1);
return sb;
}
-#if 0
-static void psi_parser_register_constants(struct psi_parser *P)
-{
- zend_string *key;
- zval *val;
-
- ZEND_HASH_FOREACH_STR_KEY_VAL(&P->cpp.defs, key, val)
- {
- struct psi_impl_def_val *iv;
- struct psi_const_type *ct;
- struct psi_const *c;
- const char *ctn;
- token_t ctt;
- impl_val tmp;
- zend_string *str;
-
- ZVAL_DEREF(val);
- switch (Z_TYPE_P(val)) {
- case IS_TRUE:
- case IS_FALSE:
- ctt = PSI_T_BOOL;
- ctn = "bool";
- tmp.zend.bval = Z_TYPE_P(val) == IS_TRUE;
- break;
- case IS_LONG:
- ctt = PSI_T_INT;
- ctn = "int";
- tmp.zend.lval = Z_LVAL_P(val);
- break;
- case IS_DOUBLE:
- ctt = PSI_T_FLOAT;
- ctn = "float";
- tmp.dval = Z_DVAL_P(val);
- break;
- default:
- ctt = PSI_T_STRING;
- ctn = "string";
- str = zval_get_string(val);
- tmp.zend.str = zend_string_dup(str, 1);
- zend_string_release(str);
- break;
- }
-
- iv = psi_impl_def_val_init(ctt, NULL);
- iv->ival = tmp;
- ct = psi_const_type_init(ctt, ctn);
- c = psi_const_init(ct, key->val, iv);
- if (!P->consts) {
- P->consts = psi_plist_init((psi_plist_dtor) psi_const_free);
- }
- P->consts = psi_plist_add(P->consts, &c);
- }
- ZEND_HASH_FOREACH_END();
-}
-#endif
-
struct psi_plist *psi_parser_preprocess(struct psi_parser *P, struct psi_plist **tokens)
{
if (psi_cpp_process(P->preproc, tokens)) {
struct psi_impl_def_val *def;
struct psi_const *cnst;
struct psi_num_exp *num;
- char *name_str = malloc(name->len + sizeof("psi\\"));
+ smart_str ns_name = {0};
+ zend_string *name_str;
+
+ smart_str_appendl_ex(&ns_name, ZEND_STRL("psi\\"), 1);
+ smart_str_append_ex(&ns_name, name, 1);
+ name_str = smart_str_extract(&ns_name);
- strcat(strcpy(name_str, "psi\\"), name->val);
num = psi_num_exp_copy(scope.macro->exp);
def = psi_impl_def_val_init(PSI_T_NUMBER, num);
- type = psi_impl_type_init(PSI_T_NUMBER, "<eval number>");
+ type = psi_impl_type_init(PSI_T_NUMBER,
+ zend_string_init(ZEND_STRL("<eval number>"), 1));
cnst = psi_const_init(type, name_str, def);
P->consts = psi_plist_add(P->consts, &cnst);
- free(name_str);
+ zend_string_release(name_str);
}
} else {
if (psi_plist_count(scope.macro->tokens) == 1) {
struct psi_impl_type *type;
struct psi_impl_def_val *def;
struct psi_const *cnst;
- char *name_str = malloc(name->len + sizeof("psi\\"));
+ smart_str ns_name = {0};
+ zend_string *name_str;
+
+ smart_str_appendl_ex(&ns_name, ZEND_STRL("psi\\"), 1);
+ smart_str_append_ex(&ns_name, name, 1);
+ name_str = smart_str_extract(&ns_name);
- strcat(strcpy(name_str, "psi\\"), name->val);
- type = psi_impl_type_init(PSI_T_STRING, "string");
+ type = psi_impl_type_init(PSI_T_STRING,
+ zend_string_init(ZEND_STRL("string"), 1));
def = psi_impl_def_val_init(PSI_T_QUOTED_STRING, t->text);
cnst = psi_const_init(type, name_str, def);
P->consts = psi_plist_add(P->consts, &cnst);
- free(name_str);
+ zend_string_release(name_str);
}
}
}
bool escaped;
token_t char_width;
- PSI_DEBUG_PRINT(P, "PSI: scanning %s\n", I->file);
+ PSI_DEBUG_PRINT(P, "PSI: scanning %s\n", I->file->val);
tok = mrk = eol = cur = I->buffer;
lim = I->buffer + I->length;
error: ;
P->error(PSI_DATA(P), token, PSI_WARNING, "PSI syntax error: unexpected input (%d) '%.*s' at col %tu",
- token->type, token->size, token->text, tok - eol + 1);
+ token->type, token->text->len, token->text->val, tok - eol + 1);
psi_plist_free(tokens);
return NULL;
return;
}
free(def->type->name);
- def->type->name = strdup(def->var->name);
+ def->type->name = zend_string_copy(def->var->name);
}
static inline void psi_parser_proc_add_typedef(struct psi_parser *P, struct psi_decl_arg *def)
{
static inline void psi_parser_proc_add_decl(struct psi_parser *P, struct psi_decl *decl) {
assert(decl);
- if (psi_decl_is_blacklisted(decl->func->var->name)) {
+ if (psi_decl_is_blacklisted(decl->func->var->name->val)) {
psi_decl_free(&decl);
return;
}
case 285:
#line 458 "src/parser_proc_grammar.y" /* glr.c:817 */
{
- char *libname = strdup((*(struct psi_token **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval))->text);
+ char *libname = strdup((*(struct psi_token **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval))->text->val);
P->file.libnames = psi_plist_add(P->file.libnames, &libname);
}
#line 4308 "src/parser_proc.c" /* glr.c:817 */
#line 471 "src/parser_proc_grammar.y" /* glr.c:817 */
{
if (P->flags & PSI_DEBUG) {
- P->error(PSI_DATA(P), (*(struct psi_decl **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval))->func->token, PSI_NOTICE, "Ignored decl: %s", (*(struct psi_decl **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval))->func->var->name);
+ P->error(PSI_DATA(P), (*(struct psi_decl **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval))->func->token, PSI_NOTICE, "Ignored decl: %s", (*(struct psi_decl **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval))->func->var->name->val);
}
psi_decl_free(&(*(struct psi_decl **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval)));
}
while (psi_plist_get((*(struct psi_plist **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval)), index++, &next)) {
struct psi_token *old = msg;
msg = psi_token_cat(" ", 2, msg, next);
- free(old);
+ psi_token_free(&old);
}
}
psi_plist_free((*(struct psi_plist **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval)));
{
if ((*(struct psi_token **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval))) {
(*(struct psi_token **)(&(*yyvalp))) = psi_token_cat(" ", 2, (*(struct psi_token **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval)), (*(struct psi_token **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval)));
- free((*(struct psi_token **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval)));
+ psi_token_free(&(*(struct psi_token **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval)));
} else {
(*(struct psi_token **)(&(*yyvalp))) = psi_token_copy((*(struct psi_token **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval)));
}
{
if ((*(struct psi_token **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval))) {
(*(struct psi_token **)(&(*yyvalp))) = psi_token_cat(" ", 2, (*(struct psi_token **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval)), (*(struct psi_token **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval)));
- free((*(struct psi_token **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval)));
- free((*(struct psi_token **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval)));
+ psi_token_free(&(*(struct psi_token **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval)));
+ psi_token_free(&(*(struct psi_token **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval)));
} else {
(*(struct psi_token **)(&(*yyvalp))) = (*(struct psi_token **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval));
}
{
if ((*(struct psi_token **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval))) {
(*(struct psi_token **)(&(*yyvalp))) = psi_token_cat(" ", 2, (*(struct psi_token **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval)), (*(struct psi_token **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval)));
- free((*(struct psi_token **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval)));
+ psi_token_free(&(*(struct psi_token **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval)));
} else {
(*(struct psi_token **)(&(*yyvalp))) = psi_token_copy((*(struct psi_token **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval)));
}
{
(*(struct psi_decl **)(&(*yyvalp))) = (*(struct psi_decl **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval));
if ((*(struct psi_token **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval))) {
- (*(struct psi_decl **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval))->redir = strdup((*(struct psi_token **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval))->text);
- free((*(struct psi_token **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval)));
+ (*(struct psi_decl **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval))->redir = zend_string_copy((*(struct psi_token **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval))->text);
+ psi_token_free(&(*(struct psi_token **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval)));
}
}
#line 5223 "src/parser_proc.c" /* glr.c:817 */
{
(*(struct psi_decl **)(&(*yyvalp))) = (*(struct psi_decl **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval));
if ((*(struct psi_token **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval))) {
- (*(struct psi_decl **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval))->redir = strdup((*(struct psi_token **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval))->text);
- free((*(struct psi_token **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval)));
+ (*(struct psi_decl **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval))->redir = zend_string_copy((*(struct psi_token **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval))->text);
+ psi_token_free(&(*(struct psi_token **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval)));
}
}
#line 5235 "src/parser_proc.c" /* glr.c:817 */
#line 1096 "src/parser_proc_grammar.y" /* glr.c:817 */
{
(*(struct psi_token **)(&(*yyvalp))) = psi_token_cat("", 2, (*(struct psi_token **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval)), (*(struct psi_token **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval)));
- free((*(struct psi_token **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval)));
+ psi_token_free(&(*(struct psi_token **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval)));
}
#line 5268 "src/parser_proc.c" /* glr.c:817 */
break;
struct psi_decl_var *var;
while (psi_plist_get((*(struct psi_plist **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval)), i++, &var)) {
- if (psi_decl_extvar_is_blacklisted(var->name)) {
+ if (psi_decl_extvar_is_blacklisted(var->name->val)) {
psi_decl_var_free(&var);
} else {
struct psi_decl_extvar *evar = psi_decl_extvar_init(
free((*(struct psi_plist **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval)));
}
- if (psi_decl_extvar_is_blacklisted((*(struct psi_decl_arg **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval))->var->name)) {
+ if (psi_decl_extvar_is_blacklisted((*(struct psi_decl_arg **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval))->var->name->val)) {
psi_decl_arg_free(&(*(struct psi_decl_arg **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval)));
} else {
struct psi_decl_extvar *evar = psi_decl_extvar_init((*(struct psi_decl_arg **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval)));
char digest[17];
struct psi_token *name;
- psi_token_hash((*(struct psi_decl **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval))->func ->token, digest);
+ psi_token_hash((*(struct psi_decl **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval))->func->token, digest);
name = psi_token_append("@", psi_token_copy((*(struct psi_decl **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval))->func->token), 2, "funct", digest);
(*(struct psi_decl_arg **)(&(*yyvalp))) = psi_decl_arg_init(
case 499:
#line 1723 "src/parser_proc_grammar.y" /* glr.c:817 */
{
- uint64_t len = (*(struct psi_token **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval))->size + 1;
+ uint64_t len = (*(struct psi_token **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval))->text->len + 1;
(*(struct psi_number **)(&(*yyvalp))) = psi_number_init(PSI_T_UINT64, &len, 0);
}
#line 5965 "src/parser_proc.c" /* glr.c:817 */
case 508:
#line 1787 "src/parser_proc_grammar.y" /* glr.c:817 */
{
- (*(struct psi_layout **)(&(*yyvalp))) = psi_layout_init(0, 0, psi_layout_init(0, atol((*(struct psi_token **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval))->text), NULL));
+ (*(struct psi_layout **)(&(*yyvalp))) = psi_layout_init(0, 0, psi_layout_init(0, atol((*(struct psi_token **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval))->text->val), NULL));
}
#line 6043 "src/parser_proc.c" /* glr.c:817 */
break;
case 509:
#line 1790 "src/parser_proc_grammar.y" /* glr.c:817 */
{
- (*(struct psi_layout **)(&(*yyvalp))) = psi_layout_init(atol((*(struct psi_token **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval))->text), atol((*(struct psi_token **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval))->text), NULL);
+ (*(struct psi_layout **)(&(*yyvalp))) = psi_layout_init(atol((*(struct psi_token **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval))->text->val), atol((*(struct psi_token **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval))->text->val), NULL);
}
#line 6051 "src/parser_proc.c" /* glr.c:817 */
break;
case 510:
#line 1793 "src/parser_proc_grammar.y" /* glr.c:817 */
{
- (*(struct psi_layout **)(&(*yyvalp))) = psi_layout_init(atol((*(struct psi_token **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval))->text), atol((*(struct psi_token **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval))->text), psi_layout_init(0, atol((*(struct psi_token **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (-7)].yystate.yysemantics.yysval))->text), NULL));
+ (*(struct psi_layout **)(&(*yyvalp))) = psi_layout_init(atol((*(struct psi_token **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval))->text->val), atol((*(struct psi_token **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval))->text->val), psi_layout_init(0, atol((*(struct psi_token **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (-7)].yystate.yysemantics.yysval))->text->val), NULL));
}
#line 6059 "src/parser_proc.c" /* glr.c:817 */
break;
case 512:
#line 1803 "src/parser_proc_grammar.y" /* glr.c:817 */
{
- (*(struct psi_layout*)(&(*yyvalp))).pos = atol((*(struct psi_token **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval))->text);
- (*(struct psi_layout*)(&(*yyvalp))).len = atol((*(struct psi_token **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval))->text);
+ (*(struct psi_layout*)(&(*yyvalp))).pos = atol((*(struct psi_token **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval))->text->val);
+ (*(struct psi_layout*)(&(*yyvalp))).len = atol((*(struct psi_token **)(&((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval))->text->val);
}
#line 6077 "src/parser_proc.c" /* glr.c:817 */
break;
return;
}
free(def->type->name);
- def->type->name = strdup(def->var->name);
+ def->type->name = zend_string_copy(def->var->name);
}
static inline void psi_parser_proc_add_typedef(struct psi_parser *P, struct psi_decl_arg *def)
{
static inline void psi_parser_proc_add_decl(struct psi_parser *P, struct psi_decl *decl) {
assert(decl);
- if (psi_decl_is_blacklisted(decl->func->var->name)) {
+ if (psi_decl_is_blacklisted(decl->func->var->name->val)) {
psi_decl_free(&decl);
return;
}
}
}
| lib {
- char *libname = strdup($lib->text);
+ char *libname = strdup($lib->text->val);
P->file.libnames = psi_plist_add(P->file.libnames, &libname);
}
| constant {
}
| ignored_decl {
if (P->flags & PSI_DEBUG) {
- P->error(PSI_DATA(P), $ignored_decl->func->token, PSI_NOTICE, "Ignored decl: %s", $ignored_decl->func->var->name);
+ P->error(PSI_DATA(P), $ignored_decl->func->token, PSI_NOTICE, "Ignored decl: %s", $ignored_decl->func->var->name->val);
}
psi_decl_free(&$ignored_decl);
}
while (psi_plist_get($tokens, index++, &next)) {
struct psi_token *old = msg;
msg = psi_token_cat(" ", 2, msg, next);
- free(old);
+ psi_token_free(&old);
}
}
psi_plist_free($tokens);
| int_signed int_signed_types {
if ($2) {
$type = psi_token_cat(" ", 2, $1, $2);
- free($2);
+ psi_token_free(&$2);
} else {
$type = psi_token_copy($1);
}
| int_width int_width_types {
if ($2) {
$type = psi_token_cat(" ", 2, $1, $2);
- free($1);
- free($2);
+ psi_token_free(&$1);
+ psi_token_free(&$2);
} else {
$type = $1;
}
| int_signed int_signed_types {
if ($2) {
$type = psi_token_cat(" ", 2, $1, $2);
- free($2);
+ psi_token_free(&$2);
} else {
$type = psi_token_copy($1);
}
decl decl_asm EOS {
$decl_stmt = $decl;
if ($decl_asm) {
- $decl->redir = strdup($decl_asm->text);
- free($decl_asm);
+ $decl->redir = zend_string_copy($decl_asm->text);
+ psi_token_free(&$decl_asm);
}
}
| CPP_EXTENSION decl decl_asm EOS {
$decl_stmt = $decl;
if ($decl_asm) {
- $decl->redir = strdup($decl_asm->text);
- free($decl_asm);
+ $decl->redir = zend_string_copy($decl_asm->text);
+ psi_token_free(&$decl_asm);
}
}
;
}
| quoted_strings[strings_] QUOTED_STRING {
$strings = psi_token_cat("", 2, $strings_, $QUOTED_STRING);
- free($strings_);
+ psi_token_free(&$strings_);
}
;
struct psi_decl_var *var;
while (psi_plist_get($vars, i++, &var)) {
- if (psi_decl_extvar_is_blacklisted(var->name)) {
+ if (psi_decl_extvar_is_blacklisted(var->name->val)) {
psi_decl_var_free(&var);
} else {
struct psi_decl_extvar *evar = psi_decl_extvar_init(
free($vars);
}
- if (psi_decl_extvar_is_blacklisted($decl_arg->var->name)) {
+ if (psi_decl_extvar_is_blacklisted($decl_arg->var->name->val)) {
psi_decl_arg_free(&$decl_arg);
} else {
struct psi_decl_extvar *evar = psi_decl_extvar_init($decl_arg);
char digest[17];
struct psi_token *name;
- psi_token_hash($decl->func ->token, digest);
+ psi_token_hash($decl->func->token, digest);
name = psi_token_append("@", psi_token_copy($decl->func->token), 2, "funct", digest);
$arg = psi_decl_arg_init(
$sizeof = psi_number_init(PSI_T_INT8, &sizeof_a, 0);
}
| QUOTED_STRING {
- uint64_t len = $QUOTED_STRING->size + 1;
+ uint64_t len = $QUOTED_STRING->text->len + 1;
$sizeof = psi_number_init(PSI_T_UINT64, &len, 0);
}
;
$l = NULL;
}
| COLON NUMBER[width] {
- $l = psi_layout_init(0, 0, psi_layout_init(0, atol($width->text), NULL));
+ $l = psi_layout_init(0, 0, psi_layout_init(0, atol($width->text->val), NULL));
}
| COLON COLON LPAREN NUMBER[align] COMMA NUMBER[size] RPAREN {
- $l = psi_layout_init(atol($align->text), atol($size->text), NULL);
+ $l = psi_layout_init(atol($align->text->val), atol($size->text->val), NULL);
}
| COLON NUMBER[width] COLON COLON LPAREN NUMBER[align] COMMA NUMBER[size] RPAREN {
- $l = psi_layout_init(atol($align->text), atol($size->text), psi_layout_init(0, atol($width->text), NULL));
+ $l = psi_layout_init(atol($align->text->val), atol($size->text->val), psi_layout_init(0, atol($width->text->val), NULL));
}
;
$as.len = 0;
}
| COLON COLON LPAREN NUMBER[align] COMMA NUMBER[size] RPAREN {
- $as.pos = atol($align->text);
- $as.len = atol($size->text);
+ $as.pos = atol($align->text->val);
+ $as.len = atol($size->text->val);
}
;
memcpy(dest, src, list->size); \
} \
} while (0)
+#define PLIST_CPY_R(list, dest, src, num) memcpy((dest), (src), (num) * (list)->size)
/* !!! adjust list->count prior reduction */
#define PLIST_MOV_REDUCE(l, i) PLIST_MOV_REDUCE_EX(l, i, 1)
#define PLIST_MOV_REDUCE_EX(l, i, n) memmove(PLIST_ELE(l, i), PLIST_ELE(l, (i) + (n)), (l)->size * ((l)->count - (i)))
size_t e;
PLIST_MOV_EXPAND_EX(list, offset_start, num_eles);
- for (e = 0; e < num_eles; ++e) {
- PLIST_CPY(list, PLIST_ELE(list, offset_start + e), &eles[e]);
- }
+ PLIST_CPY_R(list, PLIST_ELE(list, offset_start), eles, num_eles);
list->count = new_count;
}
}
#include <ctype.h>
+#include <Zend/zend_smart_str.h>
+
#include "token.h"
#include "parser.h"
}
struct psi_token *psi_token_init(token_t token_typ, const char *token_txt,
- size_t token_len, unsigned col, unsigned line, const char *file)
+ size_t token_len, unsigned col, unsigned line, zend_string *file)
{
struct psi_token *T;
- size_t file_len = strlen(file);
- T = calloc(1, psi_token_alloc_size(token_len, file_len));
+ T = calloc(1, sizeof(*T));
T->type = token_typ;
- T->size = token_len;
- T->text = &T->buf[0];
- T->file = &T->buf[token_len + 1];
- T->line = line;
T->col = col;
-
- memcpy(T->text, token_txt, token_len);
- memcpy(T->file, file, file_len);
+ T->line = line;
+ T->file = zend_string_copy(file);
+ T->text = zend_string_init(token_txt, token_len, 1);
return T;
}
struct psi_token *token = *token_ptr;
*token_ptr = NULL;
+ zend_string_release(token->text);
+ zend_string_release(token->file);
free(token);
}
}
struct psi_token *psi_token_copy(struct psi_token *src) {
- size_t strct_len = psi_token_alloc_size(src->size, strlen(src->file));
- struct psi_token *ptr = malloc(strct_len);
+ struct psi_token *ptr = malloc(sizeof(*ptr));
- memcpy(ptr, src, strct_len);
+ *ptr = *src;
- ptr->text = &ptr->buf[0];
- ptr->file = &ptr->buf[ptr->size + 1];
+ ptr->text = zend_string_copy(ptr->text);
+ ptr->file = zend_string_copy(ptr->file);
return ptr;
}
*tok = psi_token_copy(*tok);
}
+/* concatenate `argc` number of tokens separated by `sep` into a newly allocated token */
struct psi_token *psi_token_cat(const char *sep, unsigned argc, ...) {
va_list argv;
unsigned i;
size_t sep_len = sep ? strlen(sep) : 0;
- struct psi_token *T = NULL;
+ struct psi_token *T = malloc(sizeof(*T));
+ smart_str text = {0};
va_start(argv, argc);
- for (i = 0; i < argc; ++i) {
- struct psi_token *arg = va_arg(argv, struct psi_token *);
- if (T) {
- size_t token_len = T->size, fname_len = strlen(T->file);
- struct psi_token *tmp = realloc(T, psi_token_alloc_size(T->size += arg->size + sep_len, fname_len));
+ *T = *(struct psi_token *) va_arg(argv, struct psi_token *);
+ T->type = PSI_T_NAME;
+ T->file = zend_string_copy(T->file);
- if (tmp) {
- T = tmp;
- } else {
- free(T);
- va_end(argv);
- return NULL;
- }
+ for (i = 0; i < argc; ++i) {
+ struct psi_token *arg = va_arg(argv, struct psi_token *);
- T->text = &T->buf[0];
- T->file = &T->buf[T->size + 1];
- memmove(&T->buf[T->size + 1], &T->buf[token_len + 1], fname_len + 1);
- memcpy(&T->buf[token_len], sep, sep_len);
- memcpy(&T->buf[token_len + sep_len], arg->text, arg->size + 1);
- } else {
- T = psi_token_copy(arg);
- T->type = PSI_T_NAME;
+ if (sep_len && text.a) {
+ smart_str_appendl_ex(&text, sep, sep_len, 1);
}
+
+ smart_str_append_ex(&text, arg->text, 1);
}
va_end(argv);
+ T->text = smart_str_extract(&text);
+
return T;
}
-struct psi_token *psi_token_prepend(const char *sep, struct psi_token *T, unsigned argc, ...) {
+/* append `argc` number of C strings separated by `sep` to token `T` */
+struct psi_token *psi_token_append(const char *sep, struct psi_token *T, unsigned argc, ...) {
va_list argv;
unsigned i;
size_t sep_len = sep ? strlen(sep) : 0;
+ smart_str text = {0};
+
+ smart_str_append_ex(&text, T->text, 1);
va_start(argv, argc);
for (i = 0; i < argc; ++i) {
char *str = va_arg(argv, char *);
- size_t str_len = strlen(str), token_len = T->size, fname_len = strlen(T->file);
-
- T = realloc(T, psi_token_alloc_size(T->size += str_len + sep_len, fname_len));
- T->text = &T->buf[0];
- T->file = &T->buf[T->size + 1];
- memmove(&T->buf[str_len + sep_len], &T->buf[0], token_len + 1 + fname_len + 1);
- memcpy(&T->buf[0], str, str_len);
- memcpy(&T->buf[str_len], sep, sep_len);
- T->buf[T->size] = '\0';
- }
- va_end(argv);
+ size_t str_len = strlen(str);
- return T;
-}
-struct psi_token *psi_token_append(const char *sep, struct psi_token *T, unsigned argc, ...) {
- va_list argv;
- unsigned i;
- size_t sep_len = sep ? strlen(sep) : 0;
+ if (sep_len && text.a) {
+ smart_str_appendl_ex(&text, sep, sep_len, 1);
+ }
- va_start(argv, argc);
- for (i = 0; i < argc; ++i) {
- char *str = va_arg(argv, char *);
- size_t str_len = strlen(str), token_len = T->size, fname_len = strlen(T->file);
-
- T = realloc(T, psi_token_alloc_size(T->size += str_len + sep_len, fname_len));
- T->text = &T->buf[0];
- T->file = &T->buf[T->size + 1];
- memmove(&T->buf[T->size + 1], &T->buf[token_len + 1], fname_len + 1);
- memcpy(&T->buf[token_len], sep, sep_len);
- memcpy(&T->buf[token_len + sep_len], str, str_len + 1);
+ smart_str_appendl_ex(&text, str, str_len, 1);
}
va_end(argv);
+ zend_string_release(T->text);
+ T->text = smart_str_extract(&text);
+
return T;
}
char *php_strtr(char *str, size_t len, char *str_from, char *str_to, size_t trlen);
struct psi_token *psi_token_translit(struct psi_token *T, char *from, char *to) {
- php_strtr(T->text, T->size, from, to, MIN(strlen(from), strlen(to)));
+ zend_string *tmp = zend_string_init(T->text->val, T->text->len, 1);
+
+ zend_string_release(T->text);
+ T->text = tmp;
+
+ php_strtr(T->text->val, T->text->len, from, to, MIN(strlen(from), strlen(to)));
+ zend_string_forget_hash_val(T->text);
+
return T;
}
uint64_t psi_token_hash(struct psi_token *t, char *digest_buf) {
char loc_buf[48];
- sprintf(loc_buf, "%u%u", t->line, t->col);
- return psi_hash(digest_buf, t->file, loc_buf, (char *) NULL);
+ sprintf(digest_buf, "%u%u", t->line, t->col);
+ return psi_hash(digest_buf, t->file->val, loc_buf, (char *) NULL);
}
void psi_token_dump(int fd, struct psi_token *t)
dprintf(fd, "EOF");
} else {
dprintf(fd, "\"");
- for (i = 0; i < t->size; ++i) {
- switch (t->text[i]) {
+ for (i = 0; i < t->text->len; ++i) {
+ switch (t->text->val[i]) {
case '\0':
dprintf(fd, "\\0");
break;
dprintf(fd, "\\\"");
break;
default:
- if (isprint(t->text[i])) {
- dprintf(fd, "%c", t->text[i]);
+ if (isprint(t->text->val[i])) {
+ dprintf(fd, "%c", t->text->val[i]);
} else {
- dprintf(fd, "\\x%02hhX", t->text[i]);
+ dprintf(fd, "\\x%02hhX", t->text->val[i]);
}
break;
}
}
dprintf(fd, "\"");
}
- dprintf(fd, " at col %u in %s on line %u\n", t->col, t->file, t->line);
+ dprintf(fd, " at col %u in %s on line %u\n", t->col, t->file->val, t->line);
}
struct psi_token {
token_t type;
- unsigned size, line, col, flags;
- char *text, *file;
- char buf[1];
+ unsigned line;
+ unsigned col;
+ unsigned flags;
+ zend_string *file;
+ zend_string *text;
};
struct psi_parser;
struct psi_token *psi_token_init(token_t token_typ, const char *token_txt,
- size_t token_len, unsigned col, unsigned line, const char *file);
-size_t psi_token_alloc_size(size_t token_len, size_t fname_len);
+ size_t token_len, unsigned col, unsigned line, zend_string *file);
struct psi_token *psi_token_copy(struct psi_token *src);
void psi_token_copy_ctor(struct psi_token **src);
struct psi_token *psi_token_cat(const char *sep, unsigned argc, ...);
-struct psi_token *psi_token_prepend(const char *sep, struct psi_token *T, unsigned argc, ...);
struct psi_token *psi_token_append(const char *sep, struct psi_token *T, unsigned argc, ...);
struct psi_token *psi_token_translit(struct psi_token *T, char *from, char *to);
uint64_t psi_token_hash(struct psi_token *t, char *digest_buf);
ZEND_ASSERT(!var->arg || var->arg->var != var);
#if 0
fprintf(stderr, "deref: %s pl=%u:%u as=%u:%u %p\n",
- var->name, var->pointer_level, var->arg->var->pointer_level,
+ var->name->val, var->pointer_level, var->arg->var->pointer_level,
var->array_size, var->arg->var->array_size, ret_val);
#endif
for (i = 0; i < var->pointer_level; ++i) {
ZEND_ASSERT(var->arg->var == var);
#if 0
fprintf(stderr, "enref: %s pl=%u:%u as=%u:%u\n",
- var->name, var->pointer_level, var->arg->var->pointer_level,
+ var->name->val, var->pointer_level, var->arg->var->pointer_level,
var->array_size, var->arg->var->array_size);
#endif
if (!var->pointer_level ){//&& real_decl_type(var->arg->type)->type != PSI_T_STRUCT) {
static inline impl_val *struct_member_ref(struct psi_decl_arg *set_arg, impl_val *struct_ptr, impl_val **to_free) {
void *ptr = (char *) struct_ptr + set_arg->layout->pos;
#if 0
- fprintf(stderr, "struct member %s: %p\n", set_arg->var->name, ptr);
+ fprintf(stderr, "struct member %s: %p\n", set_arg->var->name->val, ptr);
#endif
return ptr;
}
if (*stmt_ptr) {
struct psi_assert_stmt *stmt = *stmt_ptr;
+ *stmt_ptr = NULL;
psi_num_exp_free(&stmt->exp);
- if (stmt->token) {
- free(stmt->token);
- }
+ psi_token_free(&stmt->token);
free(stmt);
- *stmt_ptr = NULL;
}
}
#include "php_psi_stdinc.h"
#include "data.h"
-struct psi_const *psi_const_init(struct psi_impl_type *type, const char *name,
+struct psi_const *psi_const_init(struct psi_impl_type *type, zend_string *name,
struct psi_impl_def_val *val)
{
struct psi_const *c = calloc(1, sizeof(*c));
+
+ if (name->val[0] == '\\') {
+ c->name = zend_string_init(&name->val[1], name->len-1, 1);
+ } else {
+ c->name = zend_string_copy(name);
+ }
c->type = type;
- c->name = strdup(name[0] == '\\' ? &name[1] : name);
c->val = val;
return c;
}
struct psi_const *constant = *constant_ptr;
*constant_ptr = NULL;
- if (constant->token) {
- free(constant->token);
- }
+ psi_token_free(&constant->token);
psi_impl_type_free(&constant->type);
- free(constant->name);
+ zend_string_release(constant->name);
psi_impl_def_val_free(&constant->val);
free(constant);
}
{
dprintf(fd, "const ");
psi_impl_type_dump(fd, cnst->type);
- dprintf(fd, " %s = ", cnst->name);
+ dprintf(fd, " %s = ", cnst->name->val);
psi_impl_def_val_dump(fd, cnst->val);
dprintf(fd, ";");
}
struct psi_const {
struct psi_token *token;
struct psi_impl_type *type;
- char *name;
+ zend_string *name;
struct psi_impl_def_val *val;
};
-struct psi_const *psi_const_init(struct psi_impl_type *type, const char *name,
+struct psi_const *psi_const_init(struct psi_impl_type *type, zend_string *name,
struct psi_impl_def_val *val);
void psi_const_free(struct psi_const **constant_ptr);
void psi_const_dump(int fd, struct psi_const *cnst);
case PSI_T_IMPORT:
case PSI_T_INCLUDE:
case PSI_T_INCLUDE_NEXT:
- free(exp->data.tok);
- exp->data.tok = NULL;
+ psi_token_free(&exp->data.tok);
break;
case PSI_T_DEFINE:
psi_cpp_macro_decl_free(&exp->data.decl);
assert(0);
break;
}
- if (exp->token) {
- free(exp->token);
- }
+ psi_token_free(&exp->token);
free(exp);
}
}
void psi_cpp_exp_dump(int fd, struct psi_cpp_exp *exp)
{
- dprintf(fd, "#%s ", exp->token->text);
+ dprintf(fd, "#%s ", exp->token->text->val);
switch (exp->type) {
case PSI_T_WARNING:
case PSI_T_ERROR:
case PSI_T_UNDEF:
case PSI_T_IFDEF:
case PSI_T_IFNDEF:
- dprintf(fd, "%s", exp->data.tok->text);
+ dprintf(fd, "%s", exp->data.tok->text->val);
break;
case PSI_T_IMPORT:
case PSI_T_INCLUDE:
case PSI_T_INCLUDE_NEXT:
if (exp->data.tok->type == PSI_T_CPP_HEADER) {
- dprintf(fd, "<%s>", exp->data.tok->text);
+ dprintf(fd, "<%s>", exp->data.tok->text->val);
} else {
- dprintf(fd, "\"%s\"", exp->data.tok->text);
+ dprintf(fd, "\"%s\"", exp->data.tok->text->val);
}
break;
case PSI_T_DEFINE:
void psi_cpp_exp_exec(struct psi_cpp_exp *exp, struct psi_cpp *cpp, struct psi_data *D)
{
PSI_DEBUG_PRINT(D, "PSI: CPP EVAL < %s (level=%u, skip=%u)\n",
- exp->token->text, cpp->level, cpp->skip);
+ exp->token->text->val, cpp->level, cpp->skip);
#if PSI_CPP_DEBUG
psi_cpp_exp_dump(2, exp);
case PSI_T_ERROR:
if (!cpp->skip) {
D->error(D, exp->token, PSI_ERROR, "%s",
- exp->data.tok ? exp->data.tok->text : "");
+ exp->data.tok ? exp->data.tok->text->val : "");
}
break;
case PSI_T_WARNING:
if (!cpp->skip) {
D->error(D, exp->token, PSI_WARNING, "%s",
- exp->data.tok ? exp->data.tok->text : "");
+ exp->data.tok ? exp->data.tok->text->val : "");
}
break;
case PSI_T_UNDEF:
case PSI_T_INCLUDE:
if (!cpp->skip) {
if (!psi_cpp_include(cpp, exp->data.tok, PSI_CPP_INCLUDE)) {
- D->error(D, exp->token, PSI_WARNING, "Failed to include %s", exp->data.tok->text);
+ D->error(D, exp->token, PSI_WARNING, "Failed to include %s", exp->data.tok->text->val);
}
}
break;
case PSI_T_INCLUDE_NEXT:
if (!cpp->skip) {
if (!psi_cpp_include(cpp, exp->data.tok, PSI_CPP_INCLUDE_NEXT)) {
- D->error(D, exp->token, PSI_WARNING, "Failed to include %s", exp->data.tok->text);
+ D->error(D, exp->token, PSI_WARNING, "Failed to include %s", exp->data.tok->text->val);
}
}
break;
case PSI_T_IMPORT:
if (!cpp->skip) {
if (!psi_cpp_include(cpp, exp->data.tok, PSI_CPP_INCLUDE_ONCE)) {
- D->error(D, exp->token, PSI_WARNING, "Failed to include %s", exp->data.tok->text);
+ D->error(D, exp->token, PSI_WARNING, "Failed to include %s", exp->data.tok->text->val);
}
}
break;
case PSI_T_PRAGMA_ONCE:
if (!cpp->skip) {
- zend_hash_str_add_empty_element(&cpp->once, exp->token->file, strlen(exp->token->file));
+ zend_hash_add_empty_element(&cpp->once, exp->token->file);
}
break;
default:
}
PSI_DEBUG_PRINT(D, "PSI: CPP EVAL > %s (level=%u, skip=%u)\n",
- exp->token->text, cpp->level, cpp->skip);
+ exp->token->text->val, cpp->level, cpp->skip);
}
#include "cpp.h"
#include "data.h"
-struct psi_cpp_macro_call *psi_cpp_macro_call_init(const char *name,
+struct psi_cpp_macro_call *psi_cpp_macro_call_init(zend_string *name,
struct psi_plist *args)
{
struct psi_cpp_macro_call *call = calloc(1, sizeof(*call));
- call->name = strdup(name);
+ call->name = zend_string_copy(name);
call->args = args;
return call;
}
struct psi_cpp_macro_call *call)
{
struct psi_cpp_macro_call *copy = calloc(1, sizeof(*copy));
- copy->name = strdup(call->name);
+ copy->name = zend_string_copy(call->name);
if (call->token) {
copy->token = psi_token_copy(call->token);
}
*call_ptr = NULL;
- free(call->name);
+ zend_string_release(call->name);
if (call->args) {
psi_plist_free(call->args);
}
- if (call->token) {
- free(call->token);
- }
+ psi_token_free(&call->token);
free(call);
}
}
size_t i = 0;
struct psi_num_exp *num;
- dprintf(fd, "%s(", call->name);
+ dprintf(fd, "%s(", call->name->val);
while (psi_plist_get(call->args, i++, &num)) {
if (i > 1) {
dprintf(fd, ", ");
struct psi_cpp_macro_call {
struct psi_token *token;
- char *name;
+ zend_string *name;
struct psi_plist *args;
};
-struct psi_cpp_macro_call *psi_cpp_macro_call_init(const char *name,
+struct psi_cpp_macro_call *psi_cpp_macro_call_init(zend_string *name,
struct psi_plist *args);
struct psi_cpp_macro_call *psi_cpp_macro_call_copy(
struct psi_cpp_macro_call *call);
struct psi_cpp_macro_decl *macro = *macro_ptr;
*macro_ptr = NULL;
- if (macro->token) {
- free(macro->token);
- }
+ psi_token_free(¯o->token);
if (macro->exp) {
psi_num_exp_free(¯o->exp);
}
void psi_cpp_macro_decl_dump(int fd, struct psi_cpp_macro_decl *macro)
{
- dprintf(fd, "%s", macro->token->text);
+ dprintf(fd, "%s", macro->token->text->val);
if (macro->sig) {
size_t i = 0;
dprintf(fd, "(");
while (psi_plist_get(macro->sig, i++, &tok)) {
- dprintf(fd, "%s%s", i>1?",":"", tok->text);
+ dprintf(fd, "%s%s", i>1?",":"", tok->text->val);
}
dprintf(fd, ")");
}
if (macro->exp) {
dprintf(fd, " ");
psi_num_exp_dump(fd, macro->exp);
- if (!macro->tokens) abort();
- } else
- if (macro->tokens) {
+
+ assert(macro->tokens);
+
+ } else if (macro->tokens) {
size_t i = 0;
struct psi_token *tok;
while (psi_plist_get(macro->tokens, i++, &tok)) {
switch (tok->type) {
case PSI_T_QUOTED_STRING:
- dprintf(fd, " \"%s\"", tok->text);
+ dprintf(fd, " \"%s\"", tok->text->val);
break;
case PSI_T_QUOTED_CHAR:
- dprintf(fd, " '%s'", tok->text);
+ dprintf(fd, " '%s'", tok->text->val);
break;
default:
- dprintf(fd, " %s", tok->text);
+ dprintf(fd, " %s", tok->text->val);
}
}
}
psi_plist_get(l1, i, &t1);
psi_plist_get(l2, i, &t2);
- if (strcmp(t1->text, t2->text)) {
+ if (!zend_string_equals(t1->text, t2->text)) {
return false;
}
}
*******************************************************************************/
#include "php_psi_stdinc.h"
-
#include "php_psi.h"
#include <dlfcn.h>
#include <fnmatch.h>
+#include <Zend/zend_smart_str.h>
+
#include "data.h"
#define PSI_FUNC_REDIRS
psi_plist_free(d->args);
}
if (d->redir) {
- free(d->redir);
+ zend_string_release(d->redir);
}
free(d);
}
dprintf(fd, ")[%u]", decl->func->var->array_size);
}
if (decl->redir) {
- dprintf(fd, ") __asm__ (\"%s\");", decl->redir);
+ dprintf(fd, ") __asm__ (\"%s\");", decl->redir->val);
} else {
dprintf(fd, ");");
}
}
for (redir = &psi_func_redirs[0]; redir->name; ++redir) {
- if (!strcmp(func->var->name, redir->name)) {
+ if (!strcmp(func->var->name->val, redir->name)) {
decl->sym = redir->func;
}
}
void *dl;
while (!decl->sym && psi_plist_get(data->file.dlopened, i++, &dl)) {
- decl->sym = dlsym(dl, decl->redir ?: func->var->name);
+ decl->sym = dlsym(dl, decl->redir ? decl->redir->val : func->var->name->val);
}
}
if (!decl->sym) {
#ifndef RTLD_DEFAULT
# define RTLD_DEFAULT ((void *) 0)
#endif
- decl->sym = dlsym(RTLD_DEFAULT, decl->redir ?: func->var->name);
+ decl->sym = dlsym(RTLD_DEFAULT, decl->redir ? decl->redir->val : func->var->name->val);
if (!decl->sym) {
data->error(data, func->token, PSI_WARNING,
"Failed to locate symbol '%s(%s)': %s",
- func->var->name, decl->redir ?: "",
+ func->var->name->val,
+ decl->redir ? decl->redir->val : "",
dlerror() ?: "not found");
return false;
}
struct psi_validate_scope *scope)
{
if (!decl->abi) {
- decl->abi = psi_decl_abi_init("default");
+ decl->abi = psi_decl_abi_init(zend_string_init(ZEND_STRL("default"), 1));
} else if (!psi_decl_abi_validate(data, decl->abi)) {
data->error(data, decl->abi->token, PSI_WARNING,
- "Invalid calling convention: '%s'", decl->abi->token->text);
+ "Invalid calling convention: '%s'", decl->abi->token->text->val);
return false;
}
if (!psi_decl_arg_validate(data, decl->func, scope)) {
while (psi_plist_get(decl->args, i++, &arg)) {
if (!arg->var->name) {
- arg->var->name = malloc(7);
- snprintf(arg->var->name, 6, "arg%zu", i);
- arg->var->fqn = strdup(arg->var->name);
+ smart_str name = {0};
+
+ smart_str_appendl_ex(&name, ZEND_STRL("arg"), 1);
+ smart_str_append_unsigned_ex(&name, i, 1);
+
+ arg->var->name = smart_str_extract(&name);
+ arg->var->fqn = zend_string_copy(arg->var->name);
}
if (!psi_decl_arg_validate(data, arg, scope)) {
return false;
struct psi_decl_abi *abi;
struct psi_decl_arg *func;
struct psi_plist *args;
- char *redir;
+ zend_string *redir;
void *sym;
void *info;
unsigned varargs:1;
#include "php_psi_stdinc.h"
#include "data.h"
-struct psi_decl_abi *psi_decl_abi_init(const char *convention)
+struct psi_decl_abi *psi_decl_abi_init(zend_string *convention)
{
struct psi_decl_abi *abi = calloc(1, sizeof(*abi));
- abi->convention = strdup(convention);
+ abi->convention = zend_string_copy(convention);
return abi;
}
struct psi_decl_abi *abi = *abi_ptr;
*abi_ptr = NULL;
- if (abi->token) {
- free(abi->token);
- }
- free(abi->convention);
+ psi_token_free(&abi->token);
+ zend_string_release(abi->convention);
free(abi);
}
}
void psi_decl_abi_dump(int fd, struct psi_decl_abi *abi)
{
- dprintf(fd, "%s", abi->convention);
+ dprintf(fd, "%s", abi->convention->val);
}
static const char * const abi_ccs[] = {
size_t i;
for (i = 0; i < sizeof(abi_ccs) / sizeof(char *); ++i) {
- if (strcasecmp(abi->convention, abi_ccs[i])) {
+ if (!strcasecmp(abi->convention->val, abi_ccs[i])) {
return true;
}
}
struct psi_decl_abi {
struct psi_token *token;
- char *convention;
+ zend_string *convention;
};
-struct psi_decl_abi *psi_decl_abi_init(const char *convention);
+struct psi_decl_abi *psi_decl_abi_init(zend_string *convention);
void psi_decl_abi_free(struct psi_decl_abi **abi_ptr);
void psi_decl_abi_dump(int fd, struct psi_decl_abi *abi);
bool psi_decl_abi_validate(struct psi_data *data, struct psi_decl_abi *abi);
*arg_ptr = NULL;
if (arg->token && arg->token != arg->var->token) {
- free(arg->token);
+ psi_token_free(&arg->token);
}
psi_decl_type_free(&arg->type);
psi_decl_var_free(&arg->var);
}
dprintf(fd, " %s(*%s)",
psi_t_indirection(arg->var->pointer_level - !! arg->var->array_size),
- arg->var->name);
+ arg->var->name->val);
dprintf(fd, "(");
if (arg->type->real.func->args) {
size_t j = 0;
def->type->type = PSI_T_POINTER;
} else {
data->error(data, def->token, PSI_WARNING,
- "Type '%s' cannot be aliased to 'void'", def->type->name);
+ "Type '%s' cannot be aliased to 'void'", def->type->name->val);
return false;
}
} else if (!psi_decl_type_validate(data, def->type, def, scope)) {
}
data->error(data, def->token, PSI_WARNING,
"Type '%s' cannot be aliased to '%s%s'%s%s", def->var->name, pre,
- def->type->name, *data->last_error ? ": " : "", data->last_error);
+ def->type->name->val, *data->last_error ? ": " : "", data->last_error);
return false;
}
}
struct psi_decl_arg *psi_decl_arg_get_by_name(struct psi_plist *args,
- const char *name)
+ zend_string *name)
{
size_t i = 0;
struct psi_decl_arg *arg;
if (args)
while (psi_plist_get(args, i++, &arg)) {
- if (!strcmp(name, arg->var->name)) {
+ if (zend_string_equals(name, arg->var->name)) {
return arg;
}
}
return var->arg = arg;
}
- if (func && !strcmp(var->name, func->var->name)) {
+ if (func && !zend_string_equals(var->name, func->var->name)) {
return var->arg = func;
}
size_t psi_decl_arg_get_align(struct psi_decl_arg *darg);
size_t psi_decl_arg_get_size(struct psi_decl_arg *darg);
-struct psi_decl_arg *psi_decl_arg_get_by_name(struct psi_plist *args, const char *name);
+struct psi_decl_arg *psi_decl_arg_get_by_name(struct psi_plist *args, zend_string *name);
struct psi_decl_arg *psi_decl_arg_get_by_var(struct psi_decl_var *var, struct psi_plist *args, struct psi_decl_arg *func);
#include "php_psi_stdinc.h"
#include "data.h"
-struct psi_decl_enum *psi_decl_enum_init(const char *name, struct psi_plist *l)
+struct psi_decl_enum *psi_decl_enum_init(zend_string *name, struct psi_plist *l)
{
struct psi_decl_enum *e = calloc(1, sizeof(*e));
- e->name = strdup(name);
+ e->name = zend_string_copy(name);
e->items = l;
return e;
}
struct psi_decl_enum *e = *e_ptr;
*e_ptr = NULL;
- if (e->token) {
- free(e->token);
- }
+ psi_token_free(&e->token);
if (e->items) {
psi_plist_free(e->items);
}
- free(e->name);
+ zend_string_release(e->name);
free(e);
}
}
void psi_decl_enum_dump(int fd, struct psi_decl_enum *e, unsigned level)
{
- dprintf(fd, "enum %s {\n", e->name);
+ dprintf(fd, "enum %s {\n", e->name->val);
if (e->items) {
size_t i = 0;
struct psi_decl_enum_item *item;
struct psi_decl_enum_item *i, *p = NULL;
if (!psi_plist_count(e->items)) {
- data->error(data, e->token, PSI_WARNING, "Empty enum '%s'", e->name);
+ data->error(data, e->token, PSI_WARNING, "Empty enum '%s'", e->name->val);
return false;
}
struct psi_decl_enum {
struct psi_token *token;
- char *name;
+ zend_string *name;
struct psi_plist *items;
};
-struct psi_decl_enum *psi_decl_enum_init(const char *name, struct psi_plist *l);
+struct psi_decl_enum *psi_decl_enum_init(zend_string *name, struct psi_plist *l);
void psi_decl_enum_free(struct psi_decl_enum **e_ptr);
void psi_decl_enum_dump(int fd, struct psi_decl_enum *e, unsigned level);
bool psi_decl_enum_validate(struct psi_data *data, struct psi_decl_enum *e);
#include "php_psi_stdinc.h"
#include "data.h"
-struct psi_decl_enum_item *psi_decl_enum_item_init(const char *name,
+struct psi_decl_enum_item *psi_decl_enum_item_init(zend_string *name,
struct psi_num_exp *num)
{
struct psi_decl_enum_item *i = calloc(1, sizeof(*i));
- i->name = strdup(name);
+ i->name = zend_string_copy(name);
i->num = num;
return i;
}
struct psi_decl_enum_item *i = *i_ptr;
*i_ptr = NULL;
- if (i->token) {
- free(i->token);
- }
+ psi_token_free(&i->token);
if (i->num) {
if (i->num == &i->inc) {
switch (i->inc.op) {
psi_num_exp_free(&i->num);
}
}
- free(i->name);
+ zend_string_release(i->name);
free(i);
}
}
void psi_decl_enum_item_dump(int fd, struct psi_decl_enum_item *item)
{
- dprintf(fd, "%s", item->name);
+ dprintf(fd, "%s", item->name->val);
if (item->num && item->num != &item->inc) {
dprintf(fd, " = ");
psi_num_exp_dump(fd, item->num);
struct psi_decl_enum_item {
struct psi_token *token;
- char *name;
+ zend_string *name;
int64_t val;
struct psi_num_exp inc;
struct psi_num_exp *num;
struct psi_decl_enum_item *prev;
};
-struct psi_decl_enum_item *psi_decl_enum_item_init(const char *name, struct psi_num_exp *num);
+struct psi_decl_enum_item *psi_decl_enum_item_init(zend_string *name, struct psi_num_exp *num);
void psi_decl_enum_item_free(struct psi_decl_enum_item **i_ptr);
void psi_decl_enum_item_dump(int fd, struct psi_decl_enum_item *item);
bool psi_decl_enum_item_validate(struct psi_data *data, struct psi_decl_enum *enm, struct psi_decl_enum_item *item, size_t seq);
#include <dlfcn.h>
#include <fnmatch.h>
+#include <Zend/zend_smart_str.h>
+
#include "data.h"
struct psi_decl_extvar *psi_decl_extvar_init(struct psi_decl_arg *arg)
struct psi_decl_extvar *evar = *evar_ptr;
*evar_ptr = NULL;
- if (evar->token) {
- free(evar->token);
- }
+ psi_token_free(&evar->token);
psi_decl_arg_free(&evar->arg);
psi_decl_free(&evar->getter);
psi_decl_free(&evar->setter);
evar->size = psi_decl_arg_get_size(evar->arg);
if (!evar->size) {
data->error(data, evar->arg->var->token, PSI_WARNING,
- "Failed to calculate size of symbol '%s'", evar->arg->var->name);
+ "Failed to calculate size of symbol '%s'", evar->arg->var->name->val);
return false;
}
void *dl;
while (!evar->sym && psi_plist_get(data->file.dlopened, i++, &dl)) {
- evar->sym = dlsym(dl, evar->arg->var->name);
+ evar->sym = dlsym(dl, evar->arg->var->name->val);
}
}
if (!evar->sym) {
#ifndef RTLD_DEFAULT
# define RTLD_DEFAULT ((void *) 0)
#endif
- evar->sym = dlsym(RTLD_DEFAULT, evar->arg->var->name);
+ evar->sym = dlsym(RTLD_DEFAULT, evar->arg->var->name->val);
if (!evar->sym) {
data->error(data, evar->arg->var->token, PSI_WARNING,
- "Failed to locate symbol '%s': %s", evar->arg->var->name,
+ "Failed to locate symbol '%s': %s", evar->arg->var->name->val,
dlerror() ?: "not found");
return false;
}
struct psi_decl *psi_decl_extvar_setter(struct psi_decl_extvar *evar)
{
- struct psi_decl_type *func_type = psi_decl_type_init(PSI_T_VOID, "void");
+ struct psi_decl_type *func_type = psi_decl_type_init(PSI_T_VOID,
+ zend_string_init(ZEND_STRS("void"), 1));
struct psi_decl_var *func_var = psi_decl_var_copy(evar->arg->var);
struct psi_decl_arg *func = psi_decl_arg_init(func_type, func_var);
struct psi_decl_type *arg_type = psi_decl_type_copy(evar->arg->type);
struct psi_decl_arg *arg = psi_decl_arg_init(arg_type, arg_var);
struct psi_plist *args = psi_plist_init((psi_plist_dtor) psi_decl_arg_free);
struct psi_decl *decl = psi_decl_init(func, psi_plist_add(args, &arg));
+ smart_str name = {0};
func_var->pointer_level = 0;
func_var->array_size = 0;
- func_var->name = realloc(func_var->name, strlen(evar->arg->var->name) + sizeof("_set"));
- strcat(func_var->name, "_set");
+
+ smart_str_append_ex(&name, func_var->name, 1);
+ smart_str_appendl_ex(&name, ZEND_STRL("_set"), 1);
+ zend_string_release(func_var->name);
+ func_var->name = smart_str_extract(&name);
decl->extvar = 1;
struct psi_decl_var *func_var = psi_decl_var_copy(evar->arg->var);
struct psi_decl_arg *func = psi_decl_arg_init(func_type, func_var);
struct psi_decl *decl = psi_decl_init(func, NULL);
+ smart_str name = {0};
- func_var->name = realloc(func_var->name, strlen(evar->arg->var->name) + sizeof("_get"));
- strcat(func_var->name, "_get");
+ smart_str_append_ex(&name, func_var->name, 1);
+ smart_str_appendl_ex(&name, ZEND_STRL("_set"), 1);
+ zend_string_release(func_var->name);
+ func_var->name = smart_str_extract(&name);
decl->extvar = 1;
psi_plist_free(file->dlopened);
}
if (file->filename) {
- free(file->filename);
+ zend_string_release(file->filename);
}
memset(file, 0, sizeof(*file));
}
}
if (src->file.filename) {
- dst->file.filename = strdup(src->file.filename);
+ dst->file.filename = zend_string_copy(src->file.filename);
}
return true;
}
struct psi_data;
struct psi_decl_file {
- char *filename;
+ zend_string *filename;
struct psi_plist *libnames;
struct psi_plist *dlopened;
};
#include <assert.h>
-struct psi_decl_struct* psi_decl_struct_init(const char *name,
+struct psi_decl_struct* psi_decl_struct_init(zend_string *name,
struct psi_plist *args)
{
struct psi_decl_struct *s = calloc(1, sizeof(*s));
- s->name = strdup(name);
+ s->name = zend_string_copy(name);
s->args = args;
return s;
}
struct psi_decl_struct *s = *s_ptr;
*s_ptr = NULL;
- if (s->token) {
- free(s->token);
- }
+ psi_token_free(&s->token);
if (s->args) {
psi_plist_free(s->args);
}
if (s->engine.type && s->engine.dtor) {
s->engine.dtor(s->engine.type);
}
- free(s->name);
+ zend_string_release(s->name);
free(s);
}
}
void psi_decl_struct_dump(int fd, struct psi_decl_struct *strct)
{
- dprintf(fd, "struct %s::(%zu, %zu)", strct->name, strct->align,
+ dprintf(fd, "struct %s::(%zu, %zu)", strct->name->val, strct->align,
strct->size);
if (psi_plist_count(strct->args)) {
psi_decl_type_dump_args_with_layout(fd, strct->args, 0);
if (!align) {
data->error(data, darg->token, PSI_WARNING,
"Computed zero alignment of %s.%s of type '%s'",
- len, s->name, darg->var->name, darg->type->name);
+ len, s->name->val, darg->var->name->val,
+ darg->type->name->val);
psi_validate_scope_del_struct(scope, s->name);
return false;
}
data->error(data, darg->token, PSI_WARNING,
"Computed size %zu of %s.%s does not match"
" pre-defined size %zu of type '%s'",
- len, s->name, darg->var->name, darg->layout->len,
- darg->type->name);
+ len, s->name->val, darg->var->name->val,
+ darg->layout->len, darg->type->name->val);
}
if (darg->layout->pos != pos) {
data->error(data, darg->token, PSI_WARNING,
"Computed offset %zu of %s.%s does not match"
" pre-defined offset %zu",
- pos, s->name, darg->var->name, darg->layout->pos);
+ pos, s->name->val, darg->var->name->val,
+ darg->layout->pos);
}
} else {
if (i) {
break;
default:
data->error(data, darg->token, PSI_WARNING,
- "Unsupported type for bit field: %s", real->name);
+ "Unsupported type for bit field: %s",
+ real->name->val);
psi_validate_scope_del_struct(scope, s->name);
return false;
}
data->error(data, darg->token, PSI_WARNING,
"Computed offset %zu of %s.%s does not match"
" pre-defined offset %zu",
- pos, s->name, darg->var->name, darg->layout->pos);
+ pos, s->name->val, darg->var->name->val,
+ darg->layout->pos);
}
darg->layout->pos = pos;
darg->layout->len = len;
struct psi_decl_struct {
struct psi_token *token;
- char *name;
+ zend_string *name;
struct psi_plist *args;
size_t size;
size_t align;
} engine;
};
-struct psi_decl_struct *psi_decl_struct_init(const char *name, struct psi_plist *args);
+struct psi_decl_struct *psi_decl_struct_init(zend_string *name, struct psi_plist *args);
void psi_decl_struct_free(struct psi_decl_struct **s_ptr);
void psi_decl_struct_dump(int fd, struct psi_decl_struct *strct);
#define PSI_STD_TYPES
#include "php_psi_posix.h"
-struct psi_decl_type *psi_decl_type_init(token_t type, const char *name)
+struct psi_decl_type *psi_decl_type_init(token_t type, zend_string *name)
{
struct psi_decl_type *t = calloc(1, sizeof(*t));
t->type = type;
- t->name = strdup(name);
+ t->name = zend_string_copy(name);
return t;
}
struct psi_decl_type *type = *type_ptr;
*type_ptr = NULL;
- if (type->token) {
- free(type->token);
- }
+ psi_token_free(&type->token);
if (type->type == PSI_T_FUNCTION) {
psi_decl_free(&type->real.func);
}
- free(type->name);
+ zend_string_release(type->name);
free(type);
}
}
dst->type = src->type;
if (src->name) {
- dst->name = strdup(src->name);
+ dst->name = zend_string_copy(src->name);
}
if (src->token) {
dst->token = psi_token_copy(src->token);
}
if (defs) {
while (psi_plist_get(defs, i++, &def)) {
- if (!strcmp(def->var->name, type->name)) {
+ if (zend_string_equals(def->var->name, type->name)) {
type->real.def = def;
return true;
}
}
}
for (stdtyp = &psi_std_types[0]; stdtyp->type_tag; ++stdtyp) {
- if (!strcmp(type->name, stdtyp->alias ?: stdtyp->type_name)) {
+ if (!strcmp(type->name->val, stdtyp->alias ?: stdtyp->type_name)) {
type->type = stdtyp->type_tag;
return true;
}
}
if (structs) {
while (psi_plist_get(structs, i++, &s)) {
- if (!strcmp(s->name, type->name)) {
+ if (zend_string_equals(s->name, type->name)) {
type->real.strct = s;
return true;
}
}
if (unions) {
while (psi_plist_get(unions, i++, &u)) {
- if (!strcmp(u->name, type->name)) {
+ if (zend_string_equals(u->name, type->name)) {
type->real.unn = u;
return true;
}
}
if (enums) {
while (psi_plist_get(enums, i++, &e)) {
- if (!strcmp(e->name, type->name)) {
+ if (zend_string_equals(e->name, type->name)) {
type->real.enm = e;
return true;
}
}
if (decls) {
while (psi_plist_get(decls, i++, &decl)) {
- if (!strcmp(decl->func->var->name, type->name)) {
+ if (zend_string_equals(decl->func->var->name, type->name)) {
type->real.func = decl;
return true;
}
return true;
} else {
data->error(data, type->token, PSI_WARNING,
- "Unknown struct '%s'", type->name);
+ "Unknown struct '%s'", type->name->val);
return false;
}
}
return true;
} else {
data->error(data, type->token, PSI_WARNING,
- "Unknown union '%s'", type->name);
+ "Unknown union '%s'", type->name->val);
return false;
}
}
case PSI_T_ENUM:
if (!psi_decl_type_get_enum(type, data->enums)) {
data->error(data, type->token, PSI_WARNING,
- "Unknown enum '%s'", type->name);
+ "Unknown enum '%s'", type->name->val);
return false;
}
break;
case PSI_T_FUNCTION:
if (!psi_decl_type_get_decl(type, data->decls)) {
data->error(data, type->token, PSI_WARNING,
- "Unknown decl '%s'", type->name);
+ "Unknown decl '%s'", type->name->val);
return false;
}
if (!psi_decl_validate_nodl(data, type->real.func, scope)) {
{
switch (t->type) {
case PSI_T_POINTER:
- dprintf(fd, "%s *", t->name);
+ dprintf(fd, "%s *", t->name->val);
return;
case PSI_T_ENUM:
break;
}
- dprintf(fd, "%s", t->name);
+ dprintf(fd, "%s", t->name->val);
}
int psi_decl_type_is_weak(struct psi_decl_type *type)
struct psi_decl_type {
struct psi_token *token;
- char *name;
+ zend_string *name;
token_t type;
union {
struct psi_decl_arg *def;
};
#include <string.h>
-#define psi_decl_type_is_anon(name, type) !strncmp(name, type "@", sizeof(type))
+#define psi_decl_type_is_anon(name, type) !strncmp(name->val, type "@", sizeof(type))
-struct psi_decl_type *psi_decl_type_init(token_t type, const char *name);
+struct psi_decl_type *psi_decl_type_init(token_t type, zend_string *name);
struct psi_decl_type *psi_decl_type_copy(struct psi_decl_type *src);
void psi_decl_type_free(struct psi_decl_type **type_ptr);
void psi_decl_type_dump(int fd, struct psi_decl_type *t, unsigned level);
#include <assert.h>
-struct psi_decl_union* psi_decl_union_init(const char *name,
+struct psi_decl_union* psi_decl_union_init(zend_string *name,
struct psi_plist *args)
{
struct psi_decl_union *u = calloc(1, sizeof(*u));
- u->name = strdup(name);
+ u->name = zend_string_copy(name);
u->args = args;
return u;
}
struct psi_decl_union *u = *u_ptr;
*u_ptr = NULL;
- if (u->token) {
- free(u->token);
- }
+ psi_token_free(&u->token);
if (u->args) {
psi_plist_free(u->args);
}
- free(u->name);
+ zend_string_release(u->name);
free(u);
}
}
void psi_decl_union_dump(int fd, struct psi_decl_union *unn)
{
- dprintf(fd, "union %s::(%zu, %zu)", unn->name, unn->align, unn->size);
+ dprintf(fd, "union %s::(%zu, %zu)", unn->name->val, unn->align, unn->size);
if (psi_plist_count(unn->args)) {
psi_decl_type_dump_args_with_layout(fd, unn->args, 0);
} else {
if (!u->size && !psi_plist_count(u->args)) {
data->error(data, u->token, PSI_WARNING,
- "Cannot compute size of empty union %s", u->name);
+ "Cannot compute size of empty union %s", u->name->val);
return false;
}
if (darg->layout->pos != 0) {
data->error(data, darg->token, PSI_WARNING,
- "Offset of %s.%s should be 0", u->name,
- darg->var->name);
+ "Offset of %s.%s should be 0", u->name->val,
+ darg->var->name->val);
darg->layout->pos = 0;
}
if (darg->layout->len != len) {
data->error(data, darg->token, PSI_WARNING,
"Computed size %zu of %s.%s does not match"
" pre-defined size %zu of type '%s'",
- len, u->name, darg->var->name, darg->layout->len,
- darg->type->name);
+ len, u->name->val, darg->var->name->val,
+ darg->layout->len, darg->type->name->val);
}
} else {
pos = 0;
if (darg->layout) {
if (darg->layout->pos != 0) {
data->error(data, darg->token, PSI_WARNING,
- "Offset of %s.%s should be 0", u->name,
- darg->var->name);
+ "Offset of %s.%s should be 0", u->name->val,
+ darg->var->name->val);
darg->layout->pos = 0;
}
darg->layout->len = len;
struct psi_decl_union {
struct psi_token *token;
- char *name;
+ zend_string *name;
struct psi_plist *args;
size_t size;
size_t align;
};
-struct psi_decl_union *psi_decl_union_init(const char *name, struct psi_plist *args);
+struct psi_decl_union *psi_decl_union_init(zend_string *name, struct psi_plist *args);
void psi_decl_union_free(struct psi_decl_union **u_ptr);
void psi_decl_union_dump(int fd, struct psi_decl_union *unn);
#include <assert.h>
-struct psi_decl_var *psi_decl_var_init(const char *name, unsigned pl,
+#include <Zend/zend_smart_str.h>
+
+struct psi_decl_var *psi_decl_var_init(zend_string *name, unsigned pl,
unsigned as)
{
struct psi_decl_var *v = calloc(1, sizeof(*v));
if (name) {
- v->name = strdup(name);
- v->fqn = strdup(name);
+ v->name = zend_string_copy(name);
+ v->fqn = zend_string_copy(name);
}
v->pointer_level = pl;
v->array_size = as;
*dest = *src;
if (dest->name) {
- dest->name = strdup(dest->name);
- dest->fqn = strdup(dest->fqn);
+ dest->name = zend_string_copy(dest->name);
+ dest->fqn = zend_string_copy(dest->fqn);
}
if (dest->token) {
struct psi_decl_var *var = *var_ptr;
*var_ptr = NULL;
- if (var->token) {
- free(var->token);
- }
+ psi_token_free(&var->token);
if (var->name) {
- free(var->name);
- free(var->fqn);
+ zend_string_release(var->name);
+ zend_string_release(var->fqn);
}
free(var);
}
{
dprintf(fd, "%s%s",
psi_t_indirection(var->pointer_level - !!var->array_size),
- var->name ? var->name : "/**/");
+ var->name ? var->name->val : "/**/");
if (var->array_size && var->arg->type->type != PSI_T_FUNCTION) {
dprintf(fd, "[%u]", var->array_size);
}
}
+static inline zend_string *psi_decl_var_name_prepend(zend_string *current, zend_string *prepend) {
+ smart_str name = {0};
+
+ smart_str_alloc(&name, prepend->len + 1 + current->len, 1);
+ smart_str_append_ex(&name, prepend, 1);
+ smart_str_appendc_ex(&name, '.', 1);
+ smart_str_append_ex(&name, current, 1);
+
+ return smart_str_extract(&name);
+}
+
bool psi_decl_var_validate(struct psi_data *data, struct psi_decl_var *dvar,
struct psi_validate_scope *scope)
{
if (args && psi_decl_arg_get_by_var(dvar, args, NULL)) {
okay = true;
- } else if (!strcmp(svar->name, dvar->name)) {
+ } else if (zend_string_equals(svar->name, dvar->name)) {
dvar->arg = svar->arg;
okay = true;
}
}
if (okay) {
+ zend_string *tmp = dvar->fqn;
dvar->fqn = psi_decl_var_name_prepend(dvar->fqn, svar->name);
+ zend_string_release(tmp);
}
}
} else if (scope && scope->current_set) {
if (args && psi_decl_arg_get_by_var(dvar, args, NULL)) {
okay = true;
- } else if (!strcmp(svar->name, dvar->name)) {
+ } else if (zend_string_equals(svar->name, dvar->name)) {
dvar->arg = svar->arg;
okay = true;
}
}
if (okay) {
+ zend_string *tmp = dvar->fqn;
dvar->fqn = psi_decl_var_name_prepend(dvar->fqn, svar->name);
+ zend_string_release(tmp);
}
}
}
struct psi_decl_var {
struct psi_token *token;
- char *name, *fqn;
+ zend_string *name, *fqn;
unsigned pointer_level;
unsigned array_size;
struct psi_decl_arg *arg;
};
-struct psi_decl_var *psi_decl_var_init(const char *name, unsigned pl, unsigned as);
+struct psi_decl_var *psi_decl_var_init(zend_string *name, unsigned pl, unsigned as);
struct psi_decl_var *psi_decl_var_copy(struct psi_decl_var *src);
void psi_decl_var_free(struct psi_decl_var **var_ptr);
void psi_decl_var_dump(int fd, struct psi_decl_var *var);
-#include <string.h>
-
-static inline char *psi_decl_var_name_prepend(char *current, const char *prepend) {
- size_t c_len = strlen(current);
- size_t p_len = strlen(prepend);
-
- current = realloc(current, p_len + 1 + c_len + 1);
- if (current) {
- memmove(current + p_len + 1, current, c_len + 1);
- current[p_len] = '.';
- memcpy(current, prepend, p_len);
- }
- return current;
-}
-
bool psi_decl_var_validate(struct psi_data *data, struct psi_decl_var *dvar,
struct psi_validate_scope *scope);
#include "data.h"
#include "call.h"
-struct psi_free_exp *psi_free_exp_init(const char *func, struct psi_plist *vars)
+struct psi_free_exp *psi_free_exp_init(zend_string *func, struct psi_plist *vars)
{
struct psi_free_exp *f = calloc(1, sizeof(*f));
- f->func = strdup(func);
+ f->func = zend_string_copy(func);
f->vars = vars;
return f;
}
struct psi_free_exp *f = *f_ptr;
*f_ptr = NULL;
- if (f->token) {
- free(f->token);
- }
- free(f->func);
+ psi_token_free(&f->token);
+ zend_string_release(f->func);
psi_plist_free(f->vars);
if (f->let) {
free(f->let);
size_t l = 0, c = psi_plist_count(call->vars);
struct psi_decl_var *fvar;
- dprintf(fd, "%s(", call->func);
+ dprintf(fd, "%s(", call->func->val);
while (psi_plist_get(call->vars, l++, &fvar)) {
psi_decl_var_dump(fd, fvar);
if (l < c) {
struct psi_decl *decl;
while (psi_plist_get(decls, i++, &decl)) {
- if (!strcmp(decl->func->var->name, f->func)) {
+ if (zend_string_equals(decl->func->var->name, f->func)) {
return f->decl = decl;
}
}
if (!locate_free_decl(data->decls, exp)) {
data->error(data, exp->token, PSI_WARNING,
"Missing declaration '%s' in `free` statement"
- " of implementation '%s'", exp->func, scope->impl->func->name);
+ " of implementation '%s'", exp->func->val,
+ scope->impl->func->name->val);
return false;
}
data->error(data, free_var->token, PSI_WARNING,
"Unknown variable '%s' of `free` statement"
" of implementation '%s'",
- free_var->name, scope->impl->func->name);
+ free_var->name->val, scope->impl->func->name->val);
return false;
}
struct psi_free_exp {
struct psi_token *token;
- char *func;
+ zend_string *func;
struct psi_plist *vars;
struct psi_decl *decl;
struct psi_let_stmt **let;
};
-struct psi_free_exp *psi_free_exp_init(const char *func, struct psi_plist *vars);
+struct psi_free_exp *psi_free_exp_init(zend_string *func, struct psi_plist *vars);
void psi_free_exp_free(struct psi_free_exp **f_ptr);
void psi_free_exp_dump(int fd, struct psi_free_exp *call);
struct psi_free_stmt *f = *f_ptr;
*f_ptr = NULL;
- if (f->token) {
- free(f->token);
- }
+ psi_token_free(&f->token);
psi_plist_free(f->exps);
free(f);
}
struct psi_decl_var *arg;
while (psi_plist_get(ret->exp->args, i++, &arg)) {
- if (!strcmp(var->name, arg->name)) {
+ if (zend_string_equals(var->name, arg->name)) {
return var->arg = arg->arg;
}
}
struct psi_impl_arg *iarg;
while (psi_plist_get(impl->func->args, i++, &iarg)) {
- if (!strcmp(var->name, iarg->var->name)) {
+ if (zend_string_equals(var->name, iarg->var->name)) {
return var->arg = iarg;
}
}
if (let->exp->kind != PSI_LET_TMP) {
continue;
}
- if (strcmp(let->exp->var->name, var->name)) {
+ if (!zend_string_equals(let->exp->var->name, var->name)) {
continue;
}
return var->arg = let->exp->var->arg;
/* no break */
case PSI_T_STRING:
if (data) {
- def->ival.zend.str = zend_string_init(data, strlen(data), 1);
+ def->ival.zend.str = zend_string_copy(data);
}
break;
struct psi_impl_def_val *def = *def_ptr;
*def_ptr = NULL;
- if (def->token) {
- free(def->token);
- }
+ psi_token_free(&def->token);
switch (def->type) {
case PSI_T_NUMBER:
psi_num_exp_free(&def->data.num);
case PSI_T_DOUBLE:
val->type = PSI_T_FLOAT;
type->type = PSI_T_FLOAT;
- strcpy(type->name, "float");
+ zend_string_release(type->name);
+ type->name = zend_string_init(ZEND_STRL("float"), 1);
break;
default:
val->type = PSI_T_INT;
type->type = PSI_T_INT;
- strcpy(type->name, "int");
+ zend_string_release(type->name);
+ type->name = zend_string_init(ZEND_STRL("int"), 1);
break;
}
psi_num_exp_free(&val->data.num);
data->error(data, val->token, PSI_WARNING,
"Invalid default value type '%s', "
"expected one of bool, int, float, string.",
- type->name);
+ type->name->val);
}
return false;
#include "php_psi_stdinc.h"
#include "data.h"
-struct psi_impl_func *psi_impl_func_init(const char *name,
+struct psi_impl_func *psi_impl_func_init(zend_string *name,
struct psi_plist *args, struct psi_impl_type *type)
{
struct psi_impl_func *func = calloc(1, sizeof(*func));
- func->name = strdup(name);
+ func->name = zend_string_copy(name);
func->args = args ? : psi_plist_init((psi_plist_dtor) psi_impl_arg_free);
func->return_type = type;
struct psi_impl_func *f = *f_ptr;
*f_ptr = NULL;
- if (f->token) {
- free(f->token);
- }
+ psi_token_free(&f->token);
psi_impl_type_free(&f->return_type);
psi_plist_free(f->args);
psi_impl_arg_free(&f->vararg);
}
- free(f->name);
+ zend_string_release(f->name);
free(f);
}
}
"Non-optional argument %zu '$%s' of implementation '%s'"
" follows optional argument",
i + 1,
- iarg->var->name, func->name);
+ iarg->var->name->val, func->name->val);
return false;
}
}
void psi_impl_func_dump(int fd, struct psi_impl_func *func)
{
- dprintf(fd, "function %s(", func->name);
+ dprintf(fd, "function %s(", func->name->val);
if (func->args) {
size_t i = 0;
struct psi_impl_arg *iarg;
}
}
dprintf(fd, ") : %s%s", func->return_reference ? "&" : "",
- func->return_type->name);
+ func->return_type->name->val);
}
struct psi_impl_func {
struct psi_token *token;
- char *name;
+ zend_string *name;
struct psi_plist *args;
struct psi_impl_arg *vararg;
struct psi_impl_type *return_type;
unsigned static_memory:1;
};
-struct psi_impl_func *psi_impl_func_init(const char *name, struct psi_plist *args, struct psi_impl_type *return_type);
+struct psi_impl_func *psi_impl_func_init(zend_string *name,
+ struct psi_plist *args, struct psi_impl_type *return_type);
void psi_impl_func_free(struct psi_impl_func **f_ptr);
void psi_impl_func_dump(int fd, struct psi_impl_func *func);
bool psi_impl_func_validate(struct psi_data *data, struct psi_impl_func *func,
#include "php_psi_stdinc.h"
#include "data.h"
-struct psi_impl_type *psi_impl_type_init(token_t type, const char *name)
+struct psi_impl_type *psi_impl_type_init(token_t type, zend_string *name)
{
struct psi_impl_type *t = calloc(1, sizeof(*t));
t->type = type;
- t->name = strdup(name);
+ t->name = zend_string_copy(name);
return t;
}
void psi_impl_type_dump(int fd, struct psi_impl_type *type)
{
- dprintf(fd, "%s", type->name);
+ dprintf(fd, "%s", type->name->val);
}
void psi_impl_type_free(struct psi_impl_type **type_ptr)
struct psi_impl_type *type = *type_ptr;
*type_ptr = NULL;
- if (type->token) {
- free(type->token);
- }
- free(type->name);
+ psi_token_free(&type->token);
+ zend_string_release(type->name);
free(type);
}
}
struct psi_impl_type {
struct psi_token *token;
- char *name;
+ zend_string *name;
token_t type;
};
-struct psi_impl_type *psi_impl_type_init(token_t type, const char *name);
+struct psi_impl_type *psi_impl_type_init(token_t type, zend_string *name);
void psi_impl_type_free(struct psi_impl_type **type_ptr);
void psi_impl_type_dump(int fd, struct psi_impl_type *type);
#include "php_psi_stdinc.h"
#include "data.h"
-struct psi_impl_var *psi_impl_var_init(const char *name, bool is_reference)
+#include <Zend/zend_smart_str.h>
+
+struct psi_impl_var *psi_impl_var_init(zend_string *name, bool is_reference)
{
struct psi_impl_var *var = calloc(1, sizeof(*var));
- var->name = strdup(name);
- var->fqn = strdup(name);
+ var->name = zend_string_copy(name);
+ var->fqn = zend_string_copy(name);
var->reference = is_reference;
return var;
*cpy = *var;
- cpy->name = strdup(cpy->name);
- cpy->fqn = strdup(cpy->fqn);
+ cpy->name = zend_string_copy(cpy->name);
+ cpy->fqn = zend_string_copy(cpy->fqn);
if (cpy->token) {
cpy->token = psi_token_copy(cpy->token);
struct psi_impl_var *var = *var_ptr;
*var_ptr = NULL;
- if (var->token) {
- free(var->token);
- }
- free(var->name);
- free(var->fqn);
+ psi_token_free(&var->token);
+ zend_string_release(var->name);
+ zend_string_release(var->fqn);
free(var);
}
}
dprintf(fd, "%s%s%s",
var->reference ? "&" : "",
vararg ? "..." : "",
- var->name);
+ var->name->val);
+}
+
+static inline zend_string *psi_impl_var_name_prepend(zend_string *current, zend_string *prepend) {
+ smart_str name = {0};
+
+ smart_str_append_ex(&name, prepend, 1);
+ smart_str_appendc_ex(&name, '.', 1);
+ smart_str_appendl_ex(&name, ZSTR_VAL(current) + 1, ZSTR_LEN(current) - 1, 1);
+ return smart_str_extract(&name);
}
bool psi_impl_var_validate(struct psi_data *data, struct psi_impl_var *ivar,
while ((current_let_exp = current_let_exp->outer)) {
struct psi_impl_var *svar = psi_let_exp_get_impl_var(current_let_exp);
+ zend_string *tmp = ivar->fqn;
- ivar->fqn = psi_impl_var_name_prepend(ivar->fqn, svar->name + 1);
+ ivar->fqn = psi_impl_var_name_prepend(ivar->fqn, svar->name);
+ zend_string_release(tmp);
}
} else if (scope && scope->current_set) {
struct psi_set_exp *current_set_exp = scope->current_set;
while ((current_set_exp = current_set_exp->outer)) {
struct psi_impl_var *svar = psi_set_exp_get_impl_var(current_set_exp);
+ zend_string *tmp = ivar->fqn;
- ivar->fqn = psi_impl_var_name_prepend(ivar->fqn, svar->name + 1);
+ ivar->fqn = psi_impl_var_name_prepend(ivar->fqn, svar->name);
+ zend_string_release(tmp);
}
}
struct psi_impl_var {
struct psi_token *token;
- char *name, *fqn;
+ zend_string *name, *fqn;
struct psi_impl_arg *arg;
unsigned reference:1;
};
-struct psi_impl_var *psi_impl_var_init(const char *name, bool is_reference);
+struct psi_impl_var *psi_impl_var_init(zend_string *name, bool is_reference);
struct psi_impl_var *psi_impl_var_copy(struct psi_impl_var *var);
void psi_impl_var_free(struct psi_impl_var **var_ptr);
void psi_impl_var_dump(int fd, struct psi_impl_var *var, bool vararg);
-#include <string.h>
-
-static inline char *psi_impl_var_name_prepend(char *current, const char *prepend) {
- size_t c_len = strlen(current);
- size_t p_len = strlen(prepend);
-
- current = realloc(current, p_len
- + c_len // includes '$'
- + 1 // connecting dot
- + 1 // terminating 0
- );
- if (current) {
- if (c_len > 1) {
- memmove(current + p_len + 1 + 1, current + 1, c_len - 1 + 1);
- current[p_len + 1] = '.';
- } else {
- /* just '$' */
- current[p_len + 1] = '\0';
- }
- memcpy(current + 1, prepend, p_len);
- }
- return current;
-}
-
bool psi_impl_var_validate(struct psi_data *data, struct psi_impl_var *ivar,
struct psi_validate_scope *scope);
if (cb->cb_args) {
psi_plist_free(cb->cb_args);
}
- if (cb->token) {
- free(cb->token);
- }
+ psi_token_free(&cb->token);
free(cb);
}
}
data->error(data, cb->token, PSI_WARNING,
"Argument count of callback statement of implementation '%s'"
"does not match argument count of callback declaration '%s'",
- impl->func->name, cb_decl->func->var->name);
+ impl->func->name->val, cb_decl->func->var->name->val);
return false;
}
if (cb_type->type != PSI_T_FUNCTION) {
data->error(data, cb_var->token, PSI_WARNING,
"Expected a function: %s",
- cb_var->name);
+ cb_var->name->val);
return false;
}
cb->decl = cb_type->real.func;
}
}
dprintf(fd, ") as %s(%s(",
- callback->func->name,
- callback->func->var->name);
+ callback->func->name->val,
+ callback->func->var->name->val);
if (callback->args) {
size_t i = 0, last = psi_plist_count(callback->args);
*alloc_ptr = NULL;
psi_num_exp_free(&alloc->nmemb);
psi_num_exp_free(&alloc->size);
- if (alloc->token) {
- free(alloc->token);
- }
+ psi_token_free(&alloc->token);
free(alloc);
}
}
#include <assert.h>
+#include <Zend/zend_smart_str.h>
+
struct psi_let_exp *psi_let_exp_init_ex(struct psi_decl_var *var,
enum psi_let_exp_kind kind, void *data)
{
break;
case PSI_LET_TMP:
psi_decl_var_dump(fd, val->data.var);
- dprintf(fd, "\t/* fqn=%s */", val->data.var->fqn);
+ dprintf(fd, "\t/* fqn=%s */", val->data.var->fqn->val);
break;
case PSI_LET_CALLOC:
psi_let_calloc_dump(fd, val->data.alloc);
}
if (val->var) {
- dprintf(fd, "\t/* fqn=%s */", val->var->fqn);
+ dprintf(fd, "\t/* fqn=%s */", val->var->fqn->val);
}
if (level > 1) {
if (!psi_decl_var_validate(data, val->data.var, scope)) {
data->error(data, dvar->token ? : **(struct psi_token ***) &val->data,
PSI_WARNING, "Unknown variable '%s' in temp let statment of implementation '%s'",
- dvar->name, scope->impl->func->name);
+ dvar->name->val, scope->impl->func->name->val);
return false;
}
break;
if (!psi_decl_var_validate(data, dvar, scope)) {
data->error(data, dvar->token ? : **(struct psi_token ***) &val->data,
PSI_WARNING, "Unknown variable '%s' in let statement of implementation '%s'",
- dvar->name, scope->impl->func->name);
+ dvar->name->val, scope->impl->func->name->val);
return false;
}
break;
struct psi_decl_var *psi_let_exp_get_decl_var(struct psi_let_exp *val)
{
if (!val->var) {
- const char *name = psi_let_exp_get_decl_var_name(val);
+ zend_string *name = psi_let_exp_get_decl_var_name(val);
if (name) {
val->var = psi_decl_var_init(name, 0, 0);
+ zend_string_release(name);
}
}
return val->var;
return fn ? fn->var : NULL;
}
-const char* psi_let_exp_get_decl_var_name(struct psi_let_exp* val)
+zend_string *psi_let_exp_get_decl_var_name(struct psi_let_exp* val)
{
struct psi_impl_var* var;
+
if (val->var) {
- return val->var->name;
+ return zend_string_copy(val->var->name);
}
+
var = psi_let_exp_get_impl_var(val);
if (var) {
- return &var->name[1];
+ smart_str name = {0};
+
+ smart_str_appendl_ex(&name, &var->name->val[1], var->name->len - 1, 1);
+
+ return smart_str_extract(&name);
}
+
return NULL;
}
struct psi_let_func *psi_let_exp_get_func(struct psi_let_exp *exp);
struct psi_impl_var *psi_let_exp_get_impl_var(struct psi_let_exp *exp);
struct psi_decl_var *psi_let_exp_get_decl_var(struct psi_let_exp *val);
-const char *psi_let_exp_get_decl_var_name(struct psi_let_exp *exp);
+zend_string *psi_let_exp_get_decl_var_name(struct psi_let_exp *exp);
#endif
#include <assert.h>
-struct psi_let_func *psi_let_func_init(token_t type, const char *name,
+struct psi_let_func *psi_let_func_init(token_t type, zend_string *name,
struct psi_impl_var *var)
{
struct psi_let_func *func = calloc(1, sizeof(*func));
func->type = type;
- func->name = strdup(name);
+ func->name = zend_string_copy(name);
func->var = var;
return func;
}
struct psi_let_func *func = *func_ptr;
*func_ptr = NULL;
- if (func->token) {
- free(func->token);
- }
+ psi_token_free(&func->token);
psi_impl_var_free(&func->var);
- free(func->name);
+ zend_string_release(func->name);
if (func->inner) {
psi_plist_free(func->inner);
}
void psi_let_func_dump(int fd, struct psi_let_func *func, unsigned level)
{
- dprintf(fd, "%s(%s\t/* fqn=%s */", func->name, func->var->name, func->var->fqn);
+ dprintf(fd, "%s(%s\t/* fqn=%s */", func->name->val, func->var->name->val,
+ func->var->fqn->val);
if (func->inner) {
size_t i = 0, count = psi_plist_count(func->inner);
default:
data->error(data, func->var->token, PSI_WARNING,
"Unknown `let` cast function '%s' of implementation '%s'",
- func->name, scope->impl->func->name);
+ func->name->val, scope->impl->func->name->val);
return false;
}
}
struct psi_let_exp *inner;
while (psi_plist_get(func->inner, i++, &inner)) {
- const char *name = psi_let_exp_get_decl_var_name(inner);
+ zend_string *name = psi_let_exp_get_decl_var_name(inner);
struct psi_decl_arg *sub_arg;
inner->outer = exp;
sub_var = psi_let_exp_get_impl_var(exp);
sub_ref = psi_let_exp_get_impl_var(inner);
- if (strcmp(sub_var->name, sub_ref->name)) {
+ if (!zend_string_equals(sub_var->name, sub_ref->name)) {
data->error(data, sub_var->token, E_WARNING,
"Inner `set` statement casts on pointers must"
" reference the same variable");
"Inner let statement's values must refer to a structure or"
" array type, got '%s%s' for '%s'", var_typ->name,
psi_t_indirection(let_var->arg->var->pointer_level),
- let_var->name);
+ let_var->name->val);
return false;
}
* we only want to set supplied data on unions
*/
if (!zend_symtable_str_exists(Z_ARRVAL_P(frame_arg->zval_ptr),
- &inner_var->name[1], strlen(&inner_var->name[1]))) {
+ &inner_var->name->val[1], inner_var->name->len - 1)) {
return;
}
}
/* example from dm_store/dbm_fetch with arrval($string) conversion:
let key = arrval($key,
- dptr = strval($0),
- dsize = strlen($0)
+ dptr = strval($0),
+ dsize = strlen($0)
);
# ---
darg = key
struct psi_let_func {
struct psi_token *token;
token_t type;
- char *name;
+ zend_string *name;
struct psi_impl_var *var;
struct psi_plist *inner;
};
-struct psi_let_func *psi_let_func_init(token_t type, const char *name, struct psi_impl_var *var);
+struct psi_let_func *psi_let_func_init(token_t type, zend_string *name, struct psi_impl_var *var);
void psi_let_func_free(struct psi_let_func **func_ptr);
void psi_let_func_dump(int fd, struct psi_let_func *func, unsigned level);
if (stmt->exp) {
psi_let_exp_free(&stmt->exp);
}
- if (stmt->token) {
- free(stmt->token);
- }
+ psi_token_free(&stmt->token);
free(stmt);
}
}
if (!let->exp->var) {
data->error(data, let->token, PSI_WARNING,
"Missing variable in `let` statement for implementation %s",
- scope->impl->func->name);
+ scope->impl->func->name->val);
return false;
}
if (!psi_impl_get_decl_arg(scope->impl, let_var)) {
data->error(data, let_var->token, PSI_WARNING,
"Unknown variable '%s' in `let` statement of implementation '%s'",
- let_var->name, scope->impl->func->name);
+ let_var->name->val, scope->impl->func->name->val);
return false;
}
switch (let->exp->kind) {
if (let_ivar && !psi_impl_get_arg(scope->impl, let_ivar)) {
data->error(data, let_var->token, PSI_WARNING,
"Unknown variable '%s' in `let` statement of implementation '%s'",
- let_ivar->name, scope->impl->func->name);
+ let_ivar->name->val, scope->impl->func->name->val);
return false;
}
data->error(data, scope->impl->func->token, PSI_WARNING,
"Missing `let` statement for arg '%s %s%s'"
" of declaration '%s' for implementation '%s'",
- darg->type->name,
+ darg->type->name->val,
psi_t_indirection(darg->var->pointer_level),
- darg->var->name, scope->impl->decl->func->var->name,
- scope->impl->func->name);
+ darg->var->name->val,
+ scope->impl->decl->func->var->name->val,
+ scope->impl->func->name->val);
return false;
}
}
assert(0);
}
- if (c->token) {
- free(c->token);
- }
+ psi_token_free(&c->token);
free(c);
}
list = psi_plist_add(list, &ntoken);
ntoken = psi_token_copy(exp->data.c.typ->token);
list = psi_plist_add(list, &ntoken);
- ntoken = psi_token_init(PSI_T_RPAREN, ")", 1, ntoken->col+ntoken->size, ntoken->line, ntoken->file);
+ ntoken = psi_token_init(PSI_T_RPAREN, ")", 1, ntoken->col+ntoken->text->len, ntoken->line, ntoken->file);
list = psi_plist_add(list, &ntoken);
break;
list = psi_plist_add(list, &ntoken);
list = psi_num_exp_tokens(exp->data.u, list);
psi_plist_top(list, &ntoken);
- ntoken = psi_token_init(PSI_T_RPAREN, ")", 1, ntoken->col+ntoken->size, ntoken->line, ntoken->file);
+ ntoken = psi_token_init(PSI_T_RPAREN, ")", 1, ntoken->col+ntoken->text->len, ntoken->line, ntoken->file);
list = psi_plist_add(list, &ntoken);
break;
list = psi_plist_add(list, &ntoken);
list = psi_num_exp_tokens(exp->data.t.truthy, list);
psi_plist_top(list, &ntoken);
- ntoken = psi_token_init(PSI_T_COLON, ":", 1, ntoken->col+ntoken->size, ntoken->line, ntoken->file);
+ ntoken = psi_token_init(PSI_T_COLON, ":", 1, ntoken->col+ntoken->text->len, ntoken->line, ntoken->file);
list = psi_plist_add(list, &ntoken);
list = psi_plist_add(list, &ntoken);
list = psi_num_exp_tokens(exp->data.t.falsy, list);
case PSI_T_NUMBER:
case PSI_T_NSNAME:
case PSI_T_DEFINE:
- exp->data.numb = strdup(num);
+ exp->data.numb = zend_string_copy(num);
break;
case PSI_T_NAME:
exp->data.dvar = num;
case PSI_T_NSNAME:
case PSI_T_DEFINE:
case PSI_T_QUOTED_CHAR:
- num->data.numb = strdup(num->data.numb);
+ num->data.numb = zend_string_copy(num->data.numb);
break;
case PSI_T_NAME:
num->data.dvar = psi_decl_var_copy(num->data.dvar);
case PSI_T_NUMBER:
case PSI_T_DEFINE:
case PSI_T_QUOTED_CHAR:
- free(exp->data.numb);
+ zend_string_release(exp->data.numb);
break;
case PSI_T_NAME:
psi_decl_var_free(&exp->data.dvar);
unsigned pl = exp->data.dvar->pointer_level - !!exp->data.dvar->array_size;
while (pl--) {
-
- ntoken = psi_token_init(PSI_T_POINTER, "*", 1, ntoken->col+ntoken->size, ntoken->line, ntoken->file);
+ ntoken = psi_token_init(PSI_T_POINTER, "*", 1, ntoken->col+ntoken->text->len, ntoken->line, ntoken->file);
list = psi_plist_add(list, &ntoken);
}
ntoken = temp;
if (exp->data.dvar->array_size) {
char buf[0x20], *ptr;
- ntoken = psi_token_init(PSI_T_LBRACKET, "[", 1, ntoken->col+ntoken->size, ntoken->line, ntoken->file);
+ ntoken = psi_token_init(PSI_T_LBRACKET, "[", 1, ntoken->col+ntoken->text->len, ntoken->line, ntoken->file);
list = psi_plist_add(list, &ntoken);
ptr = zend_print_ulong_to_buf(&buf[sizeof(buf) - 1], exp->data.dvar->array_size);
- ntoken = psi_token_init(PSI_T_NUMBER, ptr, strlen(ptr), ntoken->col+ntoken->size, ntoken->line, ntoken->file);
+ ntoken = psi_token_init(PSI_T_NUMBER, ptr, strlen(ptr), ntoken->col+ntoken->text->len, ntoken->line, ntoken->file);
list = psi_plist_add(list, &ntoken);
}
break;
/* decl_type */
ntoken = psi_token_copy(exp->token);
list = psi_plist_add(list, &ntoken);
- ntoken = psi_token_init(PSI_T_LPAREN, "(", 1, ntoken->col+ntoken->size, ntoken->line, ntoken->file);
+ ntoken = psi_token_init(PSI_T_LPAREN, "(", 1, ntoken->col+ntoken->text->len, ntoken->line, ntoken->file);
list = psi_plist_add(list, &ntoken);
ntoken = psi_token_copy(exp->data.dtyp->token);
list = psi_plist_add(list, &ntoken);
- ntoken = psi_token_init(PSI_T_RPAREN, ")", 1, ntoken->col+ntoken->size, ntoken->line, ntoken->file);
+ ntoken = psi_token_init(PSI_T_RPAREN, ")", 1, ntoken->col+ntoken->text->len, ntoken->line, ntoken->file);
list = psi_plist_add(list, &ntoken);
break;
case PSI_T_NSNAME:
case PSI_T_DEFINE:
case PSI_T_QUOTED_CHAR:
- dprintf(fd, "%s", exp->data.numb);
+ dprintf(fd, "%s", exp->data.numb->val);
break;
case PSI_T_FUNCTION:
psi_cpp_macro_call_dump(fd, exp->data.call);
break;
case PSI_T_CONST:
- dprintf(fd, "%s", exp->data.cnst->name);
+ dprintf(fd, "%s", exp->data.cnst->name->val);
break;
case PSI_T_ENUM:
- dprintf(fd, "%s", exp->data.enm->name);
+ dprintf(fd, "%s", exp->data.enm->name->val);
break;
case PSI_T_NAME:
psi_decl_var_dump(fd, exp->data.dvar);
switch (exp->type) {
case PSI_T_NAME:
while (psi_plist_get(enm->items, i++, &itm)) {
- if (!strcmp(itm->name, exp->data.dvar->name)) {
+ if (zend_string_equals(itm->name, exp->data.dvar->name)) {
psi_decl_var_free(&exp->data.dvar);
exp->type = PSI_T_ENUM;
exp->data.enm = itm;
case PSI_T_DEFINE:
while (psi_plist_get(enm->items, i++, &itm)) {
- if (!strcmp(itm->name, exp->data.numb)) {
- free(exp->data.numb);
+ if (zend_string_equals(itm->name, exp->data.numb)) {
+ zend_string_release(exp->data.numb);
exp->type = PSI_T_ENUM;
exp->data.enm = itm;
return psi_number_validate(data, exp, scope);
{
impl_val val = {0};
unsigned lvl = 1;
- token_t typ = validate_char(exp->data.numb, &val, &lvl);
+ token_t typ = validate_char(exp->data.numb->val, &val, &lvl);
if (!typ) {
return false;
}
- free(exp->data.numb);
+ zend_string_release(exp->data.numb);
exp->type = typ;
exp->data.ival = val;
return true;
switch (exp->flags & 0x0f00) {
case PSI_NUMBER_L:
default:
- tmp.i64 = strtol(exp->data.numb, NULL, 0);
- free(exp->data.numb);
+ tmp.i64 = strtol(exp->data.numb->val, NULL, 0);
+ zend_string_release(exp->data.numb);
exp->type = PSI_T_INT64;
exp->data.ival.i64 = tmp.i64;
break;
case PSI_NUMBER_LL:
- tmp.i64 = strtoll(exp->data.numb, NULL, 0);
- free(exp->data.numb);
+ tmp.i64 = strtoll(exp->data.numb->val, NULL, 0);
+ zend_string_release(exp->data.numb);
exp->type = PSI_T_INT64;
exp->data.ival.i64 = tmp.i64;
break;
case PSI_NUMBER_U:
case PSI_NUMBER_UL:
- tmp.u64 = strtoul(exp->data.numb, NULL, 0);
- free(exp->data.numb);
+ tmp.u64 = strtoul(exp->data.numb->val, NULL, 0);
+ zend_string_release(exp->data.numb);
exp->type = PSI_T_UINT64;
exp->data.ival.u64 = tmp.u64;
break;
case PSI_NUMBER_ULL:
- tmp.u64 = strtoull(exp->data.numb, NULL, 0);
- free(exp->data.numb);
+ tmp.u64 = strtoull(exp->data.numb->val, NULL, 0);
+ zend_string_release(exp->data.numb);
exp->type = PSI_T_UINT64;
exp->data.ival.u64 = tmp.u64;
break;
switch (exp->flags & 0x0ff00) {
case PSI_NUMBER_F:
case PSI_NUMBER_DF:
- tmp.fval = strtof(exp->data.numb, NULL);
- free(exp->data.numb);
+ tmp.fval = strtof(exp->data.numb->val, NULL);
+ zend_string_release(exp->data.numb);
exp->type = PSI_T_FLOAT;
exp->data.ival.fval = tmp.fval;
break;
case PSI_NUMBER_L:
case PSI_NUMBER_DL:
#if HAVE_LONG_DOUBLE
- tmp.ldval = strtold(exp->data.numb, NULL);
- free(exp->data.numb);
+ tmp.ldval = strtold(exp->data.numb->val, NULL);
+ zend_string_release(exp->data.numb);
exp->type = PSI_T_LONG_DOUBLE;
exp->data.ival.ldval = tmp.ldval;
break;
#endif
case PSI_NUMBER_DD:
default:
- tmp.dval = strtod(exp->data.numb, NULL);
- free(exp->data.numb);
+ tmp.dval = strtod(exp->data.numb->val, NULL);
+ zend_string_release(exp->data.numb);
exp->type = PSI_T_DOUBLE;
exp->data.ival.dval = tmp.dval;
break;
break;
}
} else {
- switch (is_numeric_string(exp->data.numb, strlen(exp->data.numb), (zend_long *) &tmp, (double *) &tmp, 1)) {
+ switch (is_numeric_str_function(exp->data.numb, (zend_long *) &tmp, (double *) &tmp)) {
case IS_LONG:
- free(exp->data.numb);
+ zend_string_release(exp->data.numb);
exp->type = PSI_T_INT64;
exp->data.ival.i64 = tmp.zend.lval;
return true;
case IS_DOUBLE:
- free(exp->data.numb);
+ zend_string_release(exp->data.numb);
exp->type = PSI_T_DOUBLE;
exp->data.ival.dval = tmp.dval;
return true;
return true;
case PSI_T_NAME:
- if (scope && scope->defs && zend_hash_str_exists(scope->defs, exp->data.dvar->name, strlen(exp->data.dvar->name))) {
+ if (scope && scope->defs && zend_hash_exists(scope->defs, exp->data.dvar->name)) {
return true;
}
if (scope && scope->current_enum && psi_number_validate_enum(data, exp, scope)) {
}
data->error(data, exp->token, PSI_WARNING,
"Unknown variable '%s' in numeric expression",
- exp->data.dvar->name);
+ exp->data.dvar->name->val);
return false;
case PSI_T_FUNCTION:
- if (scope && scope->defs && zend_hash_str_exists(scope->defs, exp->data.numb, strlen(exp->data.numb))) {
+ if (scope && scope->defs && zend_hash_exists(scope->defs, exp->data.numb)) {
return true;
}
return false;
case PSI_T_DEFINE:
- if (scope && scope->defs && zend_hash_str_exists(scope->defs, exp->data.numb, strlen(exp->data.numb))) {
- if (!scope->macro || strcmp(scope->macro->token->text, exp->data.numb)) {
+ if (scope && scope->defs && zend_hash_exists(scope->defs, exp->data.numb)) {
+ if (!scope->macro || !zend_string_equals(scope->macro->token->text, exp->data.numb)) {
return true;
}
/* #define foo foo */
struct psi_decl_type *dtyp = exp->data.dtyp;
data->error(data, exp->token, PSI_WARNING,
- "Cannot compute sizeof(%s) (%u)", dtyp->name, dtyp->type);
+ "Cannot compute sizeof(%s) (%u)", dtyp->name->val, dtyp->type);
exp->type = PSI_T_UINT8;
exp->data.ival.u8 = 0;
{
zval *zc;
- if (*exp->data.numb == '\\') {
- zc = zend_get_constant_str(exp->data.numb + 1, strlen(exp->data.numb) - 1);
+ if (exp->data.numb->val[0] == '\\') {
+ zc = zend_get_constant_str(&exp->data.numb->val[1], exp->data.numb->len - 1);
} else {
- zc = zend_get_constant_str(exp->data.numb, strlen(exp->data.numb));
+ zc = zend_get_constant(exp->data.numb);
}
if (zc) {
switch (Z_TYPE_P(zc)) {
case IS_LONG:
- free(exp->data.numb);
+ zend_string_release(exp->data.numb);
exp->type = PSI_T_INT64;
exp->data.ival.i64 = Z_LVAL_P(zc);
return true;
case IS_DOUBLE:
- free(exp->data.numb);
+ zend_string_release(exp->data.numb);
exp->type = PSI_T_DOUBLE;
exp->data.ival.dval = Z_DVAL_P(zc);
return true;
}
}
while (psi_plist_get(data->consts, i++, &cnst)) {
- if (!strcmp(cnst->name, exp->data.numb)) {
- free(exp->data.numb);
+ if (zend_string_equals(cnst->name, exp->data.numb)) {
+ zend_string_release(exp->data.numb);
exp->type = PSI_T_CONST;
exp->data.cnst = cnst;
return true;
}
data->error(data, exp->token, PSI_WARNING,
"Unknown constant '%s' in numeric expression",
- exp->data.numb);
+ exp->data.numb->val);
return false;
case PSI_T_NUMBER:
{
switch (exp->data.cnst->type->type) {
case PSI_T_INT:
- res->i64 = zend_get_constant_str(exp->data.cnst->name,
- strlen(exp->data.cnst->name))->value.lval;
+ res->i64 = zend_get_constant(exp->data.cnst->name)->value.lval;
if (frame) PSI_DEBUG_PRINT(frame->context, " %" PRIi64, res->i64);
return PSI_T_INT64;
case PSI_T_FLOAT:
- res->dval = zend_get_constant_str(exp->data.cnst->name,
- strlen(exp->data.cnst->name))->value.dval;
+ res->dval = zend_get_constant(exp->data.cnst->name)->value.dval;
if (frame) PSI_DEBUG_PRINT(frame->context, " %" PRIdval, res->dval);
return PSI_T_DOUBLE;
default:
if (defs) {
struct psi_cpp_macro_decl *macro;
- macro = zend_hash_str_find_ptr(defs, exp->data.numb, strlen(exp->data.numb));
+ macro = zend_hash_find_ptr(defs, exp->data.numb);
if (macro && macro->exp && macro->exp != rec_guard) {
return psi_num_exp_exec(macro->exp, res, NULL, defs);
}
return PSI_T_INT64;
case PSI_T_NUMBER:
- res->i64 = atol(exp->data.numb);
+ res->i64 = atol(exp->data.numb->val);
return PSI_T_INT64;
case PSI_T_CONST:
token_t type;
unsigned flags;
union {
- char *numb;
+ zend_string *numb;
impl_val ival;
struct psi_const *cnst;
struct psi_decl_var *dvar;
struct psi_return_exp *exp = *exp_ptr;
*exp_ptr = NULL;
- if (exp->token) {
- psi_token_free(&exp->token);
- }
+ psi_token_free(&exp->token);
if (exp->func) {
psi_decl_var_free(&exp->func);
}
data->error(data, exp->token, PSI_WARNING,
"Argument count of return statement of implementation '%s'"
"does not match argument count of declaration '%s'",
- impl->func->name, impl->decl->func->var->name);
+ impl->func->name->val, impl->decl->func->var->name->val);
return false;
}
{
size_t i = 0;
struct psi_decl *decl;
- const char *name = psi_return_exp_get_decl_name(exp);
-
+ zend_string *name = psi_return_exp_get_decl_name(exp);
while (psi_plist_get(data->decls, i++, &decl)) {
- if (!strcmp(decl->func->var->name, name)) {
+ if (zend_string_equals(decl->func->var->name, name)) {
scope->impl->decl = decl;
if (psi_return_exp_validate_decl_args(data, exp, scope->impl)) {
scope->current_set = exp->set;
data->error(data, exp->token, PSI_WARNING,
"Missing declaration '%s' for `return` statement of implementation %s",
- name, scope->impl->func->name);
+ name->val, scope->impl->func->name->val);
return false;
}
-const char *psi_return_exp_get_decl_name(struct psi_return_exp *exp)
+zend_string *psi_return_exp_get_decl_name(struct psi_return_exp *exp)
{
return exp->func ? exp->func->name : exp->set->data.func->var->name;
}
struct psi_call_frame *frame);
bool psi_return_exp_validate(struct psi_data *data, struct psi_return_exp *exp,
struct psi_validate_scope *scope);
-const char *psi_return_exp_get_decl_name(struct psi_return_exp *exp);
+zend_string *psi_return_exp_get_decl_name(struct psi_return_exp *exp);
#endif /* RETURN_EXP_H */
struct psi_return_stmt *ret = *ret_ptr;
*ret_ptr = NULL;
- if (ret->token) {
- free(ret->token);
- }
+ psi_token_free(&ret->token);
psi_return_exp_free(&ret->exp);
free(ret);
}
data->error(data, ret->token, PSI_WARNING,
"Too many `return` statements for implementation %s;"
" found %zu, exactly one is required",
- scope->impl->func->name, count);
+ scope->impl->func->name->val, count);
return false;
case 0:
data->error(data, scope->impl->func->token, PSI_WARNING,
"Missing `return` statement for implementation %s",
- scope->impl->func->name);
+ scope->impl->func->name->val);
return false;
case 1:
break;
#include "calc.h"
#include "marshal.h"
+#include <Zend/zend_smart_str.h>
+
struct psi_set_exp *psi_set_exp_init(enum psi_set_exp_kind kind, void *data)
{
struct psi_set_exp *val = calloc(1, sizeof(*val));
if (set->var) {
/* parsed, or generated */
if (set->var->token) {
- dprintf(fd, "%s = ", set->var->name);
+ dprintf(fd, "%s = ", set->var->name->val);
}
}
}
if (set->var) {
- dprintf(fd, "\t/* fqn=%s */", set->var->fqn);
+ dprintf(fd, "\t/* fqn=%s */", set->var->fqn->val);
}
}
{
if (!exp->var) {
struct psi_decl_var *dvar = psi_set_exp_get_decl_var(exp);
- char *dollar_name;
+ zend_string *dollar_name;
+ smart_str name = {0};
if (!dvar) {
return NULL;
}
- dollar_name = psi_impl_var_name_prepend(strdup("$"), dvar->name);
+ smart_str_appendc_ex(&name, '$', 1);
+ smart_str_append_ex(&name, dvar->name, 1);
+ dollar_name = smart_str_extract(&name);
exp->var = psi_impl_var_init(dollar_name, 0);
- free(dollar_name);
+ zend_string_release(dollar_name);
}
return exp->var;
if (ivar && !psi_impl_var_validate(data, ivar, scope)) {
data->error(data, ivar->token ? : **(struct psi_token ***) &set->data,
- PSI_WARNING, "Unknown variable '%s'", ivar->name);
+ PSI_WARNING, "Unknown variable '%s'", ivar->name->val);
return false;
}
#include "php_psi_stdinc.h"
#include "data.h"
-struct psi_set_func *psi_set_func_init(token_t type, const char *name,
+struct psi_set_func *psi_set_func_init(token_t type, zend_string *name,
struct psi_decl_var *var)
{
struct psi_set_func *func = calloc(1, sizeof(*func));
func->type = type;
- func->name = strdup(name);
+ func->name = zend_string_copy(name);
func->var = var;
return func;
struct psi_set_func *func = *func_ptr;
*func_ptr = NULL;
- if (func->token) {
- free(func->token);
- }
+ psi_token_free(&func->token);
psi_decl_var_free(&func->var);
- free(func->name);
+ zend_string_release(func->name);
free(func);
}
}
void psi_set_func_dump(int fd, struct psi_set_func *func, unsigned level)
{
- dprintf(fd, "%s(", func->name);
+ dprintf(fd, "%s(", func->name->val);
psi_decl_var_dump(fd, func->var);
- dprintf(fd, "\t/* fqn=%s */", func->var->fqn);
+ dprintf(fd, "\t/* fqn=%s */", func->var->fqn->val);
if (func->inner && !func->recursive) {
size_t i = 0, count = psi_plist_count(func->inner);
struct psi_set_exp *inner;
PSI_WARNING, "Expected to_type() cast expression");
return false;
}
- if (strcmp(set_var->name, psi_set_exp_get_decl_var(sub_exp)->name)) {
+ if (!zend_string_equals(set_var->name, psi_set_exp_get_decl_var(sub_exp)->name)) {
/* no warning, because of ambiguity with a one-field-struct monstrosity */
goto complex;
}
PSI_WARNING, "Expected to_type() cast expression");
return false;
}
- if (strcmp(set_var->name, psi_set_exp_get_decl_var(sub_exp)->name)) {
+ if (!zend_string_equals(set_var->name, psi_set_exp_get_decl_var(sub_exp)->name)) {
data->error(data, **(struct psi_token ***) &sub_exp->data,
PSI_WARNING,
"Expected %s(%s) cast expression to reference the same"
" variable like the outer `set` statement, '%s'",
- sub_exp->data.func->name,
- psi_set_exp_get_decl_var(sub_exp)->name, set_var);
+ sub_exp->data.func->name->val,
+ psi_set_exp_get_decl_var(sub_exp)->name->val,
+ set_var->name->val);
return false;
}
func->handler = psi_set_to_array_counted;
data->error(data, func->token, PSI_WARNING,
"Expected struct or union type for complex to_array()"
" cast expression, got '%s'",
- set_var->arg->type->name);
+ set_var->arg->type->name->val);
return false;
}
func->handler = psi_set_to_array;
data->error(data, func->token, PSI_WARNING,
"Expected to_array() as parent to recursion in `set` statement"
" of implementation '%s'",
- impl->func->name);
+ impl->func->name->val);
return false;
}
&& !psi_impl_get_temp_let_arg(scope->impl, func->var)) {
data->error(data, func->var->token, PSI_WARNING,
"Unknown variable '%s' in implementation %s",
- func->var->name, scope->impl->func->name);
+ func->var->name->val, scope->impl->func->name->val);
return false;
}
default:
data->error(data, func->token, PSI_WARNING,
"Unknown cast '%s' in `set` statement of implementation '%s'",
- func->name, scope->impl->func->name);
+ func->name->val, scope->impl->func->name->val);
return false;
}
struct psi_set_func {
struct psi_token *token;
token_t type;
- char *name;
+ zend_string *name;
struct psi_decl_var *var;
psi_marshal_set handler;
struct psi_plist *inner;
unsigned recursive:1;
};
-struct psi_set_func *psi_set_func_init(token_t type, const char *name, struct psi_decl_var *var);
+struct psi_set_func *psi_set_func_init(token_t type, zend_string *name, struct psi_decl_var *var);
void psi_set_func_free(struct psi_set_func **func_ptr);
void psi_set_func_dump(int fd, struct psi_set_func *func, unsigned level);
bool psi_set_func_validate(struct psi_data *data, struct psi_set_func *func,
*set_ptr = NULL;
psi_set_exp_free(&set->exp);
- if (set->token) {
- free(set->token);
- }
+ psi_token_free(&set->token);
free(set);
}
}
if (!set->exp->var) {
data->error(data, set->token, PSI_WARNING,
"Missing variable of `set` statement of implementation '%s'",
- scope->impl->func->name);
+ scope->impl->func->name->val);
return false;
}
if (!psi_impl_get_arg(scope->impl, set->exp->var)) {
data->error(data, set->token, PSI_WARNING,
"Unknown variable '%s' of `set` statement of implementation '%s'",
- set->exp->var->name, scope->impl->func->name);
+ set->exp->var->name->val, scope->impl->func->name->val);
return false;
}
if (!psi_impl_get_temp_let_arg(scope->impl, set->exp->data.func->var)) {
data->error(data, set->token, PSI_WARNING,
"Unknown variable '%s' of `set` statement of implementation '%s'",
- set->exp->data.func->var->name, scope->impl->func->name);
+ set->exp->data.func->var->name->val, scope->impl->func->name->val);
scope->current_set = NULL;
return false;
}
{
struct psi_decl_arg *def = ptr;
- PSI_DEBUG_PRINT(dst, "typedef %s", def->var->name);
+ PSI_DEBUG_PRINT(dst, "typedef %s", def->var->name->val);
return psi_decl_arg_validate_typedef(dst, def, scope);
}
{
struct psi_decl_struct *str = ptr;
- PSI_DEBUG_PRINT(dst, "struct %s", str->name);
+ PSI_DEBUG_PRINT(dst, "struct %s", str->name->val);
if (psi_decl_struct_validate(dst, str, scope)) {
PSI_DEBUG_PRINT(dst, "::(%zu, %zu)", str->align, str->size);
return true;
{
struct psi_decl_union *unn = ptr;
- PSI_DEBUG_PRINT(dst, "union %s", unn->name);
+ PSI_DEBUG_PRINT(dst, "union %s", unn->name->val);
if (psi_decl_union_validate(dst, unn, scope)) {
PSI_DEBUG_PRINT(dst, "::(%zu, %zu)", unn->align, unn->size);
return true;
{
struct psi_decl_enum *enm = ptr;
- PSI_DEBUG_PRINT(dst, "enum %s", enm->name);
+ PSI_DEBUG_PRINT(dst, "enum %s", enm->name->val);
return psi_decl_enum_validate(dst, enm);
}
{
struct psi_decl_extvar *evar = ptr;
- PSI_DEBUG_PRINT(dst, "extvar %s", evar->arg->var->name);
+ PSI_DEBUG_PRINT(dst, "extvar %s", evar->arg->var->name->val);
if (psi_decl_extvar_validate(dst, evar, scope)) {
dst->decls = psi_plist_add(dst->decls, &evar->getter);
dst->decls = psi_plist_add(dst->decls, &evar->setter);
{
struct psi_decl *decl = ptr;
- PSI_DEBUG_PRINT(dst, "decl %s", decl->func->var->name);
+ PSI_DEBUG_PRINT(dst, "decl %s", decl->func->var->name->val);
return psi_decl_validate(dst, decl, scope);
}
{
struct psi_const *cnst = ptr;
- PSI_DEBUG_PRINT(dst, "constant %s", cnst->name);
+ PSI_DEBUG_PRINT(dst, "constant %s", cnst->name->val);
return psi_const_validate(dst, cnst, scope);
}
{
struct psi_impl *impl = ptr;
- PSI_DEBUG_PRINT(dst, "impl %s", impl->func->name);
+ PSI_DEBUG_PRINT(dst, "impl %s", impl->func->name->val);
return psi_impl_validate(dst, impl, scope);
}
}
#define psi_validate_scope_has_type(s, t) \
- ((s) ? zend_hash_str_exists(&(s)->types, (t), strlen(t)) : false)
+ ((s) ? zend_hash_exists(&(s)->types, (t)) : false)
#define psi_validate_scope_has_struct(s, t) \
- ((s) ? zend_hash_str_exists(&(s)->structs, (t), strlen(t)) : false)
+ ((s) ? zend_hash_exists(&(s)->structs, (t)) : false)
#define psi_validate_scope_has_union(s, t) \
- ((s) ? zend_hash_str_exists(&(s)->unions, (t), strlen(t)) : false)
+ ((s) ? zend_hash_exists(&(s)->unions, (t)) : false)
#define psi_validate_scope_add_type(s, t, p) \
- do { if (s) zend_hash_str_add_ptr(&(s)->types, (t), strlen(t), (p)); } while(0)
+ do { if (s) zend_hash_add_ptr(&(s)->types, (t), (p)); } while(0)
#define psi_validate_scope_add_struct(s, t, p) \
- do { if (s) zend_hash_str_add_ptr(&(s)->structs, (t), strlen(t), (p)); } while(0)
+ do { if (s) zend_hash_add_ptr(&(s)->structs, (t), (p)); } while(0)
#define psi_validate_scope_add_union(s, t, p) \
- do { if (s) zend_hash_str_add_ptr(&(s)->unions, (t), strlen(t), (p)); } while(0)
+ do { if (s) zend_hash_add_ptr(&(s)->unions, (t), (p)); } while(0)
#define psi_validate_scope_get_type(s, t) \
- ((s) ? zend_hash_str_find_ptr(&(s)->types, (t), strlen(t)) : NULL)
+ ((s) ? zend_hash_find_ptr(&(s)->types, (t)) : NULL)
#define psi_validate_scope_get_struct(s, t) \
- ((s) ? zend_hash_str_find_ptr(&(s)->structs, (t), strlen(t)) : NULL)
+ ((s) ? zend_hash_find_ptr(&(s)->structs, (t)) : NULL)
#define psi_validate_scope_get_union(s, t) \
- ((s) ? zend_hash_str_find_ptr(&(s)->unions, (t), strlen(t)) : NULL)
+ ((s) ? zend_hash_find_ptr(&(s)->unions, (t)) : NULL)
#define psi_validate_scope_del_type(s, t) \
- do { if (s) zend_hash_str_del(&(s)->types, (t), strlen(t)); } while(0)
+ do { if (s) zend_hash_del(&(s)->types, (t)); } while(0)
#define psi_validate_scope_del_struct(s, t) \
- do { if (s) zend_hash_str_del(&(s)->structs, (t), strlen(t)); } while(0)
+ do { if (s) zend_hash_del(&(s)->structs, (t)); } while(0)
#define psi_validate_scope_del_union(s, t) \
- do { if (s) zend_hash_str_del(&(s)->unions, (t), strlen(t)); } while(0)
+ do { if (s) zend_hash_del(&(s)->unions, (t)); } while(0)
#endif /* PSI_VALIDATE_H */