improved type validation
[m6w6/ext-psi] / src / types / assert_stmt.h
1 /*******************************************************************************
2 Copyright (c) 2017, Michael Wallner <mike@php.net>.
3 All rights reserved.
4
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7
8 * Redistributions of source code must retain the above copyright notice,
9 this list of conditions and the following disclaimer.
10 * Redistributions in binary form must reproduce the above copyright
11 notice, this list of conditions and the following disclaimer in the
12 documentation and/or other materials provided with the distribution.
13
14 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
18 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
21 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 *******************************************************************************/
25
26 #ifndef PSI_TYPES_ASSERT_STMT_H
27 #define PSI_TYPES_ASSERT_STMT_H
28
29 struct psi_token;
30 struct psi_data;
31 struct psi_impl;
32 struct psi_num_exp;
33 struct psi_call_frame;
34
35 enum psi_assert_kind {
36 PSI_ASSERT_PRE = PSI_T_PRE_ASSERT,
37 PSI_ASSERT_POST = PSI_T_POST_ASSERT
38 };
39
40 struct psi_assert_stmt {
41 struct psi_token *token;
42 struct psi_num_exp *exp;
43 enum psi_assert_kind kind;
44 };
45
46 struct psi_assert_stmt *psi_assert_stmt_init(enum psi_assert_kind kind, struct psi_num_exp *exp);
47 bool psi_assert_stmt_exec(struct psi_assert_stmt *stmt, struct psi_call_frame *frame);
48
49 void psi_assert_stmt_dump(int fd, struct psi_assert_stmt *stmt);
50 void psi_assert_stmt_free(struct psi_assert_stmt **stmt);
51
52 bool psi_assert_stmts_validate(struct psi_data *data, struct psi_impl *impl);
53
54 char *psi_assert_stmt_message(struct psi_assert_stmt *stmt);
55
56 #endif