Search in sources :

Example 1 with Range

use of lucee.transformer.bytecode.Range in project Lucee by lucee.

the class LitStringImpl method _writeOut.

/**
 * @see lucee.transformer.expression.Expression#_writeOut(org.objectweb.asm.commons.GeneratorAdapter, int)
 */
private static Type _writeOut(BytecodeContext bc, int mode, String str) throws TransformerException {
    // write to a file instead to the bytecode
    // str(0,10);
    // print.ds(str);
    int externalizeStringGTE = ((ConfigImpl) bc.getConfig()).getExternalizeStringGTE();
    if (externalizeStringGTE > -1 && str.length() > externalizeStringGTE && StringUtil.indexOfIgnoreCase(bc.getMethod().getName(), "call") != -1) {
        try {
            GeneratorAdapter ga = bc.getAdapter();
            Page page = bc.getPage();
            Range range = page.registerString(bc, str);
            if (range != null) {
                ga.visitVarInsn(Opcodes.ALOAD, 0);
                ga.visitVarInsn(Opcodes.ALOAD, 1);
                ga.push(range.from);
                ga.push(range.to);
                ga.visitMethodInsn(Opcodes.INVOKEVIRTUAL, bc.getClassName(), "str", "(Llucee/runtime/PageContext;II)Ljava/lang/String;");
                return Types.STRING;
            }
        } catch (Throwable t) {
            ExceptionUtil.rethrowIfNecessary(t);
        }
    }
    if (toBig(str)) {
        _toExpr(bc.getFactory(), str).writeOut(bc, mode);
    } else {
        bc.getAdapter().push(str);
    }
    return Types.STRING;
}
Also used : GeneratorAdapter(org.objectweb.asm.commons.GeneratorAdapter) Page(lucee.transformer.bytecode.Page) Range(lucee.transformer.bytecode.Range) ConfigImpl(lucee.runtime.config.ConfigImpl)

Aggregations

ConfigImpl (lucee.runtime.config.ConfigImpl)1 Page (lucee.transformer.bytecode.Page)1 Range (lucee.transformer.bytecode.Range)1 GeneratorAdapter (org.objectweb.asm.commons.GeneratorAdapter)1