Pastakhov has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/89392


Change subject: small cleaning up
......................................................................

small cleaning up

Time: 233 ms, Memory: 21.00Mb
OK (256 tests, 258 assertions)

Change-Id: Ifbbf8819a83802f6b73574c93f4b4fe47bc4f44d
---
M includes/Compiler.php
M tests/phpunit/includes/RuntimeTest.php
2 files changed, 13 insertions(+), 34 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Foxway 
refs/changes/92/89392/1

diff --git a/includes/Compiler.php b/includes/Compiler.php
index be05e1e..979cc5a 100644
--- a/includes/Compiler.php
+++ b/includes/Compiler.php
@@ -329,13 +329,6 @@
                                                        
ksort($incompleteOperators[$parentLevel]);
                                                        unset($operator);
                                                        $operator = array( 
FOXWAY_STACK_COMMAND=>$id, FOXWAY_STACK_RESULT=>null, 
FOXWAY_STACK_PARAM=>&$lastValue[FOXWAY_STACK_RESULT], 
FOXWAY_STACK_TOKEN_LINE=>$tokenLine );
-                                                       /*if( $values ) {
-                                                               
$math[$parentLevel][$precedence][] = $values[0];
-                                                               if( 
isset($values[1]) ) {
-                                                                       
$math[$parentLevel][$precedence][] = $values[1];
-                                                               }
-                                                               $values = 
array();
-                                                       }*/
                                                }
                                        }else{ // This is first operator
                                                $operator = array( 
FOXWAY_STACK_COMMAND=>$id, FOXWAY_STACK_RESULT=>null, 
FOXWAY_STACK_PARAM=>&$lastValue[FOXWAY_STACK_RESULT], 
FOXWAY_STACK_TOKEN_LINE=>$tokenLine );
@@ -430,7 +423,8 @@
                                                $parentFlags |= 
FOXWAY_EQUAL_HAVE_OPERATOR;
                                                $operPrec = 
self::$precedencesMatrix[$operator[FOXWAY_STACK_COMMAND]];
                                                if( $values ) {
-                                                       
$math[$parentLevel][$operPrec] = isset($math[$parentLevel][$operPrec]) ? 
array_merge( $math[$parentLevel][$operPrec], $values ) : $values;
+                                                       $stack = 
array_merge($stack, $values);
+                                                       $values = array();
                                                }
                                                $stack[] = &$operator;
                                                if( 
isset($incompleteOperators[$parentLevel]) ) {
@@ -529,16 +523,8 @@
                                                        unset($lastValue);
                                                        $lastValue = 
&$needParams[0];
                                                        
array_shift($needParams);
-                                                       switch ( 
$lastValue[FOXWAY_STACK_COMMAND] ) {
-                                                               case 
T_VARIABLE: // @todo there is variable only
-                                                                       
$lastValue[FOXWAY_STACK_ARRAY_INDEX][] = &$operator[FOXWAY_STACK_RESULT];
-                                                                       
$stack[] = &$lastValue;
-                                                                       break;
-//                                                             case T_INC:
-//                                                             case T_DEC:
-//                                                                     
$lastValue[FOXWAY_STACK_PARAM][FOXWAY_STACK_ARRAY_INDEX][] = 
&$operator[FOXWAY_STACK_RESULT];
-//                                                                     break;
-                                                       }
+                                                       
$lastValue[FOXWAY_STACK_ARRAY_INDEX][] = &$operator[FOXWAY_STACK_RESULT]; // 
$lastValue must be T_VARIABLE only
+                                                       $stack[] = &$lastValue;
                                                        unset($operator);
                                                        if( $parentFlags & 
FOXWAY_NEED_RESTORE_OPERATOR ) {
                                                                $operator = 
array_pop( $memOperators );
@@ -868,19 +854,12 @@
                                        $stack = array();
 
                                        if( isset($lastValue) ) {
-                                               switch ( 
$lastValue[FOXWAY_STACK_COMMAND] ) {
-                                                       case T_VARIABLE: // 
@todo there is variable only
-//                                                     case T_INC:
-//                                                     case T_DEC:
-                                                               array_unshift( 
$needParams, &$lastValue );
-                                                               $values = 
array();
-                                                               
unset($lastValue);
-//                                                             $values = 
array();
-                                                               break;
-                                                       default:
-                                                               throw new 
ExceptionFoxway($id, FOXWAY_PHP_SYNTAX_ERROR_UNEXPECTED, $tokenLine);
-                                                               break;
+                                               if( 
$lastValue[FOXWAY_STACK_COMMAND] != T_VARIABLE ) {
+                                                       throw new 
ExceptionFoxway($id, FOXWAY_PHP_SYNTAX_ERROR_UNEXPECTED, $tokenLine);
                                                }
+                                               array_unshift( $needParams, 
&$lastValue );
+                                               $values = array();
+                                               unset($lastValue);
                                        }else{ // $foo = [
                                                // @todo
                                                throw new ExceptionFoxway($id, 
FOXWAY_PHP_SYNTAX_ERROR_UNEXPECTED, $tokenLine);
diff --git a/tests/phpunit/includes/RuntimeTest.php 
b/tests/phpunit/includes/RuntimeTest.php
index b4bc879..4d0a9ea 100644
--- a/tests/phpunit/includes/RuntimeTest.php
+++ b/tests/phpunit/includes/RuntimeTest.php
@@ -332,25 +332,25 @@
                                Runtime::runSource('$foo=1; echo $foo++ + $foo 
= 40 + $foo = 400 + $foo, $foo;'), // $foo = 400 + 2; $foo = 40 + 402; echo 1 + 
442, 442
                                array('443', '442')
                                );
-       }
+       }*/
        public function testRun_echo_math_variables_short_circuit_1() {
                $this->assertEquals(
                                Runtime::runSource('$foo=10; echo $foo = 400 + 
$foo or $foo = 10000, $foo;'), // $foo = 400 + 10; echo 441 or ... , 410
                                array(true, '410')
                                );
-       }
+       }/*
        public function testRun_echo_math_variables_short_circuit_2() {
                $this->assertEquals(
                                Runtime::runSource('$foo=10; echo $foo = 10 - 
$foo or $foo = 10000, $foo;'), // $foo = 10 - 10; echo 0 or $foo=10000 , 10000
                                array(true, '10000')
                                );
-       }
+       }*/
        public function testRun_echo_math_variables_5() {
                $this->assertEquals(
                                Runtime::runSource('$foo=10; echo $foo = 400 + 
$foo | $foo = 10000, $foo;'), // $foo = 400 + 10 | 10000; echo 10138, 10138
                                array('10138', '10138')
                                );
-       }*/
+       }
 
        public function testRun_echo_math_union_1() {
                $this->assertEquals(

-- 
To view, visit https://gerrit.wikimedia.org/r/89392
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifbbf8819a83802f6b73574c93f4b4fe47bc4f44d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Foxway
Gerrit-Branch: develop
Gerrit-Owner: Pastakhov <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to