Package org.perl6.metamodel.metaclass

Examples of org.perl6.metamodel.metaclass.Dispatcher


            cf.leave();
        }
    }

    public void methods(ThreadContext tc, CodeRef cr, CallSiteDescriptor csd, Object[] args) {
        CallFrame cf = new CallFrame(tc, cr);
        try {
            csd = Ops.checkarity(cf, csd, args, 2, 2);
            args = tc.flatArgs;
            SixModelObject self = Ops.posparam_o(cf, csd, args, 0);
           
            if (self == null || !(self instanceof KnowHOWREPRInstance))
                throw ExceptionHandling.dieInternal(tc, "KnowHOW methods must be called on object instance with REPR KnowHOWREPR");
           
            SixModelObject BOOTHash = tc.gc.BOOTHash;
            SixModelObject result = BOOTHash.st.REPR.allocate(tc, BOOTHash.st);
           
            HashMap<String, SixModelObject> methods = ((KnowHOWREPRInstance)self).methods;
            for (String name : methods.keySet())
                result.bind_key_boxed(tc, name, methods.get(name));
           
            Ops.return_o(result, cf);
        }
        finally {
            cf.leave();
        }
    }
View Full Code Here


            cf.leave();
        }
    }
   
    public void name(ThreadContext tc, CodeRef cr, CallSiteDescriptor csd, Object[] args) {
        CallFrame cf = new CallFrame(tc, cr);
        try {
            csd = Ops.checkarity(cf, csd, args, 2, 2);
            args = tc.flatArgs;
            SixModelObject self = Ops.posparam_o(cf, csd, args, 0);
           
            if (self == null || !(self instanceof KnowHOWREPRInstance))
                throw ExceptionHandling.dieInternal(tc, "KnowHOW methods must be called on object instance with REPR KnowHOWREPR");
   
            Ops.return_s(((KnowHOWREPRInstance)self).name, cf);
        }
        finally {
            cf.leave();
        }
    }
View Full Code Here

            cf.leave();
        }
    }
   
    public void attr_new(ThreadContext tc, CodeRef cr, CallSiteDescriptor csd, Object[] args) {
        CallFrame cf = new CallFrame(tc, cr);
        try {
            /* Process arguments. */
            csd = Ops.checkarity(cf, csd, args, 1, 1);
            args = tc.flatArgs;
            SixModelObject self = Ops.posparam_o(cf, csd, args, 0);
            String name_arg = Ops.namedparam_s(cf, csd, args, "name");
            SixModelObject type_arg = Ops.namedparam_opt_o(cf, csd, args, "type");
            long bt_arg = Ops.namedparam_opt_i(cf, csd, args, "box_target");
   
            /* Allocate attribute object. */
            REPR repr = REPRRegistry.getByName("KnowHOWAttribute");
            KnowHOWAttributeInstance obj = (KnowHOWAttributeInstance)repr.allocate(tc, self.st);
           
            /* Populate it. */
            obj.name = name_arg;
            obj.type = type_arg != null ? type_arg : tc.gc.KnowHOW;
            obj.box_target = bt_arg == 0 ? 0 : 1;
           
            /* Return produced object. */
            Ops.return_o(obj, cf);
        }
        finally {
            cf.leave();
        }
    }
View Full Code Here

            cf.leave();
        }
    }

    public void attr_compose(ThreadContext tc, CodeRef cr, CallSiteDescriptor csd, Object[] args) {
        CallFrame cf = new CallFrame(tc, cr);
        try {
            csd = Ops.checkarity(cf, csd, args, 1, 1);
            args = tc.flatArgs;
            SixModelObject self = Ops.posparam_o(cf, csd, args, 0);
            Ops.return_o(self, cf);
        }
        finally {
            cf.leave();
        }
    }
View Full Code Here

            cf.leave();
        }
    }

    public void attr_name(ThreadContext tc, CodeRef cr, CallSiteDescriptor csd, Object[] args) {
        CallFrame cf = new CallFrame(tc, cr);
        try {
            csd = Ops.checkarity(cf, csd, args, 1, 1);
            args = tc.flatArgs;
            SixModelObject self = Ops.posparam_o(cf, csd, args, 0);
            Ops.return_s(((KnowHOWAttributeInstance)self).name, cf);
        }
        finally {
            cf.leave();
        }
    }
View Full Code Here

            cf.leave();
        }
    }

    public void attr_type(ThreadContext tc, CodeRef cr, CallSiteDescriptor csd, Object[] args) {
        CallFrame cf = new CallFrame(tc, cr);
        try {
            csd = Ops.checkarity(cf, csd, args, 1, 1);
            args = tc.flatArgs;
            SixModelObject self = Ops.posparam_o(cf, csd, args, 0);
            Ops.return_o(((KnowHOWAttributeInstance)self).type, cf);
        }
        finally {
            cf.leave();
        }
    }
View Full Code Here

            cf.leave();
        }
    }

    public void attr_box_target(ThreadContext tc, CodeRef cr, CallSiteDescriptor csd, Object[] args) {
        CallFrame cf = new CallFrame(tc, cr);
        try {
            csd = Ops.checkarity(cf, csd, args, 1, 1);
            args = tc.flatArgs;
            SixModelObject self = Ops.posparam_o(cf, csd, args, 0);
            Ops.return_i(((KnowHOWAttributeInstance)self).box_target, cf);
        }
        finally {
            cf.leave();
        }
    }
View Full Code Here

            /* Resolve the reference to the static code object this context is for. */
            CodeRef staticCode = readCodeRef();

            /* Create a context and set it up. */
            CallFrame ctx = new CallFrame();
            ctx.tc = tc;
            ctx.codeRef = staticCode;
            StaticCodeInfo sci = staticCode.staticInfo;
            if (sci.oLexicalNames != null)
                ctx.oLex = sci.oLexStatic.clone();
View Full Code Here

        nqpComp = Ops.getcomp(hll, t);
    }

    private SixModelObject eval(String nqp) {
        Ops.invokeDirect(t, Ops.findmethod(t, nqpComp, "compile"),
                new CallSiteDescriptor(new byte[] { ARG_OBJ, ARG_STR }, null),
                new Object[] { nqpComp, nqp });

        Ops.invokeDirect(t, Ops.result_o(t.resultFrame()), Ops.emptyCallSite, Ops.emptyArgList);
        return Ops.result_o(t.resultFrame());
    }
View Full Code Here

        long[][] hnull = new long[0][];
        MethodType mt = MethodType.methodType(void.class, ThreadContext.class,
                CodeRef.class, CallSiteDescriptor.class, Object[].class);
        Lookup l = MethodHandles.lookup();
        try {
            refs[0] = new CodeRef(this, l.findVirtual(KnowHOWMethods.class, "new_type", mt).bindTo(this),
                    "new_type", "new_type", snull, snull, snull, snull, hnull, (short)0);
            refs[1] = new CodeRef(this, l.findVirtual(KnowHOWMethods.class, "add_method", mt).bindTo(this),
                    "add_method", "add_method", snull, snull, snull, snull, hnull, (short)0);
            refs[2] = new CodeRef(this, l.findVirtual(KnowHOWMethods.class, "add_attribute", mt).bindTo(this),
                    "add_attribute", "add_attribute", snull, snull, snull, snull, hnull, (short)0);
            refs[3] = new CodeRef(this, l.findVirtual(KnowHOWMethods.class, "compose", mt).bindTo(this),
                    "compose", "compose", snull, snull, snull, snull, hnull, (short)0);
            refs[4] = new CodeRef(this, l.findVirtual(KnowHOWMethods.class, "attributes", mt).bindTo(this),
                    "attributes", "attributes", snull, snull, snull, snull, hnull, (short)0);
            refs[5] = new CodeRef(this, l.findVirtual(KnowHOWMethods.class, "methods", mt).bindTo(this),
                    "methods", "methods", snull, snull, snull, snull, hnull, (short)0);
            refs[6] = new CodeRef(this, l.findVirtual(KnowHOWMethods.class, "name", mt).bindTo(this),
                    "name", "name", snull, snull, snull, snull, hnull, (short)0);
            refs[7] = new CodeRef(this, l.findVirtual(KnowHOWMethods.class, "attr_new", mt).bindTo(this),
                    "new", "attr_new", snull, snull, snull, snull, hnull, (short)0);
            refs[8] = new CodeRef(this, l.findVirtual(KnowHOWMethods.class, "attr_compose", mt).bindTo(this),
                    "compose", "attr_compose", snull, snull, snull, snull, hnull, (short)0);
            refs[9] = new CodeRef(this, l.findVirtual(KnowHOWMethods.class, "attr_name", mt).bindTo(this),
                    "name", "attr_name", snull, snull, snull, snull, hnull, (short)0);
            refs[10] = new CodeRef(this, l.findVirtual(KnowHOWMethods.class, "attr_type", mt).bindTo(this),
                    "type", "attr_type", snull, snull, snull, snull, hnull, (short)0);
            refs[11] = new CodeRef(this, l.findVirtual(KnowHOWMethods.class, "attr_box_target", mt).bindTo(this),
                    "box_target", "attr_box_target", snull, snull, snull, snull, hnull, (short)0);
        }
        catch (Exception e) {
            throw new RuntimeException(e);
        }
View Full Code Here

TOP

Related Classes of org.perl6.metamodel.metaclass.Dispatcher

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.