Skip to content

Commit

Permalink
Remove TSRMLS_CC support from statements
Browse files Browse the repository at this point in the history
See: #1865
  • Loading branch information
sergeyklay committed Oct 17, 2019
1 parent 24ccef9 commit 73c30cc
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 28 deletions.
6 changes: 3 additions & 3 deletions Library/Statements/ForStatement.php
Expand Up @@ -474,10 +474,10 @@ public function compileIterator(array $exprRaw, CompilationContext $compilationC
*/
++$compilationContext->insideCycle;

$codePrinter->output($iteratorVariable->getName().' = zephir_get_iterator('.$compilationContext->backend->getVariableCode($exprVariable).' TSRMLS_CC);');
$codePrinter->output($iteratorVariable->getName().' = zephir_get_iterator('.$compilationContext->backend->getVariableCode($exprVariable).');');

$codePrinter->output($iteratorVariable->getName().'->funcs->rewind('.$iteratorVariable->getName().' TSRMLS_CC);');
$codePrinter->output('for (;'.$iteratorVariable->getName().'->funcs->valid('.$iteratorVariable->getName().' TSRMLS_CC) == SUCCESS && !EG(exception); '.$iteratorVariable->getName().'->funcs->move_forward('.$iteratorVariable->getName().' TSRMLS_CC)) {');
$codePrinter->output($iteratorVariable->getName().'->funcs->rewind('.$iteratorVariable->getName().');');
$codePrinter->output('for (;'.$iteratorVariable->getName().'->funcs->valid('.$iteratorVariable->getName().') == SUCCESS && !EG(exception); '.$iteratorVariable->getName().'->funcs->move_forward('.$iteratorVariable->getName().' TSRMLS_CC)) {');

if (isset($this->statement['key'])) {
$compilationContext->symbolTable->mustGrownStack(true);
Expand Down
2 changes: 1 addition & 1 deletion Library/Statements/Let/ExportSymbol.php
Expand Up @@ -64,7 +64,7 @@ public function assign($variable, ZephirVariable $symbolVariable, CompiledExpres
$symbol = $compilationContext->backend->getVariableCode($symbolVariable);
$variable = $compilationContext->backend->getVariableCode($variable);

$codePrinter->output('if (zephir_set_symbol('.$symbol.', '.$variable.' TSRMLS_CC) == FAILURE) {');
$codePrinter->output('if (zephir_set_symbol('.$symbol.', '.$variable.') == FAILURE) {');
$codePrinter->output("\t".'return;');
$codePrinter->output('}');
}
Expand Down
2 changes: 1 addition & 1 deletion Library/Statements/Let/ExportSymbolString.php
Expand Up @@ -62,7 +62,7 @@ public function assign($variable, ZephirVariable $symbolVariable = null, Compile
$letStatement->compile($compilationContext);

$symbol = $compilationContext->backend->getVariableCode($variable);
$codePrinter->output('if (zephir_set_symbol_str(SS("'.$statement['variable'].'"), '.$symbol.' TSRMLS_CC) == FAILURE) {');
$codePrinter->output('if (zephir_set_symbol_str(SS("'.$statement['variable'].'"), '.$symbol.') == FAILURE) {');
$codePrinter->output(' return;');
$codePrinter->output('}');
}
Expand Down
14 changes: 3 additions & 11 deletions Library/Statements/Let/ObjectProperty.php
Expand Up @@ -178,23 +178,15 @@ public function assign($variable, ZephirVariable $symbolVariable, CompiledExpres
break;

case 'string':
if ('ZendEngine2' == $compilationContext->backend->getName()) {
$tempVariable = $compilationContext->symbolTable->getTempNonTrackedVariable('variable', $compilationContext);
} else {
$tempVariable = $compilationContext->symbolTable->getTempVariableForWrite('variable', $compilationContext, false);
}
$tempVariable = $compilationContext->symbolTable->getTempVariableForWrite('variable', $compilationContext, false);

switch ($statement['operator']) {
case 'concat-assign':
$codePrinter->output('zephir_concat_self_str(&'.$tempVariable->getName().', "'.$resolvedExpr->getCode().'", sizeof("'.$resolvedExpr->getCode().'")-1 TSRMLS_CC);');
$codePrinter->output('zephir_concat_self_str(&'.$tempVariable->getName().', "'.$resolvedExpr->getCode().'", sizeof("'.$resolvedExpr->getCode().'") - 1);');
break;
case 'assign':
/* We only can use nonReferenced variables for not refcounted stuff in ZE3 */
if ('ZendEngine2' == $compilationContext->backend->getName()) {
$tempVariable->initNonReferenced($compilationContext);
} else {
$tempVariable->initVariant($compilationContext);
}
$tempVariable->initVariant($compilationContext);
$compilationContext->backend->assignString($tempVariable, $resolvedExpr->getCode(), $compilationContext);
break;
}
Expand Down
2 changes: 1 addition & 1 deletion Library/Statements/Let/ObjectPropertyDecr.php
Expand Up @@ -100,6 +100,6 @@ public function assign($variable, $property, ZephirVariable $symbolVariable, Com
}

$compilationContext->headersManager->add('kernel/object');
$compilationContext->codePrinter->output('RETURN_ON_FAILURE(zephir_property_decr('.$symbolVariable->getName().', SL("'.$property.'") TSRMLS_CC));');
$compilationContext->codePrinter->output('RETURN_ON_FAILURE(zephir_property_decr('.$symbolVariable->getName().', SL("'.$property.'")));');
}
}
2 changes: 1 addition & 1 deletion Library/Statements/Let/ObjectPropertyIncr.php
Expand Up @@ -100,6 +100,6 @@ public function assign($variable, $property, ZephirVariable $symbolVariable, Com
}

$compilationContext->headersManager->add('kernel/object');
$compilationContext->codePrinter->output('RETURN_ON_FAILURE(zephir_property_incr('.$symbolVariable->getName().', SL("'.$property.'") TSRMLS_CC));');
$compilationContext->codePrinter->output('RETURN_ON_FAILURE(zephir_property_incr('.$symbolVariable->getName().', SL("'.$property.'")));');
}
}
4 changes: 2 additions & 2 deletions Library/Statements/Let/StaticProperty.php
Expand Up @@ -196,7 +196,7 @@ public function assignStatic($className, $property, CompiledExpression $resolved
$propertyCache = $compilationContext->symbolTable->getTempVariableForWrite('zend_property_info', $compilationContext);
$propertyCache->setMustInitNull(true);
$propertyCache->setReusable(false);
$codePrinter->output('zephir_update_static_property_ce_cache('.$classEntry.', SL("'.$property.'"), &'.$tempVariable->getName().', &'.$propertyCache->getName().' TSRMLS_CC);');
$codePrinter->output('zephir_update_static_property_ce_cache('.$classEntry.', SL("'.$property.'"), &'.$tempVariable->getName().', &'.$propertyCache->getName().');');
} else {
$compilationContext->backend->updateStaticProperty($classEntry, $property, $tempVariable, $compilationContext);
}
Expand All @@ -212,7 +212,7 @@ public function assignStatic($className, $property, CompiledExpression $resolved
$propertyCache = $compilationContext->symbolTable->getTempVariableForWrite('zend_property_info', $compilationContext);
$propertyCache->setMustInitNull(true);
$propertyCache->setReusable(false);
$codePrinter->output('zephir_update_static_property_ce_cache('.$classEntry.', SL("'.$property.'"), &'.$tempVariable->getName().', &'.$propertyCache->getName().' TSRMLS_CC);');
$codePrinter->output('zephir_update_static_property_ce_cache('.$classEntry.', SL("'.$property.'"), &'.$tempVariable->getName().', &'.$propertyCache->getName().');');
} else {
$compilationContext->backend->updateStaticProperty($classEntry, $property, $tempVariable, $compilationContext);
}
Expand Down
12 changes: 6 additions & 6 deletions Library/Statements/Let/Variable.php
Expand Up @@ -573,7 +573,7 @@ private function doStringAssignment(
$compilationContext->backend->assignString($symbolVariable, $resolvedExpr->getCode(), $compilationContext);
break;
case 'concat-assign':
$codePrinter->output('zephir_concat_self_str(&'.$variable.', "'.$resolvedExpr->getCode().'", sizeof("'.$resolvedExpr->getCode().'")-1 TSRMLS_CC);');
$codePrinter->output('zephir_concat_self_str(&'.$variable.', "'.$resolvedExpr->getCode().'", sizeof("'.$resolvedExpr->getCode().'") - 1);');
break;
default:
throw new IllegalOperationException($statement, $resolvedExpr);
Expand All @@ -591,7 +591,7 @@ private function doStringAssignment(
}
break;
case 'concat-assign':
$codePrinter->output('zephir_concat_self_str(&'.$variable.', "'.$resolvedExpr->getCode().'", sizeof("'.$resolvedExpr->getCode().'")-1 TSRMLS_CC);');
$codePrinter->output('zephir_concat_self_str(&'.$variable.', "'.$resolvedExpr->getCode().'", sizeof("'.$resolvedExpr->getCode().'") - 1);');
break;
default:
throw new IllegalOperationException($statement, $resolvedExpr);
Expand All @@ -612,7 +612,7 @@ private function doStringAssignment(

case 'concat-assign':
$compilationContext->headersManager->add('kernel/operators');
$codePrinter->output('zephir_concat_self_str(&'.$variable.', "'.$resolvedExpr->getCode().'", sizeof("'.$resolvedExpr->getCode().'")-1 TSRMLS_CC);');
$codePrinter->output('zephir_concat_self_str(&'.$variable.', "'.$resolvedExpr->getCode().'", sizeof("'.$resolvedExpr->getCode().'") - 1);');
break;

default:
Expand All @@ -637,7 +637,7 @@ private function doStringAssignment(

case 'concat-assign':
$compilationContext->headersManager->add('kernel/operators');
$codePrinter->output('zephir_concat_self_long(&'.$variable.', '.$itemVariable->getName().' TSRMLS_CC);');
$codePrinter->output('zephir_concat_self_long(&'.$variable.', '.$itemVariable->getName().');');
break;

default:
Expand All @@ -657,7 +657,7 @@ private function doStringAssignment(

case 'concat-assign':
$compilationContext->headersManager->add('kernel/operators');
$codePrinter->output('zephir_concat_self_char(&'.$variable.', '.$itemVariable->getName().' TSRMLS_CC);');
$codePrinter->output('zephir_concat_self_char(&'.$variable.', '.$itemVariable->getName().');');
break;

default:
Expand Down Expand Up @@ -1101,7 +1101,7 @@ private function doVariableAssignment(

case 'concat-assign':
$compilationContext->headersManager->add('kernel/operators');
$codePrinter->output('zephir_concat_self_str(&'.$variable.', SL("'.$resolvedExpr->getCode().'") TSRMLS_CC);');
$codePrinter->output('zephir_concat_self_str(&'.$variable.', SL("'.$resolvedExpr->getCode().'"));');
break;

default:
Expand Down
2 changes: 1 addition & 1 deletion Library/Statements/ThrowStatement.php
Expand Up @@ -127,7 +127,7 @@ public function compile(CompilationContext $compilationContext)
$line = $statement['expr']['line'];

$codePrinter->output(
'zephir_throw_exception_debug('.$variableCode.', "'.$file.'", '.$line.' TSRMLS_CC);'
'zephir_throw_exception_debug('.$variableCode.', "'.$file.'", '.$line.');'
);

if (!$compilationContext->insideTryCatch) {
Expand Down
2 changes: 1 addition & 1 deletion Library/Statements/UnsetStatement.php
Expand Up @@ -56,7 +56,7 @@ public function compile(CompilationContext $compilationContext)
$variableCode = $compilationContext->backend->getVariableCode($variable);

$compilationContext->headersManager->add('kernel/object');
$compilationContext->codePrinter->output('zephir_unset_property('.$variableCode.', "'.$expression['right']['value'].'" TSRMLS_CC);');
$compilationContext->codePrinter->output('zephir_unset_property('.$variableCode.', "'.$expression['right']['value'].'");');

return true;

Expand Down

0 comments on commit 73c30cc

Please sign in to comment.