Code view:

A painting is a person's account of this edit as text, recorded independently of the node mapping - a rendering often has several equally defensible answers where the mapping has one. Deletions and insertions carry no position on the opposite side in a painting, so that panel draws no caret for them.

Before

…lines 1–704 unchanged (704 lines)
705 break;
706 case Token.MUL:
707 result = lval * rval;
708 break;
709 case Token.MOD:
710 if (rval == 0) {
711 error(DiagnosticType.error("JSC_DIVIDE_BY_0_ERROR", "Divide by 0"), right);
712 return null;
713 }
714 result = lval % rval;
715 break;
716 case Token.DIV:
717 if (rval == 0) {
718 error(DiagnosticType.error("JSC_DIVIDE_BY_0_ERROR", "Divide by 0"), right);
719 return null;
720 }
721 result = lval / rval;
722 break;
723 default:
724 throw new Error("Unexpected arithmetic operator");
…lines 725–1631 unchanged (907 lines)

After

…lines 1–704 unchanged (704 lines)
705 break;
706 case Token.MUL:
707 result = lval * rval;
708 break;
709 case Token.MOD:
710 if (rval == 0) {
711 return null;
712 }
713 result = lval % rval;
714 break;
715 case Token.DIV:
716 if (rval == 0) {
717 return null;
718 }
719 result = lval / rval;
720 break;
721 default:
722 throw new Error("Unexpected arithmetic operator");
723 }
…lines 724–1629 unchanged (906 lines)

Before

program
block_comment "/*\n * Copyright 2004 The Closure Compiler Authors.\n *\n * Lic"...
package_declaration
package "package"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "jscomp"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "common"
. "."
identifier "base"
. "."
identifier "Preconditions"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "common"
. "."
identifier "collect"
. "."
identifier "Lists"
; ";"
import_declaration (+22 nodes collapsed)
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "rhino"
. "."
identifier "Node"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "rhino"
. "."
identifier "Token"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "rhino"
. "."
identifier "jstype"
. "."
identifier "TernaryValue"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "List"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "Locale"
; ";"
block_comment "/**\n * Peephole optimization to fold constants (e.g. x + 1 +"...
class_declaration
class "class"
identifier "PeepholeFoldConstants"
superclass
extends "extends"
type_identifier "AbstractPeepholeOptimization"
class_body
{ "{"
field_declaration (+25 nodes collapsed)
field_declaration (+25 nodes collapsed)
field_declaration (+25 nodes collapsed)
field_declaration (+25 nodes collapsed)
field_declaration (+25 nodes collapsed)
field_declaration (+25 nodes collapsed)
field_declaration (+21 nodes collapsed)
line_comment "// The LOCALE independent \"locale\""
field_declaration
modifiers
private "private"
static "static"
final "final"
type_identifier "Locale"
variable_declarator
identifier "ROOT_LOCALE"
= "="
object_creation_expression
new "new"
type_identifier "Locale"
argument_list
( "("
string_literal
" "\""
" "\""
) ")"
; ";"
method_declaration (+169 nodes collapsed)
method_declaration (+458 nodes collapsed)
method_declaration (+106 nodes collapsed)
method_declaration (+317 nodes collapsed)
method_declaration (+68 nodes collapsed)
method_declaration (+370 nodes collapsed)
block_comment "/**\n * Folds 'typeof(foo)' if foo is a literal, e.g.\n * "...
method_declaration (+351 nodes collapsed)
method_declaration (+696 nodes collapsed)
block_comment "/**\n * Try to fold {@code left instanceof right} into {@co"...
method_declaration (+214 nodes collapsed)
method_declaration (+518 nodes collapsed)
block_comment "/**\n * Try to fold a AND/OR node.\n */"
method_declaration (+207 nodes collapsed)
block_comment "/**\n * Expressions such as [foo() + 'a' + 'b'] generate pa"...
method_declaration (+408 nodes collapsed)
block_comment "/**\n * Try to fold an ADD node with constant operands\n *"...
method_declaration (+155 nodes collapsed)
block_comment "/**\n * Try to fold arithmetic binary operators\n */"
method_declaration (+99 nodes collapsed)
block_comment "/**\n * Try to fold arithmetic binary operators\n */"
method_declaration
modifiers
private "private"
type_identifier "Node"
identifier "performArithmeticOp"
formal_parameters
( "("
formal_parameter
integral_type
int "int"
identifier "opType"
, ","
formal_parameter
type_identifier "Node"
identifier "left"
, ","
formal_parameter
type_identifier "Node"
identifier "right"
) ")"
block
{ "{"
line_comment "// Unlike other operations, ADD operands are not always conv"...
line_comment "// to Number."
if_statement (+46 nodes collapsed)
local_variable_declaration
floating_point_type
double "double"
variable_declarator
identifier "result"
; ";"
line_comment "// TODO(johnlenz): Handle NaN with unknown value. BIT ops co"...
line_comment "// to zero so this is a little akward here."
local_variable_declaration
type_identifier "Double"
variable_declarator
identifier "lValObj"
= "="
method_invocation
identifier "NodeUtil"
. "."
identifier "getNumberValue"
argument_list
( "("
identifier "left"
) ")"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "lValObj"
== "=="
null_literal "null"
) ")"
block
{ "{"
return_statement
return "return"
null_literal "null"
; ";"
} "}"
local_variable_declaration
type_identifier "Double"
variable_declarator
identifier "rValObj"
= "="
method_invocation
identifier "NodeUtil"
. "."
identifier "getNumberValue"
argument_list
( "("
identifier "right"
) ")"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "rValObj"
== "=="
null_literal "null"
) ")"
block
{ "{"
return_statement
return "return"
null_literal "null"
; ";"
} "}"
local_variable_declaration
floating_point_type
double "double"
variable_declarator
identifier "lval"
= "="
identifier "lValObj"
; ";"
local_variable_declaration
floating_point_type
double "double"
variable_declarator
identifier "rval"
= "="
identifier "rValObj"
; ";"
switch_expression
switch "switch"
parenthesized_expression
( "("
identifier "opType"
) ")"
switch_block
{ "{"
switch_block_statement_group (+34 nodes collapsed)
switch_block_statement_group (+34 nodes collapsed)
switch_block_statement_group (+34 nodes collapsed)
switch_block_statement_group
switch_label
case "case"
field_access
identifier "Token"
. "."
identifier "ADD"
: ":"
expression_statement
assignment_expression
identifier "result"
= "="
binary_expression
identifier "lval"
+ "+"
identifier "rval"
; ";"
break_statement
break "break"
; ";"
switch_block_statement_group
switch_label
case "case"
field_access
identifier "Token"
. "."
identifier "SUB"
: ":"
expression_statement
assignment_expression
identifier "result"
= "="
binary_expression
identifier "lval"
- "-"
identifier "rval"
; ";"
break_statement
break "break"
; ";"
switch_block_statement_group
switch_label
case "case"
field_access
identifier "Token"
. "."
identifier "MUL"
: ":"
expression_statement
assignment_expression
identifier "result"
= "="
binary_expression
identifier "lval"
* "*"
identifier "rval"
; ";"
break_statement
break "break"
; ";"
switch_block_statement_group
switch_label
case "case"
field_access
identifier "Token"
. "."
identifier "MOD"
: ":"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "rval"
== "=="
decimal_integer_literal "0"
) ")"
block
{ "{"
expression_statement
method_invocation
identifier "error"
argument_list
( "("
method_invocation
identifier "DiagnosticType"
. "."
identifier "error"
argument_list
( "("
string_literal
" "\""
string_fragment "JSC_DIVIDE_BY_0_ERROR"
" "\""
, ","
string_literal
" "\""
string_fragment "Divide by 0"
" "\""
) ")"
, ","
identifier "right"
) ")"
; ";"
return_statement
return "return"
null_literal "null"
; ";"
} "}"
expression_statement
assignment_expression
identifier "result"
= "="
binary_expression
identifier "lval"
% "%"
identifier "rval"
; ";"
break_statement
break "break"
; ";"
switch_block_statement_group
switch_label
case "case"
field_access
identifier "Token"
. "."
identifier "DIV"
: ":"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "rval"
== "=="
decimal_integer_literal "0"
) ")"
block
{ "{"
expression_statement
method_invocation
identifier "error"
argument_list
( "("
method_invocation
identifier "DiagnosticType"
. "."
identifier "error"
argument_list
( "("
string_literal
" "\""
string_fragment "JSC_DIVIDE_BY_0_ERROR"
" "\""
, ","
string_literal
" "\""
string_fragment "Divide by 0"
" "\""
) ")"
, ","
identifier "right"
) ")"
; ";"
return_statement
return "return"
null_literal "null"
; ";"
} "}"
expression_statement
assignment_expression
identifier "result"
= "="
binary_expression
identifier "lval"
/ "/"
identifier "rval"
; ";"
break_statement
break "break"
; ";"
switch_block_statement_group
switch_label
default "default"
: ":"
throw_statement
throw "throw"
object_creation_expression
new "new"
type_identifier "Error"
argument_list
( "("
string_literal
" "\""
string_fragment "Unexpected arithmetic operator"
" "\""
) ")"
; ";"
} "}"
line_comment "// TODO(johnlenz): consider removing the result length check"...
line_comment "// length of the left and right value plus 1 byte for the op"...
if_statement (+207 nodes collapsed)
return_statement
return "return"
null_literal "null"
; ";"
} "}"
block_comment "/**\n * Expressions such as [foo() * 10 * 20] generate pars"...
method_declaration (+333 nodes collapsed)
method_declaration (+174 nodes collapsed)
block_comment "/**\n * Try to fold shift operations\n */"
method_declaration (+424 nodes collapsed)
block_comment "/**\n * Try to fold comparison nodes, e.g ==\n */"
method_declaration (+1249 nodes collapsed)
block_comment "/**\n * The result of the comparison as a Boolean or null i"...
method_declaration (+336 nodes collapsed)
block_comment "/**\n * @param value The value to compare to \"undefined\"\n "...
method_declaration (+246 nodes collapsed)
block_comment "/**\n * Try to fold away unnecessary object instantiation.\n"...
method_declaration (+64 nodes collapsed)
block_comment "/** Returns whether this node must be coerced to a string. *"...
method_declaration (+54 nodes collapsed)
method_declaration (+259 nodes collapsed)
method_declaration (+63 nodes collapsed)
block_comment "/**\n * Try to eveluate known String methods\n * .index"...
method_declaration (+411 nodes collapsed)
block_comment "/**\n * @return The lowered string Node.\n */"
method_declaration (+82 nodes collapsed)
block_comment "/**\n * @return The uppered string Node.\n */"
method_declaration (+82 nodes collapsed)
block_comment "/**\n * Try to evaluate String.indexOf/lastIndexOf:\n * "...
method_declaration (+315 nodes collapsed)
block_comment "/**\n * Try to fold an array join: ['a', 'b', 'c'].join('')"...
method_declaration (+911 nodes collapsed)
block_comment "/**\n * Try to fold .substr() calls on strings\n */"
method_declaration (+375 nodes collapsed)
block_comment "/**\n * Try to fold .substring() calls on strings\n */"
method_declaration (+379 nodes collapsed)
block_comment "/**\n * Try to fold array-element. e.g [1, 2, 3][10];\n */"
method_declaration (+333 nodes collapsed)
block_comment "/**\n * Try to fold array-length. e.g [1, 2, 3].length ==> "...
method_declaration (+251 nodes collapsed)
} "}"

After

program
block_comment "/*\n * Copyright 2004 The Closure Compiler Authors.\n *\n * Lic"...
package_declaration
package "package"
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "jscomp"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "common"
. "."
identifier "base"
. "."
identifier "Preconditions"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "common"
. "."
identifier "collect"
. "."
identifier "Lists"
; ";"
import_declaration (+22 nodes collapsed)
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "rhino"
. "."
identifier "Node"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "rhino"
. "."
identifier "Token"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
scoped_identifier
identifier "com"
. "."
identifier "google"
. "."
identifier "javascript"
. "."
identifier "rhino"
. "."
identifier "jstype"
. "."
identifier "TernaryValue"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "List"
; ";"
import_declaration
import "import"
scoped_identifier
scoped_identifier
identifier "java"
. "."
identifier "util"
. "."
identifier "Locale"
; ";"
block_comment "/**\n * Peephole optimization to fold constants (e.g. x + 1 +"...
class_declaration
class "class"
identifier "PeepholeFoldConstants"
superclass
extends "extends"
type_identifier "AbstractPeepholeOptimization"
class_body
{ "{"
field_declaration (+25 nodes collapsed)
field_declaration (+25 nodes collapsed)
field_declaration (+25 nodes collapsed)
field_declaration (+25 nodes collapsed)
field_declaration (+25 nodes collapsed)
field_declaration (+25 nodes collapsed)
field_declaration (+21 nodes collapsed)
line_comment "// The LOCALE independent \"locale\""
field_declaration
modifiers
private "private"
static "static"
final "final"
type_identifier "Locale"
variable_declarator
identifier "ROOT_LOCALE"
= "="
object_creation_expression
new "new"
type_identifier "Locale"
argument_list
( "("
string_literal
" "\""
" "\""
) ")"
; ";"
method_declaration (+169 nodes collapsed)
method_declaration (+458 nodes collapsed)
method_declaration (+106 nodes collapsed)
method_declaration (+317 nodes collapsed)
method_declaration (+68 nodes collapsed)
method_declaration (+370 nodes collapsed)
block_comment "/**\n * Folds 'typeof(foo)' if foo is a literal, e.g.\n * "...
method_declaration (+351 nodes collapsed)
method_declaration (+696 nodes collapsed)
block_comment "/**\n * Try to fold {@code left instanceof right} into {@co"...
method_declaration (+214 nodes collapsed)
method_declaration (+518 nodes collapsed)
block_comment "/**\n * Try to fold a AND/OR node.\n */"
method_declaration (+207 nodes collapsed)
block_comment "/**\n * Expressions such as [foo() + 'a' + 'b'] generate pa"...
method_declaration (+408 nodes collapsed)
block_comment "/**\n * Try to fold an ADD node with constant operands\n *"...
method_declaration (+155 nodes collapsed)
block_comment "/**\n * Try to fold arithmetic binary operators\n */"
method_declaration (+99 nodes collapsed)
block_comment "/**\n * Try to fold arithmetic binary operators\n */"
method_declaration
modifiers
private "private"
type_identifier "Node"
identifier "performArithmeticOp"
formal_parameters
( "("
formal_parameter
integral_type
int "int"
identifier "opType"
, ","
formal_parameter
type_identifier "Node"
identifier "left"
, ","
formal_parameter
type_identifier "Node"
identifier "right"
) ")"
block
{ "{"
line_comment "// Unlike other operations, ADD operands are not always conv"...
line_comment "// to Number."
if_statement (+46 nodes collapsed)
local_variable_declaration
floating_point_type
double "double"
variable_declarator
identifier "result"
; ";"
line_comment "// TODO(johnlenz): Handle NaN with unknown value. BIT ops co"...
line_comment "// to zero so this is a little akward here."
local_variable_declaration
type_identifier "Double"
variable_declarator
identifier "lValObj"
= "="
method_invocation
identifier "NodeUtil"
. "."
identifier "getNumberValue"
argument_list
( "("
identifier "left"
) ")"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "lValObj"
== "=="
null_literal "null"
) ")"
block
{ "{"
return_statement
return "return"
null_literal "null"
; ";"
} "}"
local_variable_declaration
type_identifier "Double"
variable_declarator
identifier "rValObj"
= "="
method_invocation
identifier "NodeUtil"
. "."
identifier "getNumberValue"
argument_list
( "("
identifier "right"
) ")"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "rValObj"
== "=="
null_literal "null"
) ")"
block
{ "{"
return_statement
return "return"
null_literal "null"
; ";"
} "}"
local_variable_declaration
floating_point_type
double "double"
variable_declarator
identifier "lval"
= "="
identifier "lValObj"
; ";"
local_variable_declaration
floating_point_type
double "double"
variable_declarator
identifier "rval"
= "="
identifier "rValObj"
; ";"
switch_expression
switch "switch"
parenthesized_expression
( "("
identifier "opType"
) ")"
switch_block
{ "{"
switch_block_statement_group (+34 nodes collapsed)
switch_block_statement_group (+34 nodes collapsed)
switch_block_statement_group (+34 nodes collapsed)
switch_block_statement_group
switch_label
case "case"
field_access
identifier "Token"
. "."
identifier "ADD"
: ":"
expression_statement
assignment_expression
identifier "result"
= "="
binary_expression
identifier "lval"
+ "+"
identifier "rval"
; ";"
break_statement
break "break"
; ";"
switch_block_statement_group
switch_label
case "case"
field_access
identifier "Token"
. "."
identifier "SUB"
: ":"
expression_statement
assignment_expression
identifier "result"
= "="
binary_expression
identifier "lval"
- "-"
identifier "rval"
; ";"
break_statement
break "break"
; ";"
switch_block_statement_group
switch_label
case "case"
field_access
identifier "Token"
. "."
identifier "MUL"
: ":"
expression_statement
assignment_expression
identifier "result"
= "="
binary_expression
identifier "lval"
* "*"
identifier "rval"
; ";"
break_statement
break "break"
; ";"
switch_block_statement_group
switch_label
case "case"
field_access
identifier "Token"
. "."
identifier "MOD"
: ":"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "rval"
== "=="
decimal_integer_literal "0"
) ")"
block
{ "{"
return_statement
return "return"
null_literal "null"
; ";"
} "}"
expression_statement
assignment_expression
identifier "result"
= "="
binary_expression
identifier "lval"
% "%"
identifier "rval"
; ";"
break_statement
break "break"
; ";"
switch_block_statement_group
switch_label
case "case"
field_access
identifier "Token"
. "."
identifier "DIV"
: ":"
if_statement
if "if"
parenthesized_expression
( "("
binary_expression
identifier "rval"
== "=="
decimal_integer_literal "0"
) ")"
block
{ "{"
return_statement
return "return"
null_literal "null"
; ";"
} "}"
expression_statement
assignment_expression
identifier "result"
= "="
binary_expression
identifier "lval"
/ "/"
identifier "rval"
; ";"
break_statement
break "break"
; ";"
switch_block_statement_group
switch_label
default "default"
: ":"
throw_statement
throw "throw"
object_creation_expression
new "new"
type_identifier "Error"
argument_list
( "("
string_literal
" "\""
string_fragment "Unexpected arithmetic operator"
" "\""
) ")"
; ";"
} "}"
line_comment "// TODO(johnlenz): consider removing the result length check"...
line_comment "// length of the left and right value plus 1 byte for the op"...
if_statement (+207 nodes collapsed)
return_statement
return "return"
null_literal "null"
; ";"
} "}"
block_comment "/**\n * Expressions such as [foo() * 10 * 20] generate pars"...
method_declaration (+333 nodes collapsed)
method_declaration (+174 nodes collapsed)
block_comment "/**\n * Try to fold shift operations\n */"
method_declaration (+424 nodes collapsed)
block_comment "/**\n * Try to fold comparison nodes, e.g ==\n */"
method_declaration (+1249 nodes collapsed)
block_comment "/**\n * The result of the comparison as a Boolean or null i"...
method_declaration (+336 nodes collapsed)
block_comment "/**\n * @param value The value to compare to \"undefined\"\n "...
method_declaration (+246 nodes collapsed)
block_comment "/**\n * Try to fold away unnecessary object instantiation.\n"...
method_declaration (+64 nodes collapsed)
block_comment "/** Returns whether this node must be coerced to a string. *"...
method_declaration (+54 nodes collapsed)
method_declaration (+259 nodes collapsed)
method_declaration (+63 nodes collapsed)
block_comment "/**\n * Try to eveluate known String methods\n * .index"...
method_declaration (+411 nodes collapsed)
block_comment "/**\n * @return The lowered string Node.\n */"
method_declaration (+82 nodes collapsed)
block_comment "/**\n * @return The uppered string Node.\n */"
method_declaration (+82 nodes collapsed)
block_comment "/**\n * Try to evaluate String.indexOf/lastIndexOf:\n * "...
method_declaration (+315 nodes collapsed)
block_comment "/**\n * Try to fold an array join: ['a', 'b', 'c'].join('')"...
method_declaration (+911 nodes collapsed)
block_comment "/**\n * Try to fold .substr() calls on strings\n */"
method_declaration (+375 nodes collapsed)
block_comment "/**\n * Try to fold .substring() calls on strings\n */"
method_declaration (+379 nodes collapsed)
block_comment "/**\n * Try to fold array-element. e.g [1, 2, 3][10];\n */"
method_declaration (+333 nodes collapsed)
block_comment "/**\n * Try to fold array-length. e.g [1, 2, 3].length ==> "...
method_declaration (+251 nodes collapsed)
} "}"