for (int c = 0, max = getChildCount(); c < max; c++) { SpelNode child = getChild(c); if (!(child instanceof Literal)) { if (child instanceof InlineList) { InlineList inlineList = (InlineList) child; if (!inlineList.isConstant()) { isConstant = false; int childcount = getChildCount(); for (int c = 0; c < childcount; c++) { SpelNode child = getChild(c); if ((child instanceof Literal)) { constantList.add(((Literal) child).getLiteralValue().getValue()); constantList.add(((InlineList) child).getConstantValue());
public InlineList(int startPos, int endPos, SpelNodeImpl... args) { super(startPos, endPos, args); checkIfConstant(); }
@Override public String toStringAST() { StringBuilder sb = new StringBuilder("{"); // String ast matches input string, not the 'toString()' of the resultant collection, which would use [] int count = getChildCount(); for (int c = 0; c < count; c++) { if (c > 0) { sb.append(","); } sb.append(getChild(c).toStringAST()); } sb.append("}"); return sb.toString(); }
private void populateBooleanArray(ExpressionState state, Object newArray, TypeConverter typeConverter, InlineList initializer) { boolean[] newBooleanArray = (boolean[]) newArray; for (int i = 0; i < newBooleanArray.length; i++) { TypedValue typedValue = initializer.getChild(i).getTypedValue(state); newBooleanArray[i] = ExpressionUtils.toBoolean(typeConverter, typedValue); } }
if (child instanceof InlineList) { InlineList inlineList = (InlineList) child; if (!inlineList.isConstant()) { isConstant = false; break; value = ((InlineList) valueChild).getConstantValue();
mv.visitFieldInsn(PUTSTATIC, clazzname, constantFieldName, "Ljava/util/List;"); int childCount = getChildCount(); for (int c = 0; c < childCount; c++) { if (!nested) { ((InlineList)this.children[c]).generateClinitCode(clazzname, constantFieldName, mv, codeflow, true);
@Override public boolean isCompilable() { return isConstant(); }
@Override public void generateCode(MethodVisitor mv, CodeFlow codeflow) { final String constantFieldName = "inlineList$" + codeflow.nextFieldId(); final String className = codeflow.getClassName(); codeflow.registerNewField((cw, cflow) -> cw.visitField(ACC_PRIVATE | ACC_STATIC | ACC_FINAL, constantFieldName, "Ljava/util/List;", null, null)); codeflow.registerNewClinit((mVisitor, cflow) -> generateClinitCode(className, constantFieldName, mVisitor, cflow, false)); mv.visitFieldInsn(GETSTATIC, className, constantFieldName, "Ljava/util/List;"); codeflow.pushDescriptor("Ljava/util/List"); }
expr = new InlineList(t.startPos, closingCurly.endPos); elements.add(firstExpression); closingCurly = eatToken(TokenKind.RCURLY); expr = new InlineList(t.startPos, closingCurly.endPos, elements.toArray(new SpelNodeImpl[0])); expr = new InlineList(t.startPos, closingCurly.endPos, elements.toArray(new SpelNodeImpl[0]));
TypedValue dValue = this.dimensions[0].getTypedValue(state); int i = ExpressionUtils.toInt(typeConverter, dValue); if (i != initializer.getChildCount()) { throw new SpelEvaluationException(getStartPosition(), SpelMessage.INITIALIZER_LENGTH_INCORRECT); int arraySize = initializer.getChildCount(); newArray = Array.newInstance(componentType, arraySize); if (arrayTypeCode == TypeCode.OBJECT) {
private void populateByteArray(ExpressionState state, Object newArray, TypeConverter typeConverter, InlineList initializer) { byte[] newByteArray = (byte[]) newArray; for (int i = 0; i < newByteArray.length; i++) { TypedValue typedValue = initializer.getChild(i).getTypedValue(state); newByteArray[i] = ExpressionUtils.toByte(typeConverter, typedValue); } }
@Override public TypedValue getValueInternal(ExpressionState expressionState) throws EvaluationException { if (this.constant != null) { return this.constant; } else { List<Object> returnValue = new ArrayList<>(); int childCount = getChildCount(); for (int c = 0; c < childCount; c++) { returnValue.add(getChild(c).getValue(expressionState)); } return new TypedValue(returnValue); } }
if (child instanceof InlineList) { InlineList inlineList = (InlineList) child; if (!inlineList.isConstant()) { isConstant = false; break; value = ((InlineList) valueChild).getConstantValue();
mv.visitFieldInsn(PUTSTATIC, clazzname, constantFieldName, "Ljava/util/List;"); int childCount = getChildCount(); for (int c = 0; c < childCount; c++) { if (!nested) { ((InlineList)this.children[c]).generateClinitCode(clazzname, constantFieldName, mv, codeflow, true);
@Override public boolean isCompilable() { return isConstant(); }
@Override public void generateCode(MethodVisitor mv, CodeFlow codeflow) { final String constantFieldName = "inlineList$" + codeflow.nextFieldId(); final String className = codeflow.getClassName(); codeflow.registerNewField((cw, cflow) -> cw.visitField(ACC_PRIVATE | ACC_STATIC | ACC_FINAL, constantFieldName, "Ljava/util/List;", null, null)); codeflow.registerNewClinit((mVisitor, cflow) -> generateClinitCode(className, constantFieldName, mVisitor, cflow, false)); mv.visitFieldInsn(GETSTATIC, className, constantFieldName, "Ljava/util/List;"); codeflow.pushDescriptor("Ljava/util/List"); }
expr = new InlineList(toPos(t.startPos, closingCurly.endPos)); elements.add(firstExpression); closingCurly = eatToken(TokenKind.RCURLY); expr = new InlineList(toPos(t.startPos, closingCurly.endPos), elements.toArray(new SpelNodeImpl[0])); expr = new InlineList(toPos(t.startPos, closingCurly.endPos), elements.toArray(new SpelNodeImpl[0]));
TypedValue dValue = this.dimensions[0].getTypedValue(state); int i = ExpressionUtils.toInt(typeConverter, dValue); if (i != initializer.getChildCount()) { throw new SpelEvaluationException(getStartPosition(), SpelMessage.INITIALIZER_LENGTH_INCORRECT); int arraySize = initializer.getChildCount(); newArray = Array.newInstance(componentType, arraySize); if (arrayTypeCode == TypeCode.OBJECT) {
for (int c = 0, max = getChildCount(); c < max; c++) { SpelNode child = getChild(c); if (!(child instanceof Literal)) { if (child instanceof InlineList) { InlineList inlineList = (InlineList) child; if (!inlineList.isConstant()) { isConstant = false; int childcount = getChildCount(); for (int c = 0; c < childcount; c++) { SpelNode child = getChild(c); if ((child instanceof Literal)) { constantList.add(((Literal) child).getLiteralValue().getValue()); constantList.add(((InlineList) child).getConstantValue());
private void populateDoubleArray(ExpressionState state, Object newArray, TypeConverter typeConverter, InlineList initializer) { double[] newDoubleArray = (double[]) newArray; for (int i = 0; i < newDoubleArray.length; i++) { TypedValue typedValue = initializer.getChild(i).getTypedValue(state); newDoubleArray[i] = ExpressionUtils.toDouble(typeConverter, typedValue); } }