Java Code Examples for org.codehaus.groovy.ast.expr.GStringExpression#getStrings()
The following examples show how to use
org.codehaus.groovy.ast.expr.GStringExpression#getStrings() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AsmClassGenerator.java From groovy with Apache License 2.0 | 5 votes |
@Override public void visitGStringExpression(final GStringExpression expression) { MethodVisitor mv = controller.getMethodVisitor(); mv.visitTypeInsn(NEW, "org/codehaus/groovy/runtime/GStringImpl"); mv.visitInsn(DUP); int size = expression.getValues().size(); BytecodeHelper.pushConstant(mv, size); mv.visitTypeInsn(ANEWARRAY, "java/lang/Object"); for (int i = 0; i < size; i += 1) { mv.visitInsn(DUP); BytecodeHelper.pushConstant(mv, i); expression.getValue(i).visit(this); controller.getOperandStack().box(); mv.visitInsn(AASTORE); } controller.getOperandStack().remove(size); List<ConstantExpression> strings = expression.getStrings(); size = strings.size(); BytecodeHelper.pushConstant(mv, size); mv.visitTypeInsn(ANEWARRAY, "java/lang/String"); for (int i = 0; i < size; i += 1) { mv.visitInsn(DUP); BytecodeHelper.pushConstant(mv, i); controller.getOperandStack().pushConstant(strings.get(i)); controller.getOperandStack().box(); mv.visitInsn(AASTORE); } controller.getOperandStack().remove(size); mv.visitMethodInsn(INVOKESPECIAL, "org/codehaus/groovy/runtime/GStringImpl", "<init>", "([Ljava/lang/Object;[Ljava/lang/String;)V", false); controller.getOperandStack().push(ClassHelper.GSTRING_TYPE); }
Example 2
Source File: ClassCompletionVerifier.java From groovy with Apache License 2.0 | 4 votes |
public void visitGStringExpression(GStringExpression expression) { super.visitGStringExpression(expression); for (ConstantExpression ce : expression.getStrings()) { checkStringExceedingMaximumLength(ce); } }