FoldConstants.java (1341:1172aca37bba) | FoldConstants.java (1426:751ada854e5a) |
---|---|
1/* 2 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided --- 23 unchanged lines hidden (view full) --- 32import jdk.nashorn.internal.codegen.types.Type; 33import jdk.nashorn.internal.ir.BinaryNode; 34import jdk.nashorn.internal.ir.Block; 35import jdk.nashorn.internal.ir.BlockStatement; 36import jdk.nashorn.internal.ir.CaseNode; 37import jdk.nashorn.internal.ir.EmptyNode; 38import jdk.nashorn.internal.ir.Expression; 39import jdk.nashorn.internal.ir.FunctionNode; | 1/* 2 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided --- 23 unchanged lines hidden (view full) --- 32import jdk.nashorn.internal.codegen.types.Type; 33import jdk.nashorn.internal.ir.BinaryNode; 34import jdk.nashorn.internal.ir.Block; 35import jdk.nashorn.internal.ir.BlockStatement; 36import jdk.nashorn.internal.ir.CaseNode; 37import jdk.nashorn.internal.ir.EmptyNode; 38import jdk.nashorn.internal.ir.Expression; 39import jdk.nashorn.internal.ir.FunctionNode; |
40import jdk.nashorn.internal.ir.FunctionNode.CompilationState; | |
41import jdk.nashorn.internal.ir.IfNode; 42import jdk.nashorn.internal.ir.LexicalContext; 43import jdk.nashorn.internal.ir.LiteralNode; 44import jdk.nashorn.internal.ir.LiteralNode.ArrayLiteralNode; 45import jdk.nashorn.internal.ir.Node; 46import jdk.nashorn.internal.ir.Statement; 47import jdk.nashorn.internal.ir.SwitchNode; 48import jdk.nashorn.internal.ir.TernaryNode; --- 47 unchanged lines hidden (view full) --- 96 log.info("Binary constant folded ", binaryNode, " to ", literalNode); 97 return literalNode; 98 } 99 return binaryNode; 100 } 101 102 @Override 103 public Node leaveFunctionNode(final FunctionNode functionNode) { | 40import jdk.nashorn.internal.ir.IfNode; 41import jdk.nashorn.internal.ir.LexicalContext; 42import jdk.nashorn.internal.ir.LiteralNode; 43import jdk.nashorn.internal.ir.LiteralNode.ArrayLiteralNode; 44import jdk.nashorn.internal.ir.Node; 45import jdk.nashorn.internal.ir.Statement; 46import jdk.nashorn.internal.ir.SwitchNode; 47import jdk.nashorn.internal.ir.TernaryNode; --- 47 unchanged lines hidden (view full) --- 95 log.info("Binary constant folded ", binaryNode, " to ", literalNode); 96 return literalNode; 97 } 98 return binaryNode; 99 } 100 101 @Override 102 public Node leaveFunctionNode(final FunctionNode functionNode) { |
104 return functionNode.setState(lc, CompilationState.CONSTANT_FOLDED); | 103 return functionNode; |
105 } 106 107 @Override 108 public Node leaveIfNode(final IfNode ifNode) { 109 final Node test = ifNode.getTest(); 110 if (test instanceof LiteralNode.PrimitiveLiteralNode) { 111 final boolean isTrue = ((LiteralNode.PrimitiveLiteralNode<?>)test).isTrue(); 112 final Block executed = isTrue ? ifNode.getPass() : ifNode.getFail(); --- 256 unchanged lines hidden --- | 104 } 105 106 @Override 107 public Node leaveIfNode(final IfNode ifNode) { 108 final Node test = ifNode.getTest(); 109 if (test instanceof LiteralNode.PrimitiveLiteralNode) { 110 final boolean isTrue = ((LiteralNode.PrimitiveLiteralNode<?>)test).isTrue(); 111 final Block executed = isTrue ? ifNode.getPass() : ifNode.getFail(); --- 256 unchanged lines hidden --- |