Package org.perl6.nqp.sixmodel

Examples of org.perl6.nqp.sixmodel.SixModelObject


    public SixModelObject shift_boxed(ThreadContext tc) {
        if (elems < 1)
            throw ExceptionHandling.dieInternal(tc, "VMArray: Can't shift from an empty array");

        SixModelObject result = slots[start];
        start++;
        elems--;
        return result;
    }
View Full Code Here


import org.perl6.nqp.sixmodel.TypeObject;

public class ReentrantMutex 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 IOHandle 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

        if (child_objs[intidx] != null) {
            return child_objs[intidx];
        }
        else {
            SixModelObject obj = makeObject(tc, storage.getPointer(index*repr_data.jna_size));
            child_objs[intidx] = obj;
            return obj;
        }
    }
View Full Code Here

    /**
     * Refresh logic for CArray of complex (CArray or CStruct) types.
     */
    private void refreshComplex(ThreadContext tc) {
        for (int i = 0; i < child_objs.length; i++) {
            SixModelObject child = child_objs[i];

            // No cache for this element? Go to next.
            if (child == null) continue;

            /* Invalidate cache and recursively refresh child too. Future
View Full Code Here

    /**
     * Refresh logic for CArray of simple (CPointer) types.
     */
    private void refreshSimple(ThreadContext tc) {
        for (int i = 0; i < child_objs.length; i++) {
            SixModelObject child = child_objs[i];

            // No cache for this element? Go to next.
            if (child == null) continue;

            /* Invalidate cache. Future versions here should only invalidate
View Full Code Here

    private static ObjectCache<String, Class<?>> classCache = new ObjectCache< >();

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

    }
   
    @SuppressWarnings("unchecked") // Because Java implemented generics stupidly
    public void compose(ThreadContext tc, STable st, SixModelObject repr_info_hash) {
        /* Get attribute part of the protocol from the hash. */
        SixModelObject repr_info = repr_info_hash.at_key_boxed(tc, "attribute");

        /* Go through MRO and find all classes with attributes and build up
         * mapping info hashes. Note, reverse order so indexes will match
         * those in parent types. */
        int curAttr = 0;
        boolean mi = false;
        List<SixModelObject> classHandles = new ArrayList<SixModelObject>();
        List<HashMap<String, Integer>> attrIndexes = new ArrayList<HashMap<String, Integer>>();
        List<SixModelObject> autoVivs = new ArrayList<SixModelObject>();
        List<STable> flattenedSTables = new ArrayList<STable>();
        List<AttrInfo> attrInfoList = new ArrayList<AttrInfo>();
        long mroLength = repr_info.elems(tc);
        for (long i = mroLength - 1; i >= 0; i--) {
            SixModelObject entry = repr_info.at_pos_boxed(tc, i);
            SixModelObject type = entry.at_pos_boxed(tc, 0);
            SixModelObject attrs = entry.at_pos_boxed(tc, 1);
            SixModelObject parents = entry.at_pos_boxed(tc, 2);
           
            /* If it has any attributes, give them each indexes and put them
             * in the list to add to the layout. */
            long numAttrs = attrs.elems(tc);
            if (numAttrs > 0) {
                HashMap<String, Integer> indexes = new HashMap<String, Integer>();
                for (long j = 0; j < numAttrs; j++) {
                    SixModelObject attrHash = attrs.at_pos_boxed(tc, j);
                    String attrName = attrHash.at_key_boxed(tc, "name").get_str(tc);
                    SixModelObject attrType = attrHash.at_key_boxed(tc, "type");
                    if (attrType == null)
                        attrType = tc.gc.KnowHOW;
                    indexes.put(attrName, curAttr);
                    AttrInfo info = new AttrInfo();
                    info.st = attrType.st;
                    if (attrType.st.REPR.get_storage_spec(tc, attrType.st).inlineable == StorageSpec.INLINED)
                        flattenedSTables.add(attrType.st);
                    else
                        flattenedSTables.add(null);
                    info.boxTarget = attrHash.exists_key(tc, "box_target") != 0;
                    SixModelObject autoViv = attrHash.at_key_boxed(tc, "auto_viv_container");
                    autoVivs.add(autoViv);
                    if (autoViv != null)
                        info.hasAutoVivContainer = true;
                    info.posDelegate = attrHash.exists_key(tc, "positional_delegate") != 0;
                    info.assDelegate = attrHash.exists_key(tc, "associative_delegate") != 0;
View Full Code Here

        // Note the condition below works because we don't make an entry in the
        // class handles list for a type with no attributes.
        P6OpaqueBaseInstance instance = (P6OpaqueBaseInstance)obj;
        if (ourREPRData.classHandles.length != targetREPRData.classHandles.length) {
            // Create delegate.
            SixModelObject delegate = newType.st.REPR.allocate(tc, newType.st);
           
            // Find original object.
            SixModelObject orig;
            if (instance.delegate != null)
                orig = instance.delegate;
            else
                orig = obj;
           
            // Copy over current attribute values.
            Field[] fromFields = orig.getClass().getFields();
            Field[] toFields = delegate.getClass().getFields();
            try {
                for (int i = 0; i < fromFields.length - 3; i++)
                    toFields[i].set(delegate, fromFields[i].get(orig));
            }
View Full Code Here

        // Read in the name to index mapping.
        int numClasses = (int)reader.readLong();
        ArrayList<SixModelObject> classHandles = new ArrayList<SixModelObject>();
        ArrayList<HashMap<String, Integer>> nameToHintMaps = new ArrayList<HashMap<String, Integer>>();
        for (int i = 0; i < numClasses; i++) {
            SixModelObject classHandle = reader.readRef();
            SixModelObject nameToHintObject = reader.readRef();
            if (nameToHintObject == null) {
                /* Nothing to do. */
            }
            else if (nameToHintObject instanceof VMHashInstance) {
                HashMap<String, Integer> nameToHintMap = new HashMap<String, Integer>();
View Full Code Here

TOP

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

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.