@@ -13,10 +13,11 @@ |
||
13 | 13 | { |
14 | 14 | $this->selector = VoidCore::getClass ($this->classname, $this->assembly); |
15 | 15 | |
16 | - if ($pid !== null) |
|
17 | - $this->selector = $pid == getmypid () ? |
|
16 | + if ($pid !== null) { |
|
17 | + $this->selector = $pid == getmypid () ? |
|
18 | 18 | VoidCore::callMethod ($this->selector, 'GetCurrentProcess') : |
19 | 19 | VoidCore::callMethod ($this->selector, 'GetProcessById', $pid); |
20 | + } |
|
20 | 21 | |
21 | 22 | Components::add ($this); |
22 | 23 | } |
@@ -31,15 +31,17 @@ discard block |
||
31 | 31 | $name = $node->args['name']; |
32 | 32 | $args = []; |
33 | 33 | |
34 | - if (isset (self::$objects[$name])) |
|
35 | - break; |
|
34 | + if (isset (self::$objects[$name])) { |
|
35 | + break; |
|
36 | + } |
|
36 | 37 | |
37 | 38 | if (isset ($node->args['args'])) |
38 | 39 | { |
39 | 40 | $args = $node->args['args']; |
40 | 41 | |
41 | - foreach ($args as $arg_id => $arg) |
|
42 | - $args[$arg_id] = self::formatLine ($arg, self::$objects); |
|
42 | + foreach ($args as $arg_id => $arg) { |
|
43 | + $args[$arg_id] = self::formatLine ($arg, self::$objects); |
|
44 | + } |
|
43 | 45 | } |
44 | 46 | |
45 | 47 | try |
@@ -49,15 +51,12 @@ discard block |
||
49 | 51 | try |
50 | 52 | { |
51 | 53 | self::$objects[$name]->name = $name; |
52 | - } |
|
53 | - |
|
54 | - catch (\Throwable $e) {} |
|
55 | - } |
|
56 | - |
|
57 | - catch (\Throwable $e) |
|
54 | + } catch (\Throwable $e) {} |
|
55 | + } catch (\Throwable $e) |
|
58 | 56 | { |
59 | - if (self::$throw_errors) |
|
60 | - throw new \Exception ('Interpeter couldn\'t create object "'. $class .'" with name "'. $name .'" at line "'. $node->line .'". Exception info:'. "\n\n". (string) $e, 0, $e); |
|
57 | + if (self::$throw_errors) { |
|
58 | + throw new \Exception ('Interpeter couldn\'t create object "'. $class .'" with name "'. $name .'" at line "'. $node->line .'". Exception info:'. "\n\n". (string) $e, 0, $e); |
|
59 | + } |
|
61 | 60 | } |
62 | 61 | break; |
63 | 62 | |
@@ -76,13 +75,15 @@ discard block |
||
76 | 75 | $use = $ouse = substr ($use, ($pos = strpos ($use, '(') + 1), strpos ($use, ')') - $pos); |
77 | 76 | $use = explode (' ', $use); |
78 | 77 | |
79 | - foreach ($use as $id => $useParam) |
|
80 | - if (isset (self::$objects[$useParam]) && $use[$id + 1][0] == '$') |
|
78 | + foreach ($use as $id => $useParam) { |
|
79 | + if (isset (self::$objects[$useParam]) && $use[$id + 1][0] == '$') |
|
81 | 80 | { |
82 | 81 | $fname = $use[$id + 1]; |
82 | + } |
|
83 | 83 | |
84 | - if (substr ($fname, strlen ($fname) - 1) == ',') |
|
85 | - $fname = substr ($fname, 0, -1); |
|
84 | + if (substr ($fname, strlen ($fname) - 1) == ',') { |
|
85 | + $fname = substr ($fname, 0, -1); |
|
86 | + } |
|
86 | 87 | |
87 | 88 | $preset .= "$fname = $useParam; "; |
88 | 89 | |
@@ -91,27 +92,26 @@ discard block |
||
91 | 92 | |
92 | 93 | $preset = self::formatLine ($preset, self::$objects); |
93 | 94 | $propertyValue = self::formatLine (str_replace ($ouse, implode (' ', $use), $propertyValue), self::$objects); |
95 | + } else { |
|
96 | + $propertyValue = self::formatLine ($propertyValue, self::$objects); |
|
94 | 97 | } |
95 | 98 | |
96 | - else $propertyValue = self::formatLine ($propertyValue, self::$objects); |
|
97 | - |
|
98 | 99 | try |
99 | 100 | { |
100 | - if (strpos ($propertyName, '->') !== false && self::$allow_multimethods_calls) |
|
101 | - eval ('namespace VoidEngine; '. $preset .' _c('. self::$objects[$name]->selector .')->'. $propertyName .' = '. $propertyValue .';'); |
|
102 | - |
|
103 | - else self::$objects[$name]->$propertyName = eval ("namespace VoidEngine; $preset return $propertyValue;"); |
|
104 | - } |
|
105 | - |
|
106 | - catch (\Throwable $e) |
|
101 | + if (strpos ($propertyName, '->') !== false && self::$allow_multimethods_calls) { |
|
102 | + eval ('namespace VoidEngine; '. $preset .' _c('. self::$objects[$name]->selector .')->'. $propertyName .' = '. $propertyValue .';'); |
|
103 | + } else { |
|
104 | + self::$objects[$name]->$propertyName = eval ("namespace VoidEngine; $preset return $propertyValue;"); |
|
105 | + } |
|
106 | + } catch (\Throwable $e) |
|
107 | 107 | { |
108 | - if (self::$throw_errors) |
|
109 | - throw new \Exception ('Interpeter couldn\'t set property "'. $propertyName .'" with value "'. $propertyValue .'" at line "'. $node->line .'". Exception info:'. "\n\n". (string) $e, 0, $e); |
|
108 | + if (self::$throw_errors) { |
|
109 | + throw new \Exception ('Interpeter couldn\'t set property "'. $propertyName .'" with value "'. $propertyValue .'" at line "'. $node->line .'". Exception info:'. "\n\n". (string) $e, 0, $e); |
|
110 | + } |
|
110 | 111 | } |
112 | + } elseif (self::$throw_errors) { |
|
113 | + throw new \Exception ('Setting property to an non-object at line "'. $node->line); |
|
111 | 114 | } |
112 | - |
|
113 | - elseif (self::$throw_errors) |
|
114 | - throw new \Exception ('Setting property to an non-object at line "'. $node->line); |
|
115 | 115 | break; |
116 | 116 | |
117 | 117 | case METHOD_CALL: |
@@ -122,29 +122,28 @@ discard block |
||
122 | 122 | $methodName = $node->args['name']; |
123 | 123 | $methodArgs = $node->args['args']; |
124 | 124 | |
125 | - foreach ($methodArgs as $arg_id => $arg) |
|
126 | - $methodArgs[$arg_id] = self::formatLine ($arg, self::$objects); |
|
125 | + foreach ($methodArgs as $arg_id => $arg) { |
|
126 | + $methodArgs[$arg_id] = self::formatLine ($arg, self::$objects); |
|
127 | + } |
|
127 | 128 | |
128 | 129 | try |
129 | 130 | { |
130 | - if (strpos ($methodName, '->') !== false && self::$allow_multimethods_calls) |
|
131 | - eval ('namespace VoidEngine; _c('. self::$objects[$name]->selector .')->'. $methodName .' ('. implode (', ', $methodArgs) .');'); |
|
132 | - |
|
133 | - elseif (sizeof ($methodArgs) > 0) |
|
134 | - self::$objects[$name]->$methodName (...eval ('namespace VoidEngine; return ['. implode (', ', $methodArgs) .'];')); |
|
135 | - |
|
136 | - else self::$objects[$name]->$methodName (); |
|
137 | - } |
|
138 | - |
|
139 | - catch (\Throwable $e) |
|
131 | + if (strpos ($methodName, '->') !== false && self::$allow_multimethods_calls) { |
|
132 | + eval ('namespace VoidEngine; _c('. self::$objects[$name]->selector .')->'. $methodName .' ('. implode (', ', $methodArgs) .');'); |
|
133 | + } elseif (sizeof ($methodArgs) > 0) { |
|
134 | + self::$objects[$name]->$methodName (...eval ('namespace VoidEngine; return ['. implode (', ', $methodArgs) .'];')); |
|
135 | + } else { |
|
136 | + self::$objects[$name]->$methodName (); |
|
137 | + } |
|
138 | + } catch (\Throwable $e) |
|
140 | 139 | { |
141 | - if (self::$throw_errors) |
|
142 | - throw new \Exception ('Interpeter couldn\'t call method "'. $methodName .'" with arguments '. json_encode ($methodArgs) .' at line "'. $node->line .'". Exception info:'. "\n\n". (string) $e, 0, $e); |
|
140 | + if (self::$throw_errors) { |
|
141 | + throw new \Exception ('Interpeter couldn\'t call method "'. $methodName .'" with arguments '. json_encode ($methodArgs) .' at line "'. $node->line .'". Exception info:'. "\n\n". (string) $e, 0, $e); |
|
142 | + } |
|
143 | 143 | } |
144 | + } elseif (self::$throw_errors) { |
|
145 | + throw new \Exception ('Calling method to an non-object at line "'. $node->line .'"'); |
|
144 | 146 | } |
145 | - |
|
146 | - elseif (self::$throw_errors) |
|
147 | - throw new \Exception ('Calling method to an non-object at line "'. $node->line .'"'); |
|
148 | 147 | break; |
149 | 148 | |
150 | 149 | case STYLES_IMPORTING: |
@@ -152,8 +151,9 @@ discard block |
||
152 | 151 | { |
153 | 152 | $path = eval ('namespace VoidEngine; return '. self::formatLine ($style, self::$objects) .';'); |
154 | 153 | |
155 | - if (!file_exists ($path)) |
|
156 | - throw new \Exception ('Trying to import nonexistent style at line "'. $node->line .'"'); |
|
154 | + if (!file_exists ($path)) { |
|
155 | + throw new \Exception ('Trying to import nonexistent style at line "'. $node->line .'"'); |
|
156 | + } |
|
157 | 157 | |
158 | 158 | \VLF\VST\Interpreter::run (\VLF\VST\Parser::parse (file_get_contents ($path))); |
159 | 159 | } |
@@ -166,12 +166,13 @@ discard block |
||
166 | 166 | |
167 | 167 | $nodes = $node->getNodes (); |
168 | 168 | |
169 | - if (isset ($node->args['styles'])) |
|
170 | - foreach ($node->args['styles'] as $style) |
|
169 | + if (isset ($node->args['styles'])) { |
|
170 | + foreach ($node->args['styles'] as $style) |
|
171 | 171 | if (isset (\VLF\VST\Interpreter::$styles[$style])) |
172 | 172 | $nodes = array_merge ($nodes, \VLF\VST\Interpreter::$styles[$style]); |
173 | - |
|
174 | - else throw new \Exception ('Trying to set undefined style to object at line "'. $node->line .'"'); |
|
173 | + } else { |
|
174 | + throw new \Exception ('Trying to set undefined style to object at line "'. $node->line .'"'); |
|
175 | + } |
|
175 | 176 | |
176 | 177 | self::$objects = self::run (new AST (array_map ( |
177 | 178 | fn ($node) => $node->export (), $nodes)), $node); |
@@ -211,8 +212,9 @@ discard block |
||
211 | 212 | |
212 | 213 | $nReplacement = []; |
213 | 214 | |
214 | - foreach ($replacement as $replaceTo => $nLn) |
|
215 | - $nReplacement[$omap[$replaceTo]] = $replaceTo; |
|
215 | + foreach ($replacement as $replaceTo => $nLn) { |
|
216 | + $nReplacement[$omap[$replaceTo]] = $replaceTo; |
|
217 | + } |
|
216 | 218 | |
217 | 219 | $replacement = $nReplacement; |
218 | 220 | $blacklist = array_flip (['\'', '"', '$']); |
@@ -221,10 +223,11 @@ discard block |
||
221 | 223 | { |
222 | 224 | $replaced = false; |
223 | 225 | |
224 | - foreach ($replacement as $name => $replaceAt) |
|
225 | - if (substr ($line, $i, ($l = strlen ($name))) == $name && !isset ($blacklist[$line[$i - 1]])) |
|
226 | + foreach ($replacement as $name => $replaceAt) { |
|
227 | + if (substr ($line, $i, ($l = strlen ($name))) == $name && !isset ($blacklist[$line[$i - 1]])) |
|
226 | 228 | { |
227 | 229 | $newLine .= $replaceAt; |
230 | + } |
|
228 | 231 | |
229 | 232 | $i += $l - 1; |
230 | 233 | $replaced = true; |
@@ -232,8 +235,9 @@ discard block |
||
232 | 235 | break; |
233 | 236 | } |
234 | 237 | |
235 | - if (!$replaced) |
|
236 | - $newLine .= $line[$i]; |
|
238 | + if (!$replaced) { |
|
239 | + $newLine .= $line[$i]; |
|
240 | + } |
|
237 | 241 | } |
238 | 242 | |
239 | 243 | $line = $newLine; |
@@ -35,11 +35,12 @@ |
||
35 | 35 | $name = $node->args['name']; |
36 | 36 | $nodes = $node->getNodes (); |
37 | 37 | |
38 | - if ($node->args['parents'] !== null) |
|
39 | - foreach ($node->args['parents'] as $parent) |
|
38 | + if ($node->args['parents'] !== null) { |
|
39 | + foreach ($node->args['parents'] as $parent) |
|
40 | 40 | { |
41 | 41 | if (!isset (self::$styles[$parent]) && self::$throw_errors) |
42 | 42 | throw new \Exception ('Style "'. $parent .'" not founded'); |
43 | + } |
|
43 | 44 | |
44 | 45 | $nodes = array_merge (self::$styles[$parent], $nodes); |
45 | 46 | } |