Xor.java revision 608:7e06bf1dcb09
138786Sdfr/* 238786Sdfr * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved. 338786Sdfr * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 438786Sdfr * 538786Sdfr * This code is free software; you can redistribute it and/or modify it 638786Sdfr * under the terms of the GNU General Public License version 2 only, as 738786Sdfr * published by the Free Software Foundation. Oracle designates this 838786Sdfr * particular file as subject to the "Classpath" exception as provided 938786Sdfr * by Oracle in the LICENSE file that accompanied this code. 1038786Sdfr * 1138786Sdfr * This code is distributed in the hope that it will be useful, but WITHOUT 1238786Sdfr * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1338786Sdfr * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1438786Sdfr * version 2 for more details (a copy is included in the LICENSE file that 1538786Sdfr * accompanied this code). 1638786Sdfr * 1738786Sdfr * You should have received a copy of the GNU General Public License version 1838786Sdfr * 2 along with this work; if not, write to the Free Software Foundation, 1938786Sdfr * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2038786Sdfr * 2138786Sdfr * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2238786Sdfr * or visit www.oracle.com if you need additional information or have any 2338786Sdfr * questions. 2438786Sdfr */ 2538786Sdfr/* 2638786Sdfr * COMPONENT_NAME: idl.parser 2738786Sdfr * 2838786Sdfr * ORIGINS: 27 2950476Speter * 3038786Sdfr * Licensed Materials - Property of IBM 3138786Sdfr * 5639-D57 (C) COPYRIGHT International Business Machines Corp. 1997, 1999 3249831Smpp * RMI-IIOP v1.0 3379538Sru * 3438786Sdfr */ 3538786Sdfr 3638786Sdfrpackage com.sun.tools.corba.se.idl.constExpr; 3738786Sdfr 3838786Sdfr// NOTES: 3938786Sdfr 4084306Sruimport com.sun.tools.corba.se.idl.Util; 4184306Sruimport java.math.BigInteger; 4238786Sdfr 4338786Sdfrpublic class Xor extends BinaryExpr 4438786Sdfr{ 4538786Sdfr protected Xor (Expression leftOperand, Expression rightOperand) 4638786Sdfr { 4738786Sdfr super ("^", leftOperand, rightOperand); 4838786Sdfr } // ctor 49121380Shmp 50121380Shmp public Object evaluate () throws EvaluationException 5138786Sdfr { 5238786Sdfr try 5338786Sdfr { 54108257Sru Number l = (Number)left ().evaluate (); 5589124Smpp Number r = (Number)right ().evaluate (); 56108257Sru 5738786Sdfr if (l instanceof Float || l instanceof Double || r instanceof Float || r instanceof Double) 58108257Sru { 5938786Sdfr String[] parameters = {Util.getMessage ("EvaluationException.xor"), left ().value ().getClass ().getName (), right ().value ().getClass ().getName ()}; 6038786Sdfr throw new EvaluationException (Util.getMessage ("EvaluationException.1", parameters)); 6138786Sdfr } 62121414Shmp else 6338786Sdfr { 64 // Xor (^) 65 //daz value (new Long (l.longValue () ^ r.longValue ())); 66 //BigInteger uL = (BigInteger)toUnsigned((BigInteger)l); 67 //BigInteger uR = (BigInteger)toUnsigned((BigInteger)r); 68 //value (coerceToTarget(uL.xor (uR))); 69 BigInteger uL = (BigInteger)coerceToTarget((BigInteger)l); 70 BigInteger uR = (BigInteger)coerceToTarget((BigInteger)r); 71 value (uL.xor (uR)); 72 } 73 } 74 catch (ClassCastException e) 75 { 76 String[] parameters = {Util.getMessage ("EvaluationException.xor"), left ().value ().getClass ().getName (), right ().value ().getClass ().getName ()}; 77 throw new EvaluationException (Util.getMessage ("EvaluationException.1", parameters)); 78 } 79 return value (); 80 } // evaluate 81} // class Xor 82