Package Rakudo.Metamodel

Examples of Rakudo.Metamodel.RakudoObject


    /// <param name="Value"></param>
    /// <returns></returns>
    public static RakudoObject box_int(ThreadContext tc, int value, RakudoObject to)
    {
        Representation REPR = to.getSTable().REPR;
        RakudoObject result = REPR.instance_of(tc, to);
        REPR.set_int(tc, result, value);
        return result;
    }
View Full Code Here


    /// </summary>
    /// <param name="Value"></param>
    /// <returns></returns>
    public static RakudoObject box_int(ThreadContext tc, int value)
    {
        RakudoObject result = tc.DefaultIntBoxType.getSTable().REPR.instance_of(tc, tc.DefaultIntBoxType);
        tc.DefaultIntBoxType.getSTable().REPR.set_int(tc, result, value);
        return result;
    }
View Full Code Here

    /// <param name="Value"></param>
    /// <returns></returns>
    public static RakudoObject box_num(ThreadContext tc, double value, RakudoObject to)
    {
        Representation REPR = to.getSTable().REPR;
        RakudoObject result = REPR.instance_of(tc, to);
        REPR.set_num(tc, result, value);
        return result;
    }
View Full Code Here

    /// </summary>
    /// <param name="Value"></param>
    /// <returns></returns>
    public static RakudoObject box_num(ThreadContext tc, int value)
    {
        RakudoObject result = tc.DefaultNumBoxType.getSTable().REPR.instance_of(tc, tc.DefaultNumBoxType);
        tc.DefaultNumBoxType.getSTable().REPR.set_num(tc, result, value);
        return result;
    }
View Full Code Here

    /// <param name="Value"></param>
    /// <returns></returns>
    public static RakudoObject box_str(ThreadContext tc, String value, RakudoObject to)
    {
        Representation REPR = to.getSTable().REPR;
        RakudoObject result = REPR.instance_of(tc, to);
        REPR.set_str(tc, result, value);
        return result;
    }
View Full Code Here

    /// </summary>
    /// <param name="Value"></param>
    /// <returns></returns>
    public static RakudoObject box_str(ThreadContext tc, String value)
    {
        RakudoObject result = tc.DefaultStrBoxType.getSTable().REPR.instance_of(tc, tc.DefaultStrBoxType);
        tc.DefaultStrBoxType.getSTable().REPR.set_str(tc, result, value);
        return result;
    }
View Full Code Here

        while (curOuter != null)
        {
            RakudoCodeRef.Instance codeObj = curOuter.StaticCodeObject;
            if (codeObj.Dispatchees != null)
            {
                RakudoObject candidate = MultiDispatcher.FindBestCandidate(
                    codeObj, curOuter.Capture);
                return candidate.getSTable().Invoke(tc, candidate, curOuter.Capture);
            }
            curOuter = curOuter.Outer;
        }
        throw new UnsupportedOperationException("Could not find dispatchee list!");
    }
View Full Code Here

            int idx = store.size() - 1;
            if (idx < 0)
            {
                throw new IndexOutOfBoundsException("Cannot pop from an empty list");
            }
            RakudoObject item = store.get(idx);
            store.remove(idx);
            return item;
        }
        else
        {
View Full Code Here

            int idx = store.size() - 1;
            if (idx < 0)
            {
                throw new IndexOutOfBoundsException("Cannot shift from an empty list");
            }
            RakudoObject item = store.get(0);
            store.remove(0);
            return item;
        }
        else
        {
View Full Code Here

        P6capture.Instance nativeCapture = (P6capture.Instance)capture;

        // First, try the dispatch cache.
        if (dispatchRoutine.MultiDispatchCache != null && nativeCapture.Nameds == null)
        {
            RakudoObject cacheResult = dispatchRoutine.MultiDispatchCache.Lookup(nativeCapture.Positionals);
            if (cacheResult != null)
                return cacheResult;
        }

        // Sort the candidates.
        // XXX Cache this in the future.
        ArrayList<RakudoObject> sortedCandidates = candidateSort(dispatchRoutine.Dispatchees);

        // Now go through the sorted candidates and find the first one that
        // matches.
        ArrayList<RakudoCodeRef.Instance> possiblesList = new ArrayList<RakudoCodeRef.Instance>();
        for (RakudoObject candidateObject : sortedCandidates)
        {
            // TODO: remove yukky type cast
            RakudoCodeRef.Instance candidate = (RakudoCodeRef.Instance)candidateObject;
            // If we hit a null, we're at the end of a group.
            if (candidate == null)
            {
                if (possiblesList.size() == 1)
                {
                    // We have an unambiguous first candidate. Cache if possible and
                    // return it.
                    if (nativeCapture.Nameds == null)
                    {
                        if (dispatchRoutine.MultiDispatchCache == null)
                            dispatchRoutine.MultiDispatchCache = new DispatchCache();
                        dispatchRoutine.MultiDispatchCache.Add(nativeCapture.Positionals, possiblesList.get(0));
                    }
                    return possiblesList.get(0);
                }
                else if (possiblesList.size() > 1)
                {
                    // Here is where you'd handle constraints.
                    throw new UnsupportedOperationException("Ambiguous dispatch: more than one candidate matches");
                }
                else
                {
                    continue;
                }
            }
           
            /* Check if it's admissible by arity. */
            int numArgs = nativeCapture.Positionals.length;
            if (numArgs < candidate.Sig.NumRequiredPositionals ||
                numArgs > candidate.Sig.NumPositionals)
                continue;

            /* Check if it's admissible by type. */
            int typeCheckCount = Math.min(numArgs, candidate.Sig.NumPositionals);
            boolean typeMismatch = false;
            for (int i = 0; i < typeCheckCount; i++) {
                RakudoObject arg = nativeCapture.Positionals[i];
                RakudoObject type = candidate.Sig.Parameters[i].Type;
                if (arg.getSTable().WHAT != type && type != null)
                {
                    typeMismatch = true;
                    break;
                }
View Full Code Here

TOP

Related Classes of Rakudo.Metamodel.RakudoObject

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.