Skip to content

Commit

Permalink
Merge branch 'master' of http://github.com/phalcon/zephir
Browse files Browse the repository at this point in the history
  • Loading branch information
andresgutierrez committed Oct 21, 2014
2 parents 4dfbb7d + d7ee4c6 commit edd567a
Show file tree
Hide file tree
Showing 36 changed files with 62 additions and 48 deletions.
4 changes: 2 additions & 2 deletions Library/Expression.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public function emptyArray($expression, CompilationContext $compilationContext)
/**
* Variable that receives property accesses must be polimorphic
*/
if ($symbolVariable->getType() != 'variable' && $symbolVariable->getType() != 'array') {
if (!$symbolVariable->isVariable() && $symbolVariable->getType() != 'array') {
throw new CompilerException("Cannot use variable: " . $symbolVariable->getName() . '(' . $symbolVariable->getType() . ") to create empty array", $expression);
}

Expand Down Expand Up @@ -276,7 +276,7 @@ public function compileTypeHint($expression, CompilationContext $compilationCont
}

$symbolVariable = $compilationContext->symbolTable->getVariableForRead($resolved->getCode(), $compilationContext, $expression);
if ($symbolVariable->getType() != 'variable') {
if (!$symbolVariable->isVariable()) {
throw new CompilerException("Type-Hints only can be applied to dynamic variables", $expression);
}

Expand Down
2 changes: 1 addition & 1 deletion Library/Expression/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public function compile(array $expression, CompilationContext $compilationContex
$symbolVariable = $compilationContext->symbolTable->getTempVariableForWrite('variable', $compilationContext, $expression);
}

if ($symbolVariable->getType() != 'variable') {
if (!$symbolVariable->isVariable()) {
throw new CompilerException('Cannot use variable: ' . $symbolVariable->getType() . ' to assign property value', $expression);
}

Expand Down
2 changes: 1 addition & 1 deletion Library/Expression/NativeArrayAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ protected function _accessDimensionArray($expression, Variable $variableVariable
/**
* Variable that receives property accesses must be polimorphic
*/
if ($symbolVariable->getType() != 'variable') {
if (!$symbolVariable->isVariable()) {
throw new CompilerException("Cannot use variable: " . $symbolVariable->getType() . " to assign array index", $expression);
}

Expand Down
2 changes: 1 addition & 1 deletion Library/Expression/PropertyAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ public function compile($expression, CompilationContext $compilationContext)
/**
* Variable that receives a property value must be polimorphic
*/
if ($symbolVariable->getType() != 'variable') {
if (!$symbolVariable->isVariable()) {
throw new CompilerException("Cannot use variable: " . $symbolVariable->getType() . " to assign property value", $expression);
}

Expand Down
2 changes: 1 addition & 1 deletion Library/Expression/PropertyDynamicAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public function compile($expression, CompilationContext $compilationContext)
/**
* Variable that receives a property value must be polymorphic
*/
if ($symbolVariable->getType() != 'variable') {
if ($symbolVariable && !$symbolVariable->isVariable()) {
throw new CompilerException("Cannot use variable: " . $symbolVariable->getType() . " to assign property value", $expression);
}

Expand Down
2 changes: 1 addition & 1 deletion Library/Expression/StaticConstantAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public function compile($expression, CompilationContext $compilationContext)
/**
* Variable that receives property accesses must be polimorphic
*/
if ($symbolVariable->getType() != 'variable') {
if (!$symbolVariable->isVariable()) {
throw new CompilerException("Cannot use variable: " . $symbolVariable->getType() . " to assign class constants", $expression);
}

Expand Down
2 changes: 1 addition & 1 deletion Library/Expression/StaticPropertyAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public function compile($expression, CompilationContext $compilationContext)
/**
* Variable that receives property accesses must be polimorphic
*/
if ($symbolVariable->getType() != 'variable') {
if (!$symbolVariable->isVariable()) {
throw new CompilerException("Cannot use variable: " . $symbolVariable->getType() . " to assign class constants", $expression);
}

Expand Down
6 changes: 2 additions & 4 deletions Library/FunctionCall.php
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,7 @@ protected function _callNormal(array $expression, $compilationContext)
*/
$symbolVariable = $this->getSymbolVariable();
if ($symbolVariable) {

if ($symbolVariable->getType() != 'variable') {
if (!$symbolVariable->isVariable()) {
throw new CompilerException("Returned values by functions can only be assigned to variant variables", $expression);
}

Expand Down Expand Up @@ -472,8 +471,7 @@ protected function _callDynamic(array $expression, $compilationContext)
*/
$symbolVariable = $this->getSymbolVariable();
if ($symbolVariable) {

if ($symbolVariable->getType() != 'variable') {
if (!$symbolVariable->isVariable()) {
throw new CompilerException("Returned values by functions can only be assigned to variant variables", $expression);
}

Expand Down
4 changes: 1 addition & 3 deletions Library/MethodCall.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,8 @@ public function compile(Expression $expr, CompilationContext $compilationContext
* Method calls only return zvals so we need to validate the target variable is also a zval
*/
if (!$builtInType) {

if ($isExpecting) {

if ($symbolVariable->getType() != 'variable') {
if (!$symbolVariable->isVariable()) {
throw new CompilerException("Returned values by functions can only be assigned to variant variables", $expression);
}

Expand Down
2 changes: 1 addition & 1 deletion Library/Operators/Other/CloneOperator.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function compile($expression, CompilationContext $compilationContext)
}

$symbolVariable = $this->getExpected($compilationContext, $expression);
if ($symbolVariable->getType() != 'variable') {
if (!$symbolVariable->isVariable()) {
throw new CompilerException("Objects can only be cloned into dynamic variables", $expression);
}

Expand Down
2 changes: 1 addition & 1 deletion Library/Operators/Other/InstanceOfOperator.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function compile($expression, CompilationContext $compilationContext)
}

$symbolVariable = $compilationContext->symbolTable->getVariableForRead($resolved->getCode(), $compilationContext, $expression);
if ($symbolVariable->getType() != 'variable') {
if (!$symbolVariable->isVariable()) {
throw new CompilerException("InstanceOf requires a 'dynamic variable' in the left operand", $expression);
}

Expand Down
3 changes: 1 addition & 2 deletions Library/Operators/Other/NewInstanceOperator.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ public function compile(array $expression, CompilationContext $compilationContex
* Resolves the symbol that expects the value
*/
$symbolVariable = $this->getExpected($compilationContext, $expression);

if ($symbolVariable->getType() != 'variable') {
if (!$symbolVariable->isVariable()) {
throw new CompilerException("Objects can only be instantiated into dynamic variables", $expression);
}

Expand Down
2 changes: 1 addition & 1 deletion Library/Optimizers/FunctionCall/ArrayKeysOptimizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function optimize(array $expression, Call $call, CompilationContext $cont
$call->processExpectedReturn($context);

$symbolVariable = $call->getSymbolVariable();
if ($symbolVariable->getType() != 'variable') {
if (!$symbolVariable->isVariable()) {
throw new CompilerException("Returned values by functions can only be assigned to variant variables", $expression);
}

Expand Down
2 changes: 1 addition & 1 deletion Library/Optimizers/FunctionCall/ArrayMergeOptimizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function optimize(array $expression, Call $call, CompilationContext $cont
$call->processExpectedReturn($context);

$symbolVariable = $call->getSymbolVariable();
if ($symbolVariable->getType() != 'variable') {
if (!$symbolVariable->isVariable()) {
throw new CompilerException("Returned values by functions can only be assigned to variant variables", $expression);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function optimize(array $expression, Call $call, CompilationContext $cont

$symbolVariable = $call->getSymbolVariable();
if ($symbolVariable) {
if ($symbolVariable->getType() != 'variable') {
if (!$symbolVariable->isVariable()) {
throw new CompilerException("Returned values by functions can only be assigned to variant variables", $expression);
}
if ($call->mustInitSymbolVariable()) {
Expand Down
2 changes: 1 addition & 1 deletion Library/Optimizers/FunctionCall/CreateArrayOptimizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function optimize(array $expression, Call $call, CompilationContext $cont
$call->processExpectedReturn($context);

$symbolVariable = $call->getSymbolVariable();
if ($symbolVariable->getType() != 'variable') {
if (!$symbolVariable->isVariable()) {
throw new CompilerException("Returned values by functions can only be assigned to variant variables", $expression);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function optimize(array $expression, Call $call, CompilationContext $cont
$call->processExpectedReturn($context);

$symbolVariable = $call->getSymbolVariable();
if ($symbolVariable->getType() != 'variable') {
if (!$symbolVariable->isVariable()) {
throw new CompilerException("Returned values by functions can only be assigned to variant variables", $expression);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function optimize(array $expression, Call $call, CompilationContext $cont
$call->processExpectedReturn($context);

$symbolVariable = $call->getSymbolVariable();
if ($symbolVariable->getType() != 'variable') {
if (!$symbolVariable->isVariable()) {
throw new CompilerException("Returned values by functions can only be assigned to variant variables", $expression);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function optimize(array $expression, Call $call, CompilationContext $cont

$symbolVariable = $call->getSymbolVariable();
if ($symbolVariable) {
if ($symbolVariable->getType() != 'variable') {
if (!$symbolVariable->isVariable()) {
throw new CompilerException("Returned values by functions can only be assigned to variant variables", $expression);
}
}
Expand Down
2 changes: 1 addition & 1 deletion Library/Optimizers/FunctionCall/JsonDecodeOptimizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function optimize(array $expression, Call $call, CompilationContext $cont

$symbolVariable = $call->getSymbolVariable();
if ($symbolVariable) {
if ($symbolVariable->getType() != 'variable') {
if (!$symbolVariable->isVariable()) {
throw new CompilerException("Returned values by functions can only be assigned to variant variables", $expression);
}
if ($call->mustInitSymbolVariable()) {
Expand Down
2 changes: 1 addition & 1 deletion Library/Optimizers/FunctionCall/JsonEncodeOptimizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function optimize(array $expression, Call $call, CompilationContext $cont

$symbolVariable = $call->getSymbolVariable();
if ($symbolVariable) {
if ($symbolVariable->getType() != 'variable') {
if (!$symbolVariable->isVariable()) {
throw new CompilerException("Returned values by functions can only be assigned to variant variables", $expression);
}
if ($call->mustInitSymbolVariable()) {
Expand Down
2 changes: 1 addition & 1 deletion Library/Optimizers/FunctionCall/PregMatchOptimizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function optimize(array $expression, Call $call, CompilationContext $cont

$symbolVariable = $call->getSymbolVariable();
if ($symbolVariable) {
if ($symbolVariable->getType() != 'variable') {
if (!$symbolVariable->isVariable()) {
throw new CompilerException("Returned values by functions can only be assigned to variant variables", $expression);
}
if ($call->mustInitSymbolVariable()) {
Expand Down
2 changes: 1 addition & 1 deletion Library/Optimizers/FunctionCall/VarExportOptimizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function optimize(array $expression, Call $call, CompilationContext $cont

$symbolVariable = $call->getSymbolVariable();
if ($symbolVariable) {
if ($symbolVariable->getType() != 'variable') {
if (!$symbolVariable->isVariable()) {
throw new CompilerException("Returned values by functions can only be assigned to variant variables", $expression);
}
if ($call->mustInitSymbolVariable()) {
Expand Down
2 changes: 1 addition & 1 deletion Library/Statements/Let/ArrayIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ public function assign($variable, ZephirVariable $symbolVariable, CompiledExpres
/**
* Only dynamic variables can be used as arrays
*/
if ($symbolVariable->getType() != 'variable' && $symbolVariable->getType() != 'array') {
if ($symbolVariable->isNotVariableAndArray()) {
throw new CompilerException("Cannot use variable type: '" . $symbolVariable->getType() . "' as array", $statement);
}

Expand Down
2 changes: 1 addition & 1 deletion Library/Statements/Let/ArrayIndexAppend.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public function assign($variable, ZephirVariable $symbolVariable, CompiledExpres
/**
* Only dynamic variables can be used as arrays
*/
if ($symbolVariable->getType() != 'variable') {
if (!$symbolVariable->isVariable()) {
throw new CompilerException("Cannot use variable type: '" . $symbolVariable->getType() . "' as array", $statement);
}

Expand Down
4 changes: 2 additions & 2 deletions Library/Statements/Let/ObjectDynamicProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function assign($variable, ZephirVariable $symbolVariable, CompiledExpres
throw new CompilerException("Cannot mutate variable '" . $variable . "' because it is not initialized", $statement);
}

if ($symbolVariable->getType() != 'variable') {
if (!$symbolVariable->isVariable()) {
throw new CompilerException("Variable type '" . $symbolVariable->getType() . "' cannot be used as object", $statement);
}

Expand All @@ -67,7 +67,7 @@ public function assign($variable, ZephirVariable $symbolVariable, CompiledExpres
throw new CompilerException("Cannot mutate static property '" . $compilationContext->classDefinition->getCompleteName() . "::" . $propertyName . "' because it is not initialized", $statement);
}

if ($symbolVariable->getType() != 'variable') {
if (!$symbolVariable->isVariable()) {
throw new CompilerException("Cannot use variable type: " . $symbolVariable->getType() . " as an object", $statement);
}

Expand Down
4 changes: 2 additions & 2 deletions Library/Statements/Let/ObjectProperty.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function assign($variable, ZephirVariable $symbolVariable, CompiledExpres
throw new CompilerException("Cannot mutate variable '" . $variable . "' because it is not initialized", $statement);
}

if ($symbolVariable->getType() != 'variable') {
if (!$symbolVariable->isVariable()) {
throw new CompilerException("Variable type '" . $symbolVariable->getType() . "' cannot be used as object", $statement);
}

Expand All @@ -63,7 +63,7 @@ public function assign($variable, ZephirVariable $symbolVariable, CompiledExpres
throw new CompilerException("Cannot mutate static property '" . $className . "::" . $propertyName . "' because it is not initialized", $statement);
}

if ($symbolVariable->getType() != 'variable') {
if (!$symbolVariable->isVariable()) {
throw new CompilerException("Cannot use variable type: " . $symbolVariable->getType() . " as an object", $statement);
}

Expand Down
2 changes: 1 addition & 1 deletion Library/Statements/Let/ObjectPropertyAppend.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function assign($variable, ZephirVariable $symbolVariable, CompiledExpres
throw new CompilerException("Cannot mutate variable '" . $variable . "' because it is not initialized", $statement);
}

if ($symbolVariable->getType() != 'variable') {
if (!$symbolVariable->isVariable()) {
throw new CompilerException("Attempt to use variable type: " . $symbolVariable->getType() . " as object", $statement);
}

Expand Down
2 changes: 1 addition & 1 deletion Library/Statements/Let/ObjectPropertyArrayIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ public function assign($variable, ZephirVariable $symbolVariable, CompiledExpres
throw new CompilerException("Cannot mutate variable '" . $variable . "' because it is not initialized", $statement);
}

if ($symbolVariable->getType() != 'variable') {
if (!$symbolVariable->isVariable()) {
throw new CompilerException("Attempt to use variable type: " . $symbolVariable->getType() . " as object", $statement);
}

Expand Down
2 changes: 1 addition & 1 deletion Library/Statements/Let/ObjectPropertyArrayIndexAppend.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public function assign($variable, ZephirVariable $symbolVariable, CompiledExpres
throw new CompilerException("Cannot mutate variable '" . $variable . "' because it is not initialized", $statement);
}

if ($symbolVariable->getType() != 'variable') {
if (!$symbolVariable->isVariable()) {
throw new CompilerException("Attempt to use variable type: " . $symbolVariable->getType() . " as object", $statement);
}

Expand Down
2 changes: 1 addition & 1 deletion Library/Statements/Let/ObjectPropertyDecr.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function assign($variable, $property, ZephirVariable $symbolVariable, Com
/**
* Only dynamic variables can be used as arrays
*/
if ($symbolVariable->getType() != 'variable') {
if (!$symbolVariable->isVariable()) {
throw new CompilerException("Cannot use variable type: '" . $symbolVariable->getType() . "' as array", $statement);
}

Expand Down
2 changes: 1 addition & 1 deletion Library/Statements/Let/ObjectPropertyIncr.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function assign($variable, $property, ZephirVariable $symbolVariable, Com
/**
* Only dynamic variables can be used as arrays
*/
if ($symbolVariable->getType() != 'variable') {
if (!$symbolVariable->isVariable()) {
throw new CompilerException("Cannot use variable type: '" . $symbolVariable->getType() . "' as array", $statement);
}

Expand Down
4 changes: 2 additions & 2 deletions Library/Statements/Let/Variable.php
Original file line number Diff line number Diff line change
Expand Up @@ -1056,7 +1056,7 @@ public function assign($variable, ZephirVariable $symbolVariable, CompiledExpres
$compilationContext->symbolTable->mustGrownStack(true);

/* Inherit the dynamic type data from the assigned value */
$symbolVariable->setDynamicTypes($itemVariable->getDynamicTypes());
$symbolVariable->setDynamicTypes(array_keys($itemVariable->getDynamicTypes()));
$symbolVariable->setClassTypes($itemVariable->getClassTypes());

$codePrinter->output('ZEPHIR_CPY_WRT(' . $variable . ', ' . $itemVariable->getName() . ');');
Expand Down Expand Up @@ -1097,7 +1097,7 @@ public function assign($variable, ZephirVariable $symbolVariable, CompiledExpres
$compilationContext->symbolTable->mustGrownStack(true);

/* Inherit the dynamic type data from the assigned value */
$symbolVariable->setDynamicTypes($itemVariable->getDynamicTypes());
$symbolVariable->setDynamicTypes(array_keys($itemVariable->getDynamicTypes()));
$symbolVariable->setClassTypes($itemVariable->getClassTypes());

$codePrinter->output('ZEPHIR_CPY_WRT(' . $variable . ', ' . $itemVariable->getName() . ');');
Expand Down
2 changes: 1 addition & 1 deletion Library/Statements/Let/VariableAppend.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function assign($variable, ZephirVariable $symbolVariable, CompiledExpres
throw new CompilerException("Cannot mutate variable '" . $variable . "' because it is local only", $statement);
}

if ($symbolVariable->getType() != 'variable') {
if (!$symbolVariable->isVariable()) {
throw new CompilerException("Cannot use variable type: '" . $symbolVariable->getType() . "' as array", $statement);
}

Expand Down
2 changes: 1 addition & 1 deletion Library/StaticCall.php
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ public function compile(Expression $expr, CompilationContext $compilationContext
*/
$symbolVariable->setDynamicTypes('undefined');

if ($symbolVariable->getType() != 'variable') {
if (!$symbolVariable->isVariable()) {
throw new CompilerException("Returned values by functions can only be assigned to variant variables", $expression);
}
}
Expand Down
Loading

0 comments on commit edd567a

Please sign in to comment.