Search in sources :

Example 1 with UninitializedType

use of org.eclipse.ceylon.langtools.tools.javac.jvm.UninitializedType in project ceylon by eclipse.

the class Code method emitInvokespecial.

/**
 * Emit an invokespecial instruction.
 */
public void emitInvokespecial(int meth, Type mtype) {
    int argsize = width(mtype.getParameterTypes());
    emitop(invokespecial);
    if (!alive)
        return;
    emit2(meth);
    Symbol sym = (Symbol) pool.pool[meth];
    state.pop(argsize);
    if (sym.isConstructor())
        state.markInitialized((UninitializedType) state.peek());
    state.pop(1);
    state.push(mtype.getReturnType());
}
Also used : Symbol(org.eclipse.ceylon.langtools.tools.javac.code.Symbol) UninitializedType(org.eclipse.ceylon.langtools.tools.javac.jvm.UninitializedType)

Example 2 with UninitializedType

use of org.eclipse.ceylon.langtools.tools.javac.jvm.UninitializedType in project ceylon by eclipse.

the class Code method emitCLDCStackMap.

/**
 * Emit a CLDC stack map frame.
 */
void emitCLDCStackMap(int pc, int localsSize) {
    if (lastStackMapPC == pc) {
        // drop existing stackmap at this offset
        stackMapBuffer[--stackMapBufferSize] = null;
    }
    lastStackMapPC = pc;
    if (stackMapBuffer == null) {
        stackMapBuffer = new StackMapFrame[20];
    } else {
        stackMapBuffer = ArrayUtils.ensureCapacity(stackMapBuffer, stackMapBufferSize);
    }
    StackMapFrame frame = stackMapBuffer[stackMapBufferSize++] = new StackMapFrame();
    frame.pc = pc;
    frame.locals = new Type[localsSize];
    for (int i = 0; i < localsSize; i++) {
        if (state.defined.isMember(i) && lvar[i] != null) {
            Type vtype = lvar[i].sym.type;
            if (!(vtype instanceof UninitializedType))
                vtype = types.erasure(vtype);
            frame.locals[i] = vtype;
        }
    }
    frame.stack = new Type[state.stacksize];
    for (int i = 0; i < state.stacksize; i++) frame.stack[i] = state.stack[i];
}
Also used : UninitializedType(org.eclipse.ceylon.langtools.tools.javac.jvm.UninitializedType) UniqueType(org.eclipse.ceylon.langtools.tools.javac.code.Types.UniqueType) UninitializedType(org.eclipse.ceylon.langtools.tools.javac.jvm.UninitializedType)

Example 3 with UninitializedType

use of org.eclipse.ceylon.langtools.tools.javac.jvm.UninitializedType in project ceylon by eclipse.

the class Code method emitStackMapFrame.

void emitStackMapFrame(int pc, int localsSize) {
    if (lastFrame == null) {
        // first frame
        lastFrame = getInitialFrame();
    } else if (lastFrame.pc == pc) {
        // drop existing stackmap at this offset
        stackMapTableBuffer[--stackMapBufferSize] = null;
        lastFrame = frameBeforeLast;
        frameBeforeLast = null;
    }
    StackMapFrame frame = new StackMapFrame();
    frame.pc = pc;
    int localCount = 0;
    Type[] locals = new Type[localsSize];
    for (int i = 0; i < localsSize; i++, localCount++) {
        if (state.defined.isMember(i) && lvar[i] != null) {
            Type vtype = lvar[i].sym.type;
            if (!(vtype instanceof UninitializedType))
                vtype = types.erasure(vtype);
            locals[i] = vtype;
            if (width(vtype) > 1)
                i++;
        }
    }
    frame.locals = new Type[localCount];
    for (int i = 0, j = 0; i < localsSize; i++, j++) {
        Assert.check(j < localCount);
        frame.locals[j] = locals[i];
        if (width(locals[i]) > 1)
            i++;
    }
    int stackCount = 0;
    for (int i = 0; i < state.stacksize; i++) {
        if (state.stack[i] != null) {
            stackCount++;
        }
    }
    frame.stack = new Type[stackCount];
    stackCount = 0;
    for (int i = 0; i < state.stacksize; i++) {
        if (state.stack[i] != null) {
            frame.stack[stackCount++] = types.erasure(state.stack[i]);
        }
    }
    if (stackMapTableBuffer == null) {
        stackMapTableBuffer = new StackMapTableFrame[20];
    } else {
        stackMapTableBuffer = ArrayUtils.ensureCapacity(stackMapTableBuffer, stackMapBufferSize);
    }
    stackMapTableBuffer[stackMapBufferSize++] = StackMapTableFrame.getInstance(frame, lastFrame.pc, lastFrame.locals, types);
    frameBeforeLast = lastFrame;
    lastFrame = frame;
}
Also used : UninitializedType(org.eclipse.ceylon.langtools.tools.javac.jvm.UninitializedType) UniqueType(org.eclipse.ceylon.langtools.tools.javac.code.Types.UniqueType) UninitializedType(org.eclipse.ceylon.langtools.tools.javac.jvm.UninitializedType)

Example 4 with UninitializedType

use of org.eclipse.ceylon.langtools.tools.javac.jvm.UninitializedType in project ceylon by eclipse.

the class ClassWriter method writeStackMapType.

// where
void writeStackMapType(Type t) {
    if (t == null) {
        if (debugstackmap)
            System.out.print("empty");
        databuf.appendByte(0);
    } else
        switch(t.getTag()) {
            case BYTE:
            case CHAR:
            case SHORT:
            case INT:
            case BOOLEAN:
                if (debugstackmap)
                    System.out.print("int");
                databuf.appendByte(1);
                break;
            case FLOAT:
                if (debugstackmap)
                    System.out.print("float");
                databuf.appendByte(2);
                break;
            case DOUBLE:
                if (debugstackmap)
                    System.out.print("double");
                databuf.appendByte(3);
                break;
            case LONG:
                if (debugstackmap)
                    System.out.print("long");
                databuf.appendByte(4);
                break;
            case // null
            BOT:
                if (debugstackmap)
                    System.out.print("null");
                databuf.appendByte(5);
                break;
            case CLASS:
            case ARRAY:
                if (debugstackmap)
                    System.out.print("object(" + t + ")");
                databuf.appendByte(7);
                databuf.appendChar(pool.put(t));
                break;
            case TYPEVAR:
                if (debugstackmap)
                    System.out.print("object(" + types.erasure(t).tsym + ")");
                databuf.appendByte(7);
                databuf.appendChar(pool.put(types.erasure(t).tsym));
                break;
            case UNINITIALIZED_THIS:
                if (debugstackmap)
                    System.out.print("uninit_this");
                databuf.appendByte(6);
                break;
            case UNINITIALIZED_OBJECT:
                {
                    UninitializedType uninitType = (UninitializedType) t;
                    databuf.appendByte(8);
                    if (debugstackmap)
                        System.out.print("uninit_object@" + uninitType.offset);
                    databuf.appendChar(uninitType.offset);
                }
                break;
            default:
                throw new AssertionError();
        }
}
Also used : UninitializedType(org.eclipse.ceylon.langtools.tools.javac.jvm.UninitializedType)

Aggregations

UninitializedType (org.eclipse.ceylon.langtools.tools.javac.jvm.UninitializedType)4 UniqueType (org.eclipse.ceylon.langtools.tools.javac.code.Types.UniqueType)2 Symbol (org.eclipse.ceylon.langtools.tools.javac.code.Symbol)1