OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************/
-#include "php_psi_stdinc.h"
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#else
+# include "php_config.h"
+#endif
#include "data.h"
-struct psi_const *psi_const_init(struct psi_const_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));
+ struct psi_const *c = pecalloc(1, sizeof(*c), 1);
+
+ 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);
c->val = val;
return c;
}
struct psi_const *constant = *constant_ptr;
*constant_ptr = NULL;
- if (constant->token) {
- free(constant->token);
- }
- psi_const_type_free(&constant->type);
- free(constant->name);
+ psi_token_free(&constant->token);
+ psi_impl_type_free(&constant->type);
+ zend_string_release(constant->name);
psi_impl_def_val_free(&constant->val);
free(constant);
}
}
-void psi_const_dump(int fd, struct psi_const *cnst)
+void psi_const_dump(struct psi_dump *dump, struct psi_const *cnst)
{
- dprintf(fd, "const ");
- psi_const_type_dump(fd, cnst->type);
- dprintf(fd, " %s = ", cnst->name);
- psi_impl_def_val_dump(fd, cnst->val);
- dprintf(fd, ";");
+ PSI_DUMP(dump, "const ");
+ if (cnst->type) {
+ psi_impl_type_dump(dump, cnst->type);
+ }
+ PSI_DUMP(dump, " %s = ", cnst->name->val);
+ psi_impl_def_val_dump(dump, cnst->val);
+ PSI_DUMP(dump, ";");
}
-bool psi_const_validate(struct psi_data *data, struct psi_const *c)
+bool psi_const_validate(struct psi_data *data, struct psi_const *c,
+ struct psi_validate_scope *scope)
{
- /* FIXME */
+ if (!psi_impl_def_val_validate(data, c->val, c->type, scope)) {
+ return false;
+ }
return true;
}