Examples of RubyHash


Examples of org.jruby.RubyHash

        }
    }
   

    private static String[] getCurrentEnv(Ruby runtime) {
        RubyHash hash = (RubyHash)runtime.getObject().fastGetConstant("ENV");
        String[] ret = new String[hash.size()];
        int i=0;

        for(Iterator iter = hash.directEntrySet().iterator();iter.hasNext();i++) {
            Map.Entry e = (Map.Entry)iter.next();
            ret[i] = e.getKey().toString() + "=" + e.getValue().toString();
        }

        return ret;
View Full Code Here

Examples of org.jruby.RubyHash

    }
   
    public static final int MAX_SPECIFIC_ARITY_HASH = 3;
   
    public static RubyHash constructHash(Ruby runtime, IRubyObject key1, IRubyObject value1) {
        RubyHash hash = RubyHash.newHash(runtime);
        hash.fastASet(key1, value1);
        return hash;
    }
View Full Code Here

Examples of org.jruby.RubyHash

        hash.fastASet(key1, value1);
        return hash;
    }
   
    public static RubyHash constructHash(Ruby runtime, IRubyObject key1, IRubyObject value1, IRubyObject key2, IRubyObject value2) {
        RubyHash hash = RubyHash.newHash(runtime);
        hash.fastASet(key1, value1);
        hash.fastASet(key2, value2);
        return hash;
    }
View Full Code Here

Examples of org.jruby.RubyHash

        hash.fastASet(key2, value2);
        return hash;
    }
   
    public static RubyHash constructHash(Ruby runtime, IRubyObject key1, IRubyObject value1, IRubyObject key2, IRubyObject value2, IRubyObject key3, IRubyObject value3) {
        RubyHash hash = RubyHash.newHash(runtime);
        hash.fastASet(key1, value1);
        hash.fastASet(key2, value2);
        hash.fastASet(key3, value3);
        return hash;
    }
View Full Code Here

Examples of org.jruby.RubyHash

        return createList(listNode);
    }
   
    @Override
    public IRubyObject interpret(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock) {
        RubyHash hash = RubyHash.newHash(runtime);
       
        ListNode listNode = this.listNode;
        if (listNode != null) {
            int size = listNode.size();
  
            for (int i = 0; i < size;) {
                // insert all nodes in sequence, hash them in the final instruction
                // KEY
                IRubyObject key = listNode.get(i++).interpret(runtime, context, self, aBlock);
                IRubyObject value = listNode.get(i++).interpret(runtime, context, self, aBlock);
  
                hash.fastASet(key, value);
            }
        }
     
        return hash;
    }
View Full Code Here

Examples of org.jruby.RubyHash

        return new File(runtime.getCurrentDirectory());
    }

    @SuppressWarnings("unchecked")
    public String[] getEnv() {
        RubyHash hash = (RubyHash) runtime.getObject().fastGetConstant("ENV");
        int i=0;

        String[] env = new String[hash.size()];
        for (Iterator<Entry<Object, Object>> iter = hash.directEntrySet().iterator(); iter.hasNext(); i++) {
            Map.Entry<Object, Object> entry = iter.next();
            env[i] = entry.getKey().toString() + "=" + entry.getValue().toString();
        }

        return env;
View Full Code Here

Examples of org.jruby.RubyHash

        }
        return arr;
    }

    public Object constructRubyMapping(final Node node) {
        RubyHash h1 = RubyHash.newHash(runtime, (Map)super.constructMapping(node), runtime.getNil());
        return h1;
    }
View Full Code Here

Examples of org.jruby.RubyHash

                    objClass = (RubyModule)objClass.getConstant(nms[i]);
                }
            } catch(Exception e) {
                // No constant available, so we'll fall back on YAML::Object
                objClass = (RubyClass)runtime.fastGetModule("YAML").fastGetConstant("Object");
                final RubyHash vars = (RubyHash)(((JRubyConstructor)ctor).constructRubyMapping(node));
                return RuntimeHelpers.invoke(runtime.getCurrentContext(), objClass, "new", runtime.newString(tag), vars);
            }
        }
        final RubyClass theCls = (RubyClass)objClass;
        final RubyObject oo = (RubyObject)theCls.getAllocator().allocate(runtime, theCls);
        final Map vars = (Map)(ctor.constructMapping(node));
        ctor.doRecursionFix(node, oo);
        for(final Iterator iter = vars.keySet().iterator();iter.hasNext();) {
            final IRubyObject key = (IRubyObject)iter.next();
            final Object val = vars.get(key);
            if(val instanceof LinkNode) {
                final String KEY = "@" + key.toString();
                ctor.addFixer((Node)(((LinkNode)val).getValue()), new RecursiveFixer() {
                        public void replace(Node node, Object real) {
                            oo.setInstanceVariable(KEY,(IRubyObject)real);
View Full Code Here

Examples of org.jruby.RubyHash

    }

    public static Object constructRuby(final Constructor ctor, final RubyClass theCls, final Node node) {
        final Ruby runtime = ((JRubyConstructor)ctor).runtime;
        if(theCls.respondsTo("yaml_new")) {
            final RubyHash vars = (RubyHash)(((JRubyConstructor)ctor).constructRubyMapping(node));
            return RuntimeHelpers.invoke(runtime.getCurrentContext(), theCls, "yaml_new", theCls, runtime.newString(node.getTag()), vars);
        } else {
            final RubyObject oo = (RubyObject)theCls.getAllocator().allocate(runtime, theCls);
            if (oo.respondsTo("yaml_initialize")) {
                RubyHash vars = (RubyHash)(((JRubyConstructor)ctor).constructRubyMapping(node));
                RuntimeHelpers.invoke(runtime.getCurrentContext(), oo, "yaml_initialize", runtime.newString(node.getTag()), vars);
            } else {
                final Map vars = (Map)(ctor.constructMapping(node));
                ctor.doRecursionFix(node, oo);
                for(final Iterator iter = vars.keySet().iterator();iter.hasNext();) {
                    final IRubyObject key = (IRubyObject)iter.next();
                    final Object val = vars.get(key);
                    if(val instanceof LinkNode) {
                        final String KEY = "@" + key.toString();
                        ctor.addFixer((Node)(((LinkNode)val).getValue()), new RecursiveFixer() {
                                public void replace(Node node, Object real) {
                                    oo.setInstanceVariable(KEY,(IRubyObject)real);
View Full Code Here

Examples of org.jruby.RubyHash

                    objClass = (RubyModule)objClass.getConstant(nms[i]);
                }
            } catch(Exception e) {
                // No constant available, so we'll fall back on YAML::Object
                objClass = (RubyClass)runtime.fastGetModule("YAML").fastGetConstant("Object");
                final RubyHash vars = (RubyHash)(((JRubyConstructor)ctor).constructRubyMapping(node));
                return RuntimeHelpers.invoke(runtime.getCurrentContext(), objClass, "new", runtime.newString(tag), vars);
            }
        }
        final RubyClass theCls = (RubyClass)objClass;
        return constructRuby(ctor,theCls,node);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.