Package org.perl6.nqp.runtime

Examples of org.perl6.nqp.runtime.CallSiteDescriptor


                AsyncSocketHandle handle = new AsyncSocketHandle(curTC, channel);
                IOHandleInstance ioHandle = (IOHandleInstance) IOType.st.REPR.allocate(curTC,
                        IOType.st);
                ioHandle.handle = handle;

                SixModelObject result = Array.st.REPR.allocate(curTC, Array.st);
                result.push_boxed(curTC, task.schedulee);
                result.push_boxed(curTC, ioHandle);
                result.push_boxed(curTC, Null);

                ((ConcBlockingQueueInstance) task.queue).push_boxed(curTC, result);
            }

            @Override
            public void failed(Throwable exc, AsyncTaskInstance task) {
                ThreadContext curTC = tc.gc.getCurrentThreadContext();
                SixModelObject result = Array.st.REPR.allocate(curTC, Array.st);
                result.push_boxed(curTC, task.schedulee);
                result.push_boxed(curTC, IOType);
                result.push_boxed(curTC, Ops.box_s(exc.getMessage(), Str, curTC));
            }
        };

        try {
            listenChan.accept(task, handler);
View Full Code Here


                        try {
                            /* We're done. Decode and box. */
                            ThreadContext curTC = tc.gc.getCurrentThreadContext();
                            ss.bb.flip();
                            String decoded = dec.decode(ss.bb).toString();
                            SixModelObject boxed = Ops.box_s(decoded, Str, curTC);
                           
                            /* Call done handler. */
                            Ops.invokeDirect(curTC, done, slurpResultCSD, new Object[] { boxed });
                        } catch (IOException e) {
                            failed(e, ss);
                        }
                    }
                    else {
                        /* Need to read some more. */
                        chan.read(ss.bb, ss.bb.position(), ss, this);
                    }
                }
               
                public void failed(Throwable exc, SlurpState ss) {
                    /* Box error. */
                    ThreadContext curTC = tc.gc.getCurrentThreadContext();
                    SixModelObject boxed = Ops.box_s(exc.toString(), Str, curTC);
                   
                    /* Call error handler. */
                    Ops.invokeDirect(curTC, error, slurpResultCSD, new Object[] { boxed });
                }
            };
View Full Code Here

                }

                public void failed(Throwable exc, SpurtState ss) {
                    /* Box error. */
                    ThreadContext curTC = tc.gc.getCurrentThreadContext();
                    SixModelObject boxed = Ops.box_s(exc.toString(), Str, curTC);

                    /* Call error handler. */
                    Ops.invokeDirect(curTC, error, spurtErrorCSD, new Object[] { boxed });
                }
            };
View Full Code Here

            }
           
            public void failed(Throwable exc, LinesState ss) {
                /* Box error. */
                ThreadContext curTC = tc.gc.getCurrentThreadContext();
                SixModelObject boxed = Ops.box_s(exc.toString(), Str, curTC);
               
                /* Call error handler. */
                Ops.invokeDirect(curTC, error, linesErrorCSD, new Object[] { boxed });
            }
        };
View Full Code Here

    }

    private JavaClass compileJast(SixModelObject jast, SixModelObject jastNodes, boolean split, ThreadContext tc) throws Exception {

        SixModelObject jastClassObj = jastNodes.at_key_boxed(tc, "JAST::Class");
        SixModelObject jastField = jastNodes.at_key_boxed(tc, "JAST::Field");
        SixModelObject jastMethod = jastNodes.at_key_boxed(tc, "JAST::Method");

        JastClass jastClass = new JastClass(jast, jastClassObj, tc);
        JavaClass c = new JavaClass();

        c.name = jastClass.className;
        c.serialized = jastClass.serialized;

        String className = jastClass.className.replace('.', '/');
        String superName = jastClass.superName.replace('.', '/');

        ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);
        cw.visit(Opcodes.V1_7, Opcodes.ACC_PUBLIC + Opcodes.ACC_SUPER, className, null,
                superName, null);
        cw.visitSource(jastClass.filename, null);

        SixModelObject iter = iter(jastClass.fields, tc);
        while (istrue(iter, tc) != 0) {
            JastField field = new JastField(iter.shift_boxed(tc), jastField, tc);

            cw.visitField(
                    field.isStatic
                        ? Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC
                        : Opcodes.ACC_PUBLIC,
                    field.name, field.type.getDescriptor(), null, null);
        }

        iter = iter(jastClass.methods, tc);
        while (istrue(iter, tc) != 0) {
            JastMethod method = new JastMethod(iter.shift_boxed(tc), jastMethod, tc);
            compileMethod(c, method, cw, className, split, tc);
        }

        // Add empty constructor.
        MethodVisitor constructor = cw.visitMethod(Opcodes.ACC_PUBLIC, "<init>", "()V", null, null);
View Full Code Here

            method.locals.put("this", new VariableDef(0, "L"+className+";", method.beginAll, method.endAll));

        m.visitCode();
        m.visitLabel(method.beginAll);

        SixModelObject iter = iter(method.instructions, tc);
        while (istrue(iter, tc) != 0) {
            SixModelObject insn = iter.shift_boxed(tc);
            compileInstruction(insn, method, m, tc);
        }

        m.visitLabel(method.endAll);
        for (Map.Entry<String, VariableDef> e : method.locals.entrySet()) {
View Full Code Here

        }
        else if (istype(insn, jastIndy, tc) != 0) {
            emitInvokeDynamic(insn, m, tc);
        }
        else if (istype(insn, jastInstructionList, tc) != 0) {
            SixModelObject iter = iter(getattr(insn, jastInstructionList, "@!instructions", 0, tc), tc);
            while (istrue(iter, tc) != 0) {
                compileInstruction(iter.shift_boxed(tc), method, m, tc);
            }
        }
        else {
            throw new Exception("Unknown JAST::Node in @!instructions");
        }
View Full Code Here

        }
    }

    private void emitInstruction(SixModelObject insn, JastMethod method, MethodVisitor m, ThreadContext tc) throws Exception {
        int instruction = (int) getattr_i(insn, jastInstruction, "$!op", 0, tc);
        SixModelObject args = getattr(insn, jastInstruction, "@!args", 1, tc);

        // Go by instruction.
        switch (instruction) {
        case 0x00: // nop
        case 0x01: //aconst_null
View Full Code Here

                ThreadContext curTC = tc.gc.getCurrentThreadContext();
                callback(curTC, task, IOType, Ops.box_s(t.toString(), Str, curTC));
            }

            protected void callback(ThreadContext tc, AsyncTaskInstance task, SixModelObject ioHandle, SixModelObject err) {
                SixModelObject result = Array.st.REPR.allocate(tc, Array.st);
                result.push_boxed(tc, task.schedulee);
                result.push_boxed(tc, ioHandle);
                result.push_boxed(tc, err);
                ((ConcBlockingQueueInstance) task.queue).push_boxed(tc, result);
            }
        };

        try {
View Full Code Here

                Type.getMethodDescriptor(returnType, argumentTypes));
    }

    private void emitInvokeDynamic(SixModelObject insn, MethodVisitor m, ThreadContext tc) {
        String name = getattr(insn, jastIndy, "$!name", 0, tc).get_str(tc);
        SixModelObject argTypesSmo = getattr(insn, jastIndy, "@!arg_types", 1, tc);
        Type retType = processType(getattr(insn, jastIndy, "$!ret_type", 2, tc).get_str(tc));
        String bsmType = getattr(insn, jastIndy, "$!bsm_type", 3, tc).get_str(tc);
        String bsmName = getattr(insn, jastIndy, "$!bsm_name", 4, tc).get_str(tc);
        SixModelObject extraArgsSmo = getattr(insn, jastIndy, "@!extra_args", 5, tc);

        int numArgs = (int) argTypesSmo.elems(tc);
        Type[] argTypes = new Type[numArgs];
        for (int i = 0; i < numArgs; i++) {
            argTypes[i] = processType(atpos(argTypesSmo, i, tc).get_str(tc));
        }

        int numExtraArgs = (int) extraArgsSmo.elems(tc);
        MethodType bsmMT = MethodType.methodType(CallSite.class, MethodHandles.Lookup.class,
                java.lang.String.class, MethodType.class);

        Object[] extraArgs = new Object[numExtraArgs];
        for (int i = 0; i < numExtraArgs; i++) {
            SixModelObject extra = atpos(extraArgsSmo, i, tc);
            if (istype(extra, jastPushI, tc) != 0) {
                extraArgs[i] = getattr_i(extra, jastPushI, "$!value", 0, tc);
                bsmMT = bsmMT.appendParameterTypes(long.class);
            }
            else if (istype(extra, jastPushN, tc) != 0) {
View Full Code Here

TOP

Related Classes of org.perl6.nqp.runtime.CallSiteDescriptor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.