コード例 #1
0
        public static Value get_defined_vars(Env env)
        {
            ArrayValue result = new ArrayValueImpl();

            Map <StringValue, EnvVar> map = env.getEnv();

            for (Map.Entry <StringValue, EnvVar> entry : map.entrySet())
            {
                result.append(entry.getKey(),
                              entry.getValue().get());
            }

            Map <StringValue, EnvVar> globalMap = env.getGlobalEnv();

            if (map != globalMap)
            {
                for (Map.Entry <StringValue, EnvVar> entry : globalMap.entrySet())
                {
                    result.append(entry.getKey(),
                                  entry.getValue().get());
                }
            }

            return(result);
        }
コード例 #2
0
        public override StringValue serialize(Env env)
        {
            ArrayValue array = new ArrayValueImpl();

            StringValue objStr   = env.createString("obj");
            StringValue valueStr = env.createString("inf");

            ObjectEntry entry = _head;

            while (entry != null)
            {
                ArrayValue inner = new ArrayValueImpl();

                inner.put(objStr, entry.getObject());
                inner.put(valueStr, entry.getValue());

                array.append(inner);

                entry = entry.getNext();
            }

            string str = VariableModule.serialize(env, array);

            return(env.createString(str));
        }
コード例 #3
0
        /**
         * Returns a PHP associative array of JSON object.
         */
        private Value decodeObjectToArray(Env env)
        {
            ArrayValue array = new ArrayValueImpl();

            _offset++;

            while (true)
            {
                skipWhitespace();

                if (_len <= _offset || _str[_offset] == '}')
                {
                    _offset++;
                    break;
                }

                Value name = jsonDecodeImpl(env, false);

                skipWhitespace();

                if (_offset >= _len || _str[_offset++] != ':')
                {
                    return(errorReturn(env, "expected ':'"));
                }

                array.append(name, jsonDecodeImpl(env, false));

                skipWhitespace();

                char ch;

                if (_offset >= _len)
                {
                    return(errorReturn(env, "expected either ',' or '}'"));
                }
                else if ((ch = _str[_offset++]) == ',')
                {
                }
                else if (ch == '}')
                {
                    break;
                }
                else
                {
                    return(errorReturn(env, "expected either ',' or '}'"));
                }
            }

            return(array);
        }
コード例 #4
0
        /**
         * Returns a non-associative PHP array.
         */
        private Value decodeArray(Env env)
        {
            ArrayValueImpl array = new ArrayValueImpl();

            _offset++;

            while (true)
            {
                skipWhitespace();

                if (_offset >= _len)
                {
                    return(errorReturn(env, "expected either ',' or ']'"));
                }

                if (_str[_offset] == ']')
                {
                    _offset++;
                    break;
                }

                array.append(jsonDecodeImpl(env, false));

                skipWhitespace();

                if (_offset >= _len)
                {
                    return(errorReturn(env, "expected either ',' or ']'"));
                }

                char ch = _str[_offset++];

                if (ch == ',')
                {
                }
                else if (ch == ']')
                {
                    break;
                }
                else
                {
                    return(errorReturn(env, "expected either ',' or ']'"));
                }
            }

            return(array);
        }