Package org.perl6.nqp.sixmodel

Examples of org.perl6.nqp.sixmodel.CodePairContainerConfigurer


    private void readSocket(final ThreadContext tc, final AsyncTaskInstance task, final Decoder decoder) {
        final ByteBuffer readBuffer = ByteBuffer.allocate(32768);

        HLLConfig hllConfig = tc.curFrame.codeRef.staticInfo.compUnit.hllConfig;
        final SixModelObject Array = hllConfig.listType;
        final SixModelObject Int = hllConfig.intBoxType;
        final SixModelObject Str = hllConfig.strBoxType;
        final SixModelObject Null = hllConfig.nullValue;

        CompletionHandler<Integer, AsyncTaskInstance> handler
        = new CompletionHandler<Integer, AsyncTaskInstance>() {

            @Override
            public void completed(Integer numRead, AsyncTaskInstance task) {
                ThreadContext curTC = tc.gc.getCurrentThreadContext();

                try {
                    if (numRead == -1) {
                        task.seq = -1;
                        callback(curTC, task, -1, Str, Null);
                    } else {
                        readBuffer.flip();
                        SixModelObject decoded = decoder.decode(tc, readBuffer, numRead);
                        readBuffer.compact();

                        callback(curTC, task, task.seq++, decoded, Null);

                        channel.read(readBuffer, task, this);
                    }
                } catch (Throwable t) {
                    failed(t, task);
                }
            }

            @Override
            public void failed(Throwable t, AsyncTaskInstance task) {
                ThreadContext curTC = tc.gc.getCurrentThreadContext();
                SixModelObject err = (t instanceof AsynchronousCloseException)
                        ? Str : Ops.box_s(t.toString(), Str, curTC);
                callback(curTC, task, -1, Str, err);
            }

            protected void callback(ThreadContext tc, AsyncTaskInstance task, long seq, SixModelObject str, SixModelObject err) {
                SixModelObject result = Array.st.REPR.allocate(tc, Array.st);
                result.push_boxed(tc, task.schedulee);
                result.push_boxed(tc, Ops.box_i(seq, Int, tc));
                result.push_boxed(tc, str);
                result.push_boxed(tc, err);
                ((ConcBlockingQueueInstance) task.queue).push_boxed(tc, result);
            }
        };

        try {
View Full Code Here


    public JastMethod(SixModelObject jast, SixModelObject jastMethod, ThreadContext tc) throws Exception {
        if (istype(jast, jastMethod, tc) == 0)
            throw new Exception("JAST node isn't a JAST::Method");

        SixModelObject iter;
        beginAll = new Label();
        endAll = new Label();
        int curArgIndex = 1;

        name = getattr_s(jast, jastMethod, "$!name", nameHint, tc);
        returns = processType(getattr(jast, jastMethod, "$!returns", returnsHint, tc).get_str(tc));
        isStatic = getattr_i(jast, jastMethod, "$!static", staticHint, tc) != 0;
        if (isStatic)
            curArgIndex = 0;

        iter = iter(getattr(jast, jastMethod, "@!arguments", argumentsHint, tc), tc);
        while (istrue(iter, tc) != 0) {
            SixModelObject pair = iter.shift_boxed(tc);
            String name = pair.at_pos_boxed(tc, 0).get_str(tc);
            Type type = processType(pair.at_pos_boxed(tc, 1).get_str(tc));
            arguments.add(type);
            if (locals.containsKey(name))
                throw new Exception("Duplicate local name: " + name);
            locals.put(name, new VariableDef(curArgIndex, type.getDescriptor(), beginAll, endAll));
            curArgIndex += (type == Type.LONG_TYPE || type == Type.DOUBLE_TYPE ? 2 : 1);
        }

        iter = iter(getattr(jast, jastMethod, "@!locals", localsHint, tc), tc);
        while (istrue(iter, tc) != 0) {
            SixModelObject pair = iter.shift_boxed(tc);
            String name = pair.at_pos_boxed(tc, 0).get_str(tc);
            Type type = processType(pair.at_pos_boxed(tc, 1).get_str(tc));
            if (locals.containsKey(name))
                throw new Exception("Duplicate local name: " + name);
            locals.put(name, new VariableDef(curArgIndex, type.getDescriptor(), beginAll, endAll));
            curArgIndex += (type == Type.LONG_TYPE || type == Type.DOUBLE_TYPE ? 2 : 1);
        }

        instructions = getattr(jast, jastMethod, "@!instructions", instructionsHint, tc);

        crName = getattr_s(jast, jastMethod, "$!cr_name", crNameHint, tc);
        crCuid = getattr_s(jast, jastMethod, "$!cr_cuid", crCuidHint, tc);
        crOuter = (int) getattr_i(jast, jastMethod, "$!cr_outer", crOuterHint, tc);

        fillList(crOlex, getattr(jast, jastMethod, "@!cr_olex", crOlexHint, tc), tc);
        fillList(crIlex, getattr(jast, jastMethod, "@!cr_ilex", crIlexHint, tc), tc);
        fillList(crNlex, getattr(jast, jastMethod, "@!cr_nlex", crNlexHint, tc), tc);
        fillList(crSlex, getattr(jast, jastMethod, "@!cr_slex", crSlexHint, tc), tc);

        SixModelObject handlersList = getattr(jast, jastMethod, "@!cr_handlers", crHandlersHint, tc);
        iter = iter(handlersList, tc);
        crHandlers = new long[(int) elems(handlersList, tc)];
        for (int i = 0; istrue(iter, tc) != 0; i++) {
            crHandlers[i] = iter.shift_boxed(tc).get_int(tc);
        }
View Full Code Here

            /* Most likely a version of the node without the field. */
        }
    }

    private void fillList(List<String> list, SixModelObject smoList, ThreadContext tc) {
        SixModelObject iter = iter(smoList, tc);
        while(istrue(iter, tc) != 0) {
            String value = iter.shift_boxed(tc).get_str(tc);
            list.add(value);
        }
    }
View Full Code Here

import org.perl6.nqp.runtime.ThreadContext;

public class CStruct extends REPR {
    public SixModelObject type_object_for(ThreadContext tc, SixModelObject HOW) {
        STable st = new STable(this, HOW);
        SixModelObject obj = new TypeObject();
        obj.st = st;
        st.WHAT = obj;
        return st.WHAT;
    }
View Full Code Here

        st.WHAT = obj;
        return st.WHAT;
    }

    public void compose(ThreadContext tc, STable st, SixModelObject repr_info_hash) {
        SixModelObject repr_info = repr_info_hash.at_key_boxed(tc, "attribute");
        CStructREPRData repr_data = new CStructREPRData();

        long mroLength = repr_info.elems(tc);
        List<AttrInfo> attrInfos = new ArrayList<AttrInfo>();
        for (long i = mroLength - 1; i >= 0; i--) {
            SixModelObject entry = repr_info.at_pos_boxed(tc, i);
            SixModelObject attrs = entry.at_pos_boxed(tc, 1);
            long parents = entry.at_pos_boxed(tc, 2).elems(tc);

            if (parents <= 1) {
                long numAttrs = attrs.elems(tc);
                for (long j = 0; j < numAttrs; j++) {
                    SixModelObject attrHash = attrs.at_pos_boxed(tc, j);
                    AttrInfo info = new AttrInfo();
                    info.name = attrHash.at_key_boxed(tc, "name").get_str(tc);
                    info.type = attrHash.at_key_boxed(tc, "type");
                    StorageSpec spec = info.type.st.REPR.get_storage_spec(tc, info.type.st);
                    info.bits = spec.bits;
                    repr_data.fieldTypes.put(info.name, info);

                    if (info.type == null) {
View Full Code Here

import org.perl6.nqp.sixmodel.TypeObject;

public class CallCapture extends REPR {
    public SixModelObject type_object_for(ThreadContext tc, SixModelObject HOW) {
        STable st = new STable(this, HOW);
        SixModelObject obj = new TypeObject();
        obj.st = st;
        st.WHAT = obj;
        return st.WHAT;
    }
View Full Code Here

import org.perl6.nqp.sixmodel.TypeObject;

public class MultiCache extends REPR {
    public SixModelObject type_object_for(ThreadContext tc, SixModelObject HOW) {
        STable st = new STable(this, HOW);
        SixModelObject obj = new TypeObject();
        obj.st = st;
        st.WHAT = obj;
        return st.WHAT;
    }
View Full Code Here

import org.perl6.nqp.sixmodel.TypeObject;

public class VMHash extends REPR {
    public SixModelObject type_object_for(ThreadContext tc, SixModelObject HOW) {
        STable st = new STable(this, HOW);
        SixModelObject obj = new TypeObject();
        obj.st = st;
        st.WHAT = obj;
        return st.WHAT;
    }
View Full Code Here

            SerializationReader reader, SixModelObject obj) {
        HashMap<String, SixModelObject> storage = ((VMHashInstance)obj).storage;
        int elems = reader.readInt32();
        for (int i = 0; i < elems; i++) {
            String key = reader.readStr();
            SixModelObject value = reader.readRef();
            storage.put(key, value);
        }
    }
View Full Code Here

import org.perl6.nqp.sixmodel.TypeObject;

public class VMIter extends REPR {
    public SixModelObject type_object_for(ThreadContext tc, SixModelObject HOW) {
        STable st = new STable(this, HOW);
        SixModelObject obj = new TypeObject();
        obj.st = st;
        st.WHAT = obj;
        return st.WHAT;
    }
View Full Code Here

TOP

Related Classes of org.perl6.nqp.sixmodel.CodePairContainerConfigurer

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.