gt:     entry = createEntry(name);
context: /*
   * Copyright (c) 1998-2012 Caucho Technology -- all rights reserved
   *
   * This file is part of Resin(R) Open Source
   *
   * Each copy or derived work must preserve the copyright notice and this
   * notice unmodified.
   *
   * Resin Open Source is free software; you can redistribute it and/or modify
   * it under the terms of the GNU General Public License as published by
   * the Free Software Foundation; either version 2 of the License, or
   * (at your option) any later version.
   *
   * Resin Open Source is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
   * of NON-INFRINGEMENT.  See the GNU General Public License for more
   * details.
   *
   * You should have received a copy of the GNU General Public License
   * along with Resin Open Source; if not, write to the
   *
   *   Free Software Foundation, Inc.
   *   59 Temple Place, Suite 330
   *   Boston, MA 02111-1307  USA
   *
   * @author Scott Ferguson
   */
  
  package com.caucho.quercus.env;
  
  import com.caucho.quercus.function.AbstractFunction;
  import com.caucho.quercus.program.ClassField;
  import com.caucho.util.CurrentTime;
  import com.caucho.vfs.WriteStream;
  
  import java.io.IOException;
  import java.io.ObjectInputStream;
  import java.io.ObjectOutputStream;
  import java.io.Serializable;
  import java.util.AbstractSet;
  import java.util.HashMap;
  import java.util.IdentityHashMap;
  import java.util.Iterator;
  import java.util.LinkedHashMap;
  import java.util.Map;
  import java.util.Set;
  
  /**
   * Represents a PHP object value.
   */
  @SuppressWarnings("serial")
  public class ObjectExtValue extends ObjectValue
    implements Serializable
  {
    private MethodMap<AbstractFunction> _methodMap;
  
    private LinkedHashMap<StringValue,Entry> _fieldMap
      = new LinkedHashMap<StringValue,Entry>();
  
    private HashMap<StringValue,Entry> _protectedFieldMap;
  
    private boolean _isFieldInit;
  
    public ObjectExtValue(Env env, QuercusClass cl)
    {
      super(env, cl);
  
      _methodMap = cl.getMethodMap();
    }
  
    public ObjectExtValue(Env env, ObjectExtValue copy, CopyRoot root)
    {
      super(env, copy.getQuercusClass());
  
      root.putCopy(copy, this);
  
      _methodMap = copy._methodMap;
  
      _isFieldInit = copy._isFieldInit;
  
      for (Map.Entry<StringValue,Entry> entry : copy._fieldMap.entrySet()) {
        Entry entryCopy = entry.getValue().copyTree(env, root);
  
        _fieldMap.put(entry.getKey(), entryCopy);
      }
  
      _incompleteObjectName = copy._incompleteObjectName;
    }
  
    public ObjectExtValue(Env env,
                          IdentityHashMap<Value,Value> copyMap,
                          ObjectExtValue copy)
    {
      super(env, copy.getQuercusClass());
  
      _methodMap = copy._methodMap;
  
      _isFieldInit = copy._isFieldInit;
  
      for (Map.Entry<StringValue,Entry> entry : copy._fieldMap.entrySet()) {
        Entry entryCopy = new Entry(env, copyMap, entry.getValue());
  
        _fieldMap.put(entry.getKey(), entryCopy);
      }
  
      _incompleteObjectName = copy._incompleteObjectName;
    }
  
    private void init()
    {
      _fieldMap = new LinkedHashMap<StringValue,Entry>();
    }
  
    @Override
    public void setQuercusClass(QuercusClass cl)
    {
      super.setQuercusClass(cl);
  
      _methodMap = cl.getMethodMap();
    }
  
    /**
     * Initializes the incomplete class.
     */
    @Override
    public void initObject(Env env, QuercusClass cls)
    {
      setQuercusClass(cls);
      _incompleteObjectName = null;
  
      LinkedHashMap<StringValue,Entry> existingFields = _fieldMap;
      _fieldMap = new LinkedHashMap<StringValue,Entry>();
  
      cls.initObject(env, this);
  
      Iterator<Entry> iter = existingFields.values().iterator();
  
      while (iter.hasNext()) {
        Entry newField = iter.next();
  
        Entry entry = createEntryFromInit(newField.getKey());
        entry._value = newField._value;
  
        /*
        Entry entry = getThisEntry(newField._key);
  
        if (entry != null) {
          entry._value = newField._value;
        }
        else {
          putThisField(env, newField._key, newField._value);
        }
        */
      }
    }
  
    /**
     * Returns the number of entries.
     */
    @Override
    public int getSize()
    {
      return _fieldMap.size();
    }
  
    /**
     * Gets a field value.
     */
    @Override
    public final Value getField(Env env, StringValue name)
    {
      Value returnValue = getFieldExt(env, name);
  
      if (returnValue == UnsetValue.UNSET) {
        // __get didn't work, lets look in the class itself
        Entry entry = _fieldMap.get(name);
  
        if (entry != null) {
          // php/09ks vs php/091m
          return entry._value.toValue();
        }
      }
  
      return returnValue;
    }
  
    /**
     * Gets a field value.
     */
    @Override
    public Value getThisField(Env env, StringValue name)
    {
      Entry entry = getThisEntry(name);
  
      if (entry != null) {
        return entry._value.toValue();
      }
  
      return getFieldExt(env, name);
    }
  
    /**
     * Returns fields not explicitly specified by this value.
     */
    protected Value getFieldExt(Env env, StringValue name)
    {
      Entry e = getEntry(env, name);
  
      if (e != null
          && e._value != NullValue.NULL
          && e._value != UnsetValue.UNSET) {
        return e._value;
      }
  
      return _quercusClass.getField(env, this, name);
    }
  
    /**
     * Returns the array ref.
     */
    @Override
    public Var getFieldVar(Env env, StringValue name)
    {
      Entry entry = getEntry(env, name);
  
      if (entry != null) {
        Value value = entry._value;
  
        if (value instanceof Var)
          return (Var) value;
  
        Var var = new Var(value);
        entry._value = var;
  
        return var;
      }
  
      Value value = getFieldExt(env, name);
  
      if (value != UnsetValue.UNSET) {
        if (value instanceof Var)
          return (Var) value;
        else
          return new Var(value);
      }
  
      // php/3d28
      entry = createEntry(name);
  
      value = entry._value;
  
      if (value instanceof Var)
        return (Var) value;
  
      Var var = new Var(value);
  
      entry.setValue(var);
  
      return var;
    }
  
    /**
     * Returns the array ref.
     */
    @Override
    public Var getThisFieldVar(Env env, StringValue name)
    {
      Entry entry = getThisEntry(name);
  
      if (entry != null) {
        Value value = entry._value;
  
        if (value instanceof Var)
          return (Var) value;
  
        Var var = new Var(value);
        entry._value = var;
  
        return var;
      }
  
      Value value = getFieldExt(env, name);
  
      if (value != UnsetValue.UNSET) {
        if (value instanceof Var)
          return (Var) value;
        else
          return new Var(value);
      }
  
  