Package org.perl6.nqp.sixmodel.reprs

Examples of org.perl6.nqp.sixmodel.reprs.IOHandleInstance


        return obj;
    }

    public static long closefhi(SixModelObject obj, ThreadContext tc) {
        if (obj instanceof IOHandleInstance) {
            IOHandleInstance h = (IOHandleInstance)obj;
            if (h.handle instanceof IIOClosable
             && h.handle instanceof IIOExitable) {
                ((IIOClosable)h.handle).close(tc);
                return (long)((IIOExitable)h.handle).exitValue(tc);
            }
View Full Code Here


            String value = unbox_s(iterval(kv, tc), tc);
            env.put(key, value);
        }

        SixModelObject IOType = tc.curFrame.codeRef.staticInfo.compUnit.hllConfig.ioType;
        IOHandleInstance h = (IOHandleInstance)IOType.st.REPR.allocate(tc, IOType.st);
        h.handle = new ProcessHandle(tc, cmd, dir, env);
        return h;
    }
View Full Code Here

    public static SixModelObject opendir(String path, ThreadContext tc) {
        try {
            DirectoryStream<Path> dirstrm = Files.newDirectoryStream(Paths.get(path));
            SixModelObject IOType = tc.curFrame.codeRef.staticInfo.compUnit.hllConfig.ioType;
            IOHandleInstance ioh = (IOHandleInstance)IOType.st.REPR.allocate(tc, IOType.st);
            ioh.dirstrm = dirstrm;
            ioh.diri = dirstrm.iterator();
            return ioh;
        }
        catch (Exception e) {
View Full Code Here

    }

    public static String nextfiledir(SixModelObject obj, ThreadContext tc) {
        try {
            if (obj instanceof IOHandleInstance) {
                IOHandleInstance ioh = (IOHandleInstance)obj;
                if (ioh.dirstrm != null && ioh.diri != null) {
                    if (ioh.diri.hasNext()) {
                        return ioh.diri.next().toString();
                    } else {
                        return null;
View Full Code Here

    }

    public static long closedir(SixModelObject obj, ThreadContext tc) {
        try {
            if (obj instanceof IOHandleInstance) {
                IOHandleInstance ioh = (IOHandleInstance)obj;
                ioh.diri = null;
                ioh.dirstrm.close();
                ioh.dirstrm = null;
            } else {
                die_s("closedir requires an object with the IOHandle REPR", tc);
View Full Code Here

            /* ...then an array of hashes per attribute... */
            SixModelObject attr_info_list = tc.gc.BOOTArray.st.REPR.allocate(tc, tc.gc.BOOTArray.st);
            type_info.push_boxed(tc, attr_info_list);
            List<SixModelObject> attributes = ((KnowHOWREPRInstance)self).attributes;
            for (int i = 0; i < attributes.size(); i++) {
                KnowHOWAttributeInstance attribute = (KnowHOWAttributeInstance)attributes.get(i);
                SixModelObject attr_info = tc.gc.BOOTHash.st.REPR.allocate(tc, tc.gc.BOOTHash.st);
                SixModelObject name_obj = tc.gc.BOOTStr.st.REPR.allocate(tc, tc.gc.BOOTStr.st);
                name_obj.set_str(tc, attribute.name);
                attr_info.bind_key_boxed(tc, "name", name_obj);
                attr_info.bind_key_boxed(tc, "type", attribute.type);
View Full Code Here

            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;
View Full Code Here

        /* We create a KnowHOW instance that can describe itself. This means
         * (once we tie the knot) that .HOW.HOW.HOW.HOW etc will always return
         * that, which closes the model up. */
        STable st = new STable(REPR, null);
        st.WHAT = knowhow;
        KnowHOWREPRInstance knowhow_how = (KnowHOWREPRInstance)REPR.allocate(tc, st);
        st.HOW = knowhow_how;
        knowhow_how.st = st;
       
        /* Add various methods to the KnowHOW's HOW. */
        knowhow_how.methods.put("new_type", knowhowUnit.lookupCodeRef("new_type"));
View Full Code Here

    }

    private static void bootstrapKnowHOWAttribute(ThreadContext tc, CompilationUnit knowhowUnit) {       
        /* Create meta-object. */
        SixModelObject knowhow_how = tc.gc.KnowHOW.st.HOW;
        KnowHOWREPRInstance meta_obj = (KnowHOWREPRInstance)knowhow_how.st.REPR.allocate(tc, knowhow_how.st);
       
        /* Add methods. */
        meta_obj.methods.put("new", knowhowUnit.lookupCodeRef("attr_new"));
        meta_obj.methods.put("compose", knowhowUnit.lookupCodeRef("attr_compose"));
        meta_obj.methods.put("name", knowhowUnit.lookupCodeRef("attr_name"));
View Full Code Here

        tc.gc.KnowHOWAttribute = type_obj;
    }
   
    private static SixModelObject bootType(ThreadContext tc, String typeName, String reprName) {
        SixModelObject knowhow_how = tc.gc.KnowHOW.st.HOW;
        KnowHOWREPRInstance meta_obj = (KnowHOWREPRInstance)knowhow_how.st.REPR.allocate(tc, knowhow_how.st);
        meta_obj.name = typeName;
        REPR repr = REPRRegistry.getByName(reprName);
        SixModelObject type_obj = repr.type_object_for(tc, meta_obj);
        type_obj.st.MethodCache = meta_obj.methods;
        type_obj.st.ModeFlags = STable.METHOD_CACHE_AUTHORITATIVE;
View Full Code Here

TOP

Related Classes of org.perl6.nqp.sixmodel.reprs.IOHandleInstance

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.