Esempio n. 1
0
        public virtual IP5ScalarBody Assign(Runtime runtime, IP5ScalarBody other)
        {
            var osb = other as P5TypeglobBody;

            if (osb == null)
                return other.CloneBody(runtime);

            scalar = osb.scalar;
            array = osb.array;
            hash = osb.hash;
            handle = osb.handle;
            code = osb.code;

            return this;
        }
Esempio n. 2
0
        public static IP5Any LocalizeHashElement(Runtime runtime, P5Hash hash, IP5Any index, ref SavedValue state)
        {
            string str_index = index.AsString(runtime);
            var saved = hash.LocalizeElement(runtime, str_index);
            var new_value = new P5Scalar(runtime);

            state.container = hash;
            state.str_key = str_index;
            state.value = saved;

            hash.SetItem(runtime, str_index, new_value);

            return new_value;
        }
Esempio n. 3
0
        public virtual IP5Any Clone(Runtime runtime, int depth)
        {
            P5Hash clone = new P5Hash(runtime);

            foreach (var e in hash)
            {
                if (depth == 0)
                    clone.hash.Add(e.Key, e.Value);
                else
                    clone.hash.Add(e.Key, e.Value.Clone(runtime, depth - 1));
            }

            return clone;
        }
Esempio n. 4
0
        public static IP5Any HashEach(Runtime runtime, Opcode.ContextValues cxt, P5Hash hash)
        {
            P5Scalar key, value;

            if (hash.NextKey(runtime, out key, out value))
            {
                if (cxt == Opcode.ContextValues.SCALAR)
                    return key;
                else
                    return new P5List(runtime, key, value);
            }
            else
            {
                if (cxt == Opcode.ContextValues.SCALAR)
                    return new P5Scalar(runtime);
                else
                    return new P5List(runtime);
            }
        }
Esempio n. 5
0
        private P5Scalar GetInit(Runtime runtime)
        {
            P5Hash init = new P5Hash(parser_runtime);

            init.SetItem(parser_runtime, "generator",
                         new P5Scalar(new P5NetWrapper(generator)));
            init.SetItem(parser_runtime, "runtime",
                         new P5Scalar(new P5NetWrapper(runtime)));

            return new P5Scalar(parser_runtime, init);
        }