projects
/
m6w6
/
ext-psi
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
code structure
[m6w6/ext-psi]
/
src
/
parser.h
diff --git
a/src/parser.h
b/src/parser.h
index 8c25e88b221ce26e9e9dcc036de1d09b56f6e2ec..5582922453923a3a4ce8a0a1dc2e8e61577d1799 100644
(file)
--- a/
src/parser.h
+++ b/
src/parser.h
@@
-13,6
+13,8
@@
#define BSIZE 256
#define PSI_T_POINTER PSI_T_ASTERISK
#define BSIZE 256
#define PSI_T_POINTER PSI_T_ASTERISK
+#define PSI_T_LONG_DOUBLE (PSI_T_DOUBLE << 16)
+
typedef int token_t;
/* in php_psi.h */
typedef int token_t;
/* in php_psi.h */
@@
-21,7
+23,7
@@
size_t psi_t_size(token_t);
typedef struct PSI_Token {
token_t type;
typedef struct PSI_Token {
token_t type;
- unsigned size,
*
line;
+ unsigned size, line;
char *text, *file;
char buf[1];
} PSI_Token;
char *text, *file;
char buf[1];
} PSI_Token;
@@
-41,6
+43,9
@@
typedef union impl_val {
uint64_t u64;
float fval;
double dval;
uint64_t u64;
float fval;
double dval;
+#ifdef HAVE_LONG_DOUBLE
+ long double ldval;
+#endif
union {
zend_bool bval;
zend_long lval;
union {
zend_bool bval;
zend_long lval;
@@
-82,7
+87,7
@@
static inline decl_type *init_decl_type_ex(token_t type, int argc, ...) {
pos = all;
ptr = realloc(ptr, 1 + (all += len));
} else {
pos = all;
ptr = realloc(ptr, 1 + (all += len));
} else {
- ptr = malloc(
ptr,
1 + (all = len));
+ ptr = malloc(1 + (all = len));
}
memcpy(ptr + pos, arg, len);
}
}
memcpy(ptr + pos, arg, len);
}
@@
-318,7
+323,7
@@
typedef struct decl_callinfo {
void *info;
size_t argc;
void **args;
void *info;
size_t argc;
void **args;
- void *rval;
+ void *
*
rval;
} decl_callinfo;
typedef struct decl {
} decl_callinfo;
typedef struct decl {
@@
-375,6
+380,10
@@
typedef struct decl_struct {
char *name;
decl_args *args;
size_t size;
char *name;
decl_args *args;
size_t size;
+ struct {
+ void *type;
+ void (*dtor)(void *type);
+ } engine;
} decl_struct;
static inline decl_struct *init_decl_struct(const char *name, decl_args *args) {
} decl_struct;
static inline decl_struct *init_decl_struct(const char *name, decl_args *args) {
@@
-391,6
+400,9
@@
static inline void free_decl_struct(decl_struct *s) {
if (s->args) {
free_decl_args(s->args);
}
if (s->args) {
free_decl_args(s->args);
}
+ if (s->engine.type && s->engine.dtor) {
+ s->engine.dtor(s->engine.type);
+ }
free(s->name);
free(s);
}
free(s->name);
free(s);
}
@@
-1204,7
+1216,7
@@
static inline impl_val *enref_impl_val(void *ptr, decl_var *var) {
var->name, var->pointer_level, var->arg->var->pointer_level,
var->array_size, var->arg->var->array_size);
#endif
var->name, 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) {
+ if (!var->pointer_level
){//
&& real_decl_type(var->arg->type)->type != PSI_T_STRUCT) {
return ptr;
}
return ptr;
}
@@
-1287,7
+1299,7
@@
typedef struct PSI_Parser {
} PSI_Parser;
static inline size_t PSI_TokenAllocSize(size_t token_len, size_t fname_len) {
} PSI_Parser;
static inline size_t PSI_TokenAllocSize(size_t token_len, size_t fname_len) {
- return sizeof(PSI_Token) + token_len + fname_len +
sizeof(unsigned) +
2;
+ return sizeof(PSI_Token) + token_len + fname_len + 2;
}
static inline PSI_Token *PSI_TokenAlloc(PSI_Parser *P) {
}
static inline PSI_Token *PSI_TokenAlloc(PSI_Parser *P) {
@@
-1303,16
+1315,15
@@
static inline PSI_Token *PSI_TokenAlloc(PSI_Parser *P) {
token_len = P->cur - P->tok;
fname_len = strlen(P->psi.file.fn);
token_len = P->cur - P->tok;
fname_len = strlen(P->psi.file.fn);
- T = calloc(1, PSI_TokenAllocSize(token_len, fname_len);
+ T = calloc(1, PSI_TokenAllocSize(token_len, fname_len)
)
;
T->type = token_typ;
T->size = token_len;
T->text = &T->buf[0];
T->file = &T->buf[token_len + 1];
T->type = token_typ;
T->size = token_len;
T->text = &T->buf[0];
T->file = &T->buf[token_len + 1];
- T->line =
(void *) &T->buf[fname_len + token_len + 2]
;
+ T->line =
P->line
;
memcpy(T->text, P->tok, token_len);
memcpy(T->file, P->psi.file.fn, fname_len);
memcpy(T->text, P->tok, token_len);
memcpy(T->file, P->psi.file.fn, fname_len);
- memcpy(T->line, &P->line, sizeof(unsigned));
return T;
}
return T;
}
@@
-1339,12
+1350,14
@@
static inline PSI_Token *PSI_TokenCat(unsigned argc, ...) {
PSI_Token *arg = va_arg(argv, PSI_Token *);
if (T) {
PSI_Token *arg = va_arg(argv, PSI_Token *);
if (T) {
- size_t fname_len = strlen(T->file);
+ size_t
token_len = T->size,
fname_len = strlen(T->file);
- T = realloc(T, PSI_TokenAllocSize(T->size + arg->size, fname_len));
- memmove(&T->buf[T->size + 1], T->file, fname_len + 1);
- memcpy(T->file - 1, arg->text, arg->size + 1)
+ T = realloc(T, PSI_TokenAllocSize(T->size += arg->size + 1, fname_len));
+ T->text = &T->buf[0];
T->file = &T->buf[T->size + 1];
T->file = &T->buf[T->size + 1];
+ T->buf[token_len] = ' ';
+ memmove(&T->buf[T->size + 1], &T->buf[token_len + 1], fname_len + 1);
+ memcpy(&T->buf[token_len + 1], arg->text, arg->size + 1);
} else {
T = PSI_TokenCopy(arg);
T->type = PSI_T_NAME;
} else {
T = PSI_TokenCopy(arg);
T->type = PSI_T_NAME;