Class: sun.tools.tree.AddExpression
- public class AddExpression
- extends BinaryArithmeticExpression
WARNING: The contents of this source file are not part of any
supported API. Code that depends on them does so at its own risk:
they are subject to change or removal without notice.
Inheritance
Superclass tree: Implements:Methods
-
AddExpressiontop
public AddExpression(long where, Expression left, Expression right)constructor -
codeAppendtop
void codeAppend(Environment env, Context ctx, Assembler asm, ClassDeclaration sbClass, boolean needBuffer) throws ClassNotFound, AmbiguousMemberConvert this expression to a string and append it to the string buffer on the top of the stack. If the needBuffer argument is true, the string buffer needs to be created, initialized, and pushed on the stack, first.- Override hierarchy:
- codeAppend from Expression
-
codeOperationtop
Code- Override hierarchy:
- codeOperation from BinaryExpression
-
codeValuetop
- Override hierarchy:
- codeValue from BinaryExpression
- codeValue from Expression
-
costInlinetop
public int costInline(int thresh, Environment env, Context ctx)The cost of inlining this expression- Override hierarchy:
- costInline from BinaryExpression
- costInline from UnaryExpression
- costInline from Expression
-
evaltop
Expression eval(double a, double b)- Override hierarchy:
- eval from BinaryExpression
-
evaltop
Expression eval(float a, float b)- Override hierarchy:
- eval from BinaryExpression
-
evaltop
Expression eval(int a, int b)Evaluate- Override hierarchy:
- eval from BinaryExpression
-
evaltop
Expression eval(long a, long b)- Override hierarchy:
- eval from BinaryExpression
-
evaltop
- Override hierarchy:
- eval from BinaryExpression
-
inlineValuetop
Inline the value of an AddExpression. If this AddExpression represents a concatenation of compile-time constant strings, dispatch to the special method inlineValueSB, which handles the inlining more efficiently.- Override hierarchy:
- inlineValue from BinaryExpression
- inlineValue from UnaryExpression
- inlineValue from Expression
-
inlineValueSBtop
Attempt to evaluate this expression. If this expression yields a value, append it to the StringBuffer `buffer'. If this expression cannot be evaluated at this time (for example if it contains a division by zero, a non-constant subexpression, or a subexpression which "refuses" to evaluate) then return `null' to indicate failure. It is anticipated that this method will be called to evaluate concatenations of compile-time constant strings. The call originates from AddExpression#inlineValue(). This method does not use associativity to good effect in folding string concatenations. This is room for improvement. ------------- A bit of history: this method was added because an expression like... "a" + "b" + "c" + "d" ...was evaluated at compile-time as... (new StringBuffer((new StringBuffer("a")).append("b").toString())). append((new StringBuffer("c")).append("d").toString()).toString() Alex Garthwaite, in profiling the memory allocation of the compiler, noticed this and suggested that the method inlineValueSB() be added to evaluate constant string concatenations in a more efficient manner. The compiler now builds the string in a top-down fashion, by accumulating the result in a StringBuffer which is allocated once and passed in as a parameter. The new evaluation scheme is equivalent to... (new StringBuffer("a")).append("b").append("c").append("d") .toString() ...which is more efficient. Since then, the code has been modified to fix certain problems. Now, for example, it can return `null' when it encounters a concatenation which it is not able to evaluate. See also Expression#inlineValueSB() and ExprExpression#inlineValueSB().- Override hierarchy:
- inlineValueSB from Expression
-
isNonNulltop
public boolean isNonNull()Check if the expression cannot be a null reference.- Override hierarchy:
- isNonNull from Expression
-
selectTypetop
void selectType(Environment env, Context ctx, int tm)Select the type- Override hierarchy:
- selectType from BinaryArithmeticExpression
- selectType from UnaryExpression
-
simplifytop
Expression simplify()Simplify- Override hierarchy:
- simplify from Expression
