Search in sources :

Example 11 with ArrayVisitor

use of lucee.transformer.bytecode.visitor.ArrayVisitor in project Lucee by lucee.

the class VT method _writeOutCallerUtil.

private Type _writeOutCallerUtil(BytecodeContext bc, int mode) throws TransformerException {
    GeneratorAdapter adapter = bc.getAdapter();
    final int count = countFM + countDM;
    // count 0
    if (count == 0)
        return _writeOutEmpty(bc);
    // pc
    adapter.loadArg(0);
    // collection
    RefInteger startIndex = new RefIntegerImpl();
    _writeOutFirst(bc, (members.get(0)), mode, count == 1, true, defaultValue, startIndex);
    // keys
    Iterator<Member> it = members.iterator();
    ArrayVisitor av = new ArrayVisitor();
    av.visitBegin(adapter, Types.COLLECTION_KEY, countDM - startIndex.toInt());
    int index = 0, i = 0;
    while (it.hasNext()) {
        DataMember member = (DataMember) it.next();
        if (i++ < startIndex.toInt())
            continue;
        av.visitBeginItem(adapter, index++);
        getFactory().registerKey(bc, member.getName(), false);
        av.visitEndItem(bc.getAdapter());
    }
    av.visitEnd();
    // defaultValue
    defaultValue.writeOut(bc, MODE_REF);
    bc.getAdapter().invokeStatic(Types.CALLER_UTIL, CALLER_UTIL_GET);
    return Types.OBJECT;
}
Also used : RefInteger(lucee.commons.lang.types.RefInteger) DataMember(lucee.transformer.expression.var.DataMember) GeneratorAdapter(org.objectweb.asm.commons.GeneratorAdapter) ArrayVisitor(lucee.transformer.bytecode.visitor.ArrayVisitor) RefIntegerImpl(lucee.commons.lang.types.RefIntegerImpl) DataMember(lucee.transformer.expression.var.DataMember) Member(lucee.transformer.expression.var.Member)

Aggregations

ArrayVisitor (lucee.transformer.bytecode.visitor.ArrayVisitor)11 GeneratorAdapter (org.objectweb.asm.commons.GeneratorAdapter)11 Label (org.objectweb.asm.Label)5 Type (org.objectweb.asm.Type)4 DataMember (lucee.transformer.expression.var.DataMember)3 Member (lucee.transformer.expression.var.Member)3 ArrayList (java.util.ArrayList)2 TransformerException (lucee.transformer.TransformerException)2 BytecodeContext (lucee.transformer.bytecode.BytecodeContext)2 TagCIObject (lucee.transformer.bytecode.statement.tag.TagCIObject)2 LitString (lucee.transformer.expression.literal.LitString)2 Method (org.objectweb.asm.commons.Method)2 IOException (java.io.IOException)1 Method (java.lang.reflect.Method)1 Iterator (java.util.Iterator)1 ClassException (lucee.commons.lang.ClassException)1 RefInteger (lucee.commons.lang.types.RefInteger)1 RefIntegerImpl (lucee.commons.lang.types.RefIntegerImpl)1 InterfacePageImpl (lucee.runtime.InterfacePageImpl)1 PageSource (lucee.runtime.PageSource)1