Page MenuHomePhabricator

Output stack and state changes - JavaScriptMinifier.php.diff

Authored By
Krinkle
Aug 10 2018, 11:03 PM
Size
1 KB
Referenced Files
None
Subscribers
None

Output stack and state changes - JavaScriptMinifier.php.diff

diff --git a/includes/libs/JavaScriptMinifier.php b/includes/libs/JavaScriptMinifier.php
index d87a3fdcdf..f778983c9f 100644
--- a/includes/libs/JavaScriptMinifier.php
+++ b/includes/libs/JavaScriptMinifier.php
@@ -713,12 +713,17 @@ class JavaScriptMinifier {
$newlineFound = false;
// Now that we have output our token, transition into the new state.
+ echo "\n| stack | " . implode('>', array_map( 'self::getConstName', $stack ) );
+ echo "\n| token: `$token`";
if ( isset( $push[$state][$type] ) && count( $stack ) < self::STACK_LIMIT ) {
+ echo " | action = stack_push " . self::getConstName( $push[$state][$type] );
$stack[] = $push[$state][$type];
}
if ( $stack && isset( $pop[$state][$type] ) ) {
+ echo " | action = stack_pop";
$state = array_pop( $stack );
} elseif ( isset( $goto[$state][$type] ) ) {
+ echo " | action = goto " . self::getConstName( $goto[$state][$type] );
$state = $goto[$state][$type];
}
}
@@ -729,4 +734,13 @@ class JavaScriptMinifier {
// TODO: Handle the error: trigger_error, throw exception, return false...
return false;
}
+
+ private static function getConstName( $constVal ) {
+ $theClass = new ReflectionClass( self::class );
+ foreach ( $theClass->getConstants() as $name => $value ) {
+ if ( $value === $constVal ) {
+ return $name;
+ }
+ }
+ }
}

File Metadata

Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
6265034
Default Alt Text
Output stack and state changes - JavaScriptMinifier.php.diff (1 KB)

Event Timeline