Package org.perl6.nqp.sixmodel

Examples of org.perl6.nqp.sixmodel.SixModelObject


        } catch (ReflectiveOperationException roe) {
            throw new RuntimeException(roe);
        }
        adaptorUnit.initializeCompilationUnit(tc);

        SixModelObject hash = gc.BOOTHash.st.REPR.allocate(tc, gc.BOOTHash.st);

        HashMap<String, SixModelObject> names = new HashMap< >();

        for (int i = 0; i < adaptor.descriptors.size(); i++) {
            String desc = adaptor.descriptors.get(i);
            SixModelObject cr = adaptorUnit.lookupCodeRef(i);

            int s1 = desc.indexOf('/');
            int s2 = desc.indexOf('/', s1+1);

            String shorten = desc.substring(s1+1, s2);
            names.put(shorten, names.containsKey(shorten) ? null : cr);
            names.put(desc, cr);
        }

        for (Iterator<Map.Entry<String, SixModelObject>> it = names.entrySet().iterator(); it.hasNext(); ) {
            Map.Entry<String, SixModelObject> ent = it.next();
            if (ent.getValue() != null)
                hash.bind_key_boxed(tc, ent.getKey(), ent.getValue());
            else
                it.remove();
        }

        STable protoSt = gc.BOOTJava.st;
        SixModelObject freshType = protoSt.REPR.type_object_for(tc, computeHOW(tc, klass.getName()));
        freshType.st.MethodCache = names;
        freshType.st.ModeFlags |= STable.METHOD_CACHE_AUTHORITATIVE;

        hash.bind_key_boxed(tc, "/TYPE/", freshType);
View Full Code Here


    /* Throws a simple string exception for some internal error, using our own
     * handler model. Note the exception is not resumable. */
    private static RuntimeException stooge = new RuntimeException("Stooge exception leaked");
    private static ThreadDeath death = new ThreadDeath();
    private static RuntimeException dieInternal(ThreadContext tc, String msg, Throwable t) {
        SixModelObject exType;
        VMExceptionInstance exObj;
        if (tc.gc.noisyExceptions) {
            if (t == null) t = new Throwable(msg);
            t.printStackTrace();
        }
View Full Code Here

        int oldNameIdx = 0;
       
        for (byte af : argFlags) {
            switch (af) {
            case ARG_OBJ | ARG_FLAT:
                SixModelObject flatArray = (SixModelObject)oldArgs[oldArgsIdx++];
                int prim = flatArray.st.REPR.get_value_storage_spec(cf.tc, flatArray.st).boxed_primitive;
                long elems = flatArray.elems(cf.tc);
                for (long i = 0; i < elems; i++) {
                    if (prim == StorageSpec.BP_NONE) {
                        newArgs.add(flatArray.at_pos_boxed(cf.tc, i));
                        newFlags.add(ARG_OBJ);
                    } else {
                        flatArray.at_pos_native(cf.tc, i);
                        switch (prim) {
                            case StorageSpec.BP_INT:
                                newArgs.add(cf.tc.native_i);
                                newFlags.add(ARG_INT);
                                break;
                            case StorageSpec.BP_NUM:
                                newArgs.add(cf.tc.native_n);
                                newFlags.add(ARG_NUM);
                                break;
                            case StorageSpec.BP_STR:
                                newArgs.add(cf.tc.native_s);
                                newFlags.add(ARG_STR);
                                break;
                            default:
                                throw ExceptionHandling.dieInternal(cf.tc, "Unknown boxed primitive");
                        }
                    }
                }
                break;
            case ARG_OBJ | ARG_FLAT | ARG_NAMED:
                SixModelObject flatHash = (SixModelObject)oldArgs[oldArgsIdx++];
                if (flatHash instanceof VMHashInstance) {
                    HashMap<String, SixModelObject> storage = ((VMHashInstance)flatHash).storage;
                    for (String key : storage.keySet()) {
                        newNames.add(key);
                        newArgs.add(storage.get(key));
View Full Code Here

import org.perl6.nqp.sixmodel.TypeObject;

public class VMThread 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

public class CArray extends REPR {
    public SixModelObject type_object_for(ThreadContext tc, SixModelObject HOW) {
        STable st = new STable(this, HOW);
        st.REPRData = null; /* No REPR data yet. */
        SixModelObject obj = new TypeObject();
        obj.st = st;
        st.WHAT = obj;
        return st.WHAT;
    }
View Full Code Here

    }

    private void fillREPRData(ThreadContext tc, STable st) {
        CArrayREPRData data = new CArrayREPRData();

        SixModelObject meth = Ops.findmethod(st.WHAT, "of", tc);
        if (meth == null)
            ExceptionHandling.dieInternal(tc, "CArray representation expects an 'of' method, specifying the element type");

        Ops.invokeDirect(tc, meth, new CallSiteDescriptor(new byte[] { ARG_OBJ }, null), new Object[] { st.WHAT });
        data.elem_type = Ops.decont(Ops.result_o(tc.resultFrame()), tc);
View Full Code Here

public class CPointer extends REPR {
    public SixModelObject type_object_for(ThreadContext tc, SixModelObject HOW) {
        STable st = new STable(this, HOW);
        st.REPRData = null; /* No REPR data needed. */
        SixModelObject obj = new TypeObject();
        obj.st = st;
        st.WHAT = obj;
        return st.WHAT;
    }
View Full Code Here

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

    public SixModelObject allocate(ThreadContext tc, STable st) {
        SixModelObject obj = new CPointerInstance();
        obj.st = st;
        return obj;
    }
View Full Code Here

import org.perl6.nqp.sixmodel.TypeObject;

public class Continuation 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 JavaWrap 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.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.