Remove preOptimize step from hphpc
[hiphop-php.git] / hphp / php7 / util.h
blobbea97f10963025fdb4ce11ebabe85dccaed5cb16
1 /*
2 +----------------------------------------------------------------------+
3 | HipHop for PHP |
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010- Facebook, Inc. (http://www.facebook.com) |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
17 #ifndef incl_HPHP_PHP7_UTIL_H
18 #define incl_HPHP_PHP7_UTIL_H
20 #include "hphp/php7/zend/zend.h"
22 namespace HPHP { namespace php7 {
24 // helpers to cope with these functions taking non-const pointers
25 // in zend_ast.h
27 inline const zval* zend_ast_get_zval(const zend_ast* ast) {
28 return &reinterpret_cast<const zend_ast_zval*>(ast)->val;
31 inline const zend_ast_list* zend_ast_get_list(const zend_ast* ast) {
32 return reinterpret_cast<const zend_ast_list*>(ast);
35 inline const zend_ast_decl* zend_ast_get_decl(const zend_ast* ast) {
36 return reinterpret_cast<const zend_ast_decl*>(ast);
39 inline std::string zval_to_string(const zval* zv) {
40 std::string out;
41 switch (Z_TYPE_P(zv)) {
42 case IS_LONG:
43 out.append(folly::to<std::string>(Z_LVAL_P(zv)));
44 break;
45 case IS_NULL:
46 case IS_FALSE:
47 break;
48 case IS_TRUE:
49 out.append("1");
50 break;
51 case IS_DOUBLE:
52 out.append(folly::to<std::string>(Z_DVAL_P(zv)));
53 break;
54 case IS_STRING:
55 out.append(Z_STRVAL_P(zv));
56 break;
58 return out;
61 }} // HPHP::php7
63 #endif // incl_HPHP_PHP7_UTIL_H