This repository has been archived by the owner on Nov 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
blocks.c
110 lines (92 loc) · 3.19 KB
/
blocks.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/*
+--------------------------------------------------------------------------+
| Zephir Language |
+--------------------------------------------------------------------------+
| Copyright (c) 2013-2014 Zephir Team and contributors |
+--------------------------------------------------------------------------+
| This source file is subject the MIT license, that is bundled with |
| this package in the file LICENSE, and is available through the |
| world-wide-web at the following url: |
| http://zephir-lang.com/license.html |
| |
| If you did not receive a copy of the MIT license and are unable |
| to obtain it through the world-wide-web, please send a note to |
| license@zephir-lang.com so we can mail you a copy immediately. |
+--------------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <php.h>
#include "php_zephir.h"
#include "zephir.h"
#include "utils.h"
#include "kernel/main.h"
#include "statements/echo.h"
#include "statements/if.h"
#include "statements/while.h"
#include "statements/loop.h"
#include "statements/let.h"
#include "statements/declare.h"
#include "statements/return.h"
#include "statements/break.h"
LLVMValueRef zephir_compile_block(zephir_context *context, zval *statements TSRMLS_DC)
{
HashTable *ht = Z_ARRVAL_P(statements);
HashPosition pos = {0};
zval **statement, *type;
context->is_unrecheable = 0;
zend_hash_internal_pointer_reset_ex(ht, &pos);
for (
; zend_hash_get_current_data_ex(ht, (void**) &statement, &pos) == SUCCESS
; zend_hash_move_forward_ex(ht, &pos)
) {
_zephir_array_fetch_string(&type, *statement, SS("type") TSRMLS_CC);
if (Z_TYPE_P(type) != IS_STRING) {
continue;
}
if (!memcmp(Z_STRVAL_P(type), SS("if"))) {
context->is_unrecheable = 0;
zephir_statement_if(context, *statement);
continue;
}
if (!memcmp(Z_STRVAL_P(type), SS("echo"))) {
context->is_unrecheable = 0;
zephir_statement_echo(context, *statement);
continue;
}
if (!memcmp(Z_STRVAL_P(type), SS("let"))) {
context->is_unrecheable = 0;
zephir_statement_let(context, *statement);
continue;
}
if (!memcmp(Z_STRVAL_P(type), SS("declare"))) {
context->is_unrecheable = 0;
zephir_statement_declare(context, *statement);
continue;
}
if (!memcmp(Z_STRVAL_P(type), SS("return"))) {
context->is_unrecheable = 1;
zephir_statement_return(context, *statement);
break;
}
if (!memcmp(Z_STRVAL_P(type), SS("while"))) {
context->is_unrecheable = 0;
zephir_statement_while(context, *statement);
continue;
}
if (!memcmp(Z_STRVAL_P(type), SS("loop"))) {
context->is_unrecheable = 0;
zephir_statement_loop(context, *statement);
continue;
}
if (!memcmp(Z_STRVAL_P(type), SS("break"))) {
context->is_unrecheable = 1;
zephir_statement_break(context, *statement);
continue;
}
zend_print_zval_r(*statement, 0 TSRMLS_CC);
continue;
}
return NULL;
}