comparison graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/expression/SLAddNode.java @ 13883:ff3136ecb5a7

SL: small changes
author Christian Wimmer <christian.wimmer@oracle.com>
date Wed, 05 Feb 2014 03:16:21 -0800
parents 64c77f0577bb
children 7392b9e0470b
comparison
equal deleted inserted replaced
13870:d04be74665fb 13883:ff3136ecb5a7
76 protected BigInteger add(BigInteger left, BigInteger right) { 76 protected BigInteger add(BigInteger left, BigInteger right) {
77 return left.add(right); 77 return left.add(right);
78 } 78 }
79 79
80 /** 80 /**
81 * Specialization for String concatenation. This specialization is not strictly necessary, since
82 * {@link #add(Object, Object)} covers this case too. But it leads to slightly better code,
83 * since we do not require the {@link Object#toString()} calls in this specialization.
84 */
85 @Specialization
86 protected String add(String left, String right) {
87 return left + right;
88 }
89
90 /**
91 * Specialization for String concatenation. The SL specification says that String concatenation 81 * Specialization for String concatenation. The SL specification says that String concatenation
92 * works if either the left or the right operand is a String. The non-string operand is 82 * works if either the left or the right operand is a String. The non-string operand is
93 * converted then automatically converted to a String. 83 * converted then automatically converted to a String.
94 * <p> 84 * <p>
95 * To implement these semantics, we tell the Truffle DSL to use a custom guard. The guard 85 * To implement these semantics, we tell the Truffle DSL to use a custom guard. The guard