Skip to content

Commit

Permalink
Fixing str_replace optimizer, improved parser to support any kind of …
Browse files Browse the repository at this point in the history
…keys expressions when creating arrays
  • Loading branch information
andresgutierrez committed Oct 24, 2014
1 parent b66b227 commit 46881c1
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Library/Compiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*/
class Compiler
{
const VERSION = '0.5.5a';
const VERSION = '0.5.6a';

/**
* @var CompilerFile[]
Expand Down
2 changes: 1 addition & 1 deletion Library/Optimizers/FunctionCall/StrReplaceOptimizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function optimize(array $expression, Call $call, CompilationContext $cont
$symbolVariable->setDynamicTypes('string');

$resolvedParams = $call->getReadOnlyResolvedParams($expression['parameters'], $context, $expression);
$context->codePrinter->output('zephir_fast_str_replace(' . $symbolVariable->getName() . ', ' . $resolvedParams[0] . ', ' . $resolvedParams[1] . ', ' . $resolvedParams[2] . ');');
$context->codePrinter->output('zephir_fast_str_replace(' . $symbolVariable->getName() . ', ' . $resolvedParams[0] . ', ' . $resolvedParams[1] . ', ' . $resolvedParams[2] . ' TSRMLS_CC);');
return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression);
}
}
2 changes: 1 addition & 1 deletion ext/kernel/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ void zephir_fast_stripos_str(zval *return_value, zval *haystack, char *needle, u
/**
* Immediate function resolution for str_replace function
*/
void zephir_fast_str_replace(zval *return_value, zval *search, zval *replace, zval *subject) {
void zephir_fast_str_replace(zval *return_value, zval *search, zval *replace, zval *subject TSRMLS_DC) {

zval replace_copy, search_copy;
int copy_replace = 0, copy_search = 0;
Expand Down
2 changes: 1 addition & 1 deletion ext/kernel/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void zephir_fast_explode_str(zval *result, const char *delimiter, int delimiter_
void zephir_fast_strpos(zval *return_value, const zval *haystack, const zval *needle, unsigned int offset);
void zephir_fast_strpos_str(zval *return_value, const zval *haystack, char *needle, unsigned int needle_length);
void zephir_fast_stripos_str(zval *return_value, zval *haystack, char *needle, unsigned int needle_length);
void zephir_fast_str_replace(zval *return_value, zval *search, zval *replace, zval *subject);
void zephir_fast_str_replace(zval *return_value, zval *search, zval *replace, zval *subject TSRMLS_DC);
void zephir_fast_trim(zval *return_value, zval *str, zval *charlist, int where TSRMLS_DC);
void zephir_fast_strip_tags(zval *return_value, zval *str);
void zephir_fast_strtoupper(zval *return_value, zval *str);
Expand Down
16 changes: 2 additions & 14 deletions parser/parser.lemon
Original file line number Diff line number Diff line change
Expand Up @@ -2988,20 +2988,8 @@ xx_array_item(R) ::= xx_array_value(V) . {
R = xx_ret_array_item(NULL, V, status->scanner_state);
}

xx_array_key(R) ::= CONSTANT(I) . {
R = xx_ret_literal(XX_T_CONSTANT, I, status->scanner_state);
}

xx_array_key(R) ::= IDENTIFIER(I) . {
R = xx_ret_literal(XX_T_IDENTIFIER, I, status->scanner_state);
}

xx_array_key(R) ::= STRING(S) . {
R = xx_ret_literal(XX_T_STRING, S, status->scanner_state);
}

xx_array_key(R) ::= INTEGER(I) . {
R = xx_ret_literal(XX_T_INTEGER, I, status->scanner_state);
xx_array_key(R) ::= xx_common_expr(E) . {
R = E;
}

xx_array_value(R) ::= xx_common_expr(E) . {
Expand Down

0 comments on commit 46881c1

Please sign in to comment.