Exemple #1
0
 /// <summary>
 /// The static fields should be reinitialized. It is not needed
 /// if you do not mark the static field as [ThreadStatic]/
 /// </summary>
 /// <param name="context">Currently new ScriptContext.</param>
 public static void __InitializeStaticFields(ScriptContext context)
 {
     if (context != __lastContext)
     {
         y             = new PhpSmartReference("static one");
         __lastContext = context;
     }
 }
Exemple #2
0
        public static DObject EnsurePropertyIsObject(DObject obj, string name, DTypeDesc caller,
            ScriptContext context)
        {
            Debug.Assert(name != null);

            if (ReferenceEquals(obj, ScriptContext.SetterChainSingletonObject))
            {
                // extend the setter chain if one already exists
                context.ExtendSetterChain(new RuntimeChainProperty(name));

                return ScriptContext.SetterChainSingletonObject;
            }

            // search in CT properties
            DPropertyDesc property;
            GetMemberResult get_res =
                obj.TypeDesc.GetProperty(new VariableName(name), caller, out property);

            if (get_res == GetMemberResult.BadVisibility)
            {
                DObject.ThrowPropertyVisibilityError(name, property, caller);
                return null;
            }

            DObject ret_val;
            object old_val, value;

            // was a CT property found?
            if (get_res == GetMemberResult.OK)
            {
                old_val = property.Get(obj);
                value = old_val;
                ret_val = EnsurePropertyIsObjectInternal(obj, name, caller, ref value, context);

                if (!Object.ReferenceEquals(value, old_val)) property.Set(obj, value);
            }
            else
            {
                // search in RT fields

                var namekey = new IntStringKey(name);
                if (obj.RuntimeFields != null && obj.RuntimeFields.TryGetValue(namekey, out old_val))
                {
                    //old_val = element.Value;
                }
                else
                {
                    PhpReference reference = new PhpSmartReference();
                    reference.IsSet = false;
                    old_val = reference;
                }

                value = old_val;
                ret_val = EnsurePropertyIsObjectInternal(obj, name, caller, ref value, context);

                if (!Object.ReferenceEquals(value, old_val))
                {
                    if (obj.RuntimeFields == null) obj.RuntimeFields = new PhpArray();
                    
                    obj.RuntimeFields[name] = value;
                }
            }

            return ret_val;
        }
Exemple #3
0
 /// <summary>
 /// The static fields should be reinitialized. It is not needed
 /// if you do not mark the static field as [ThreadStatic]/
 /// </summary>
 /// <param name="context">Currently new ScriptContext.</param>
 public static void __InitializeStaticFields(ScriptContext context)
 {
     if (context != __lastContext)
     {
         y = new PhpSmartReference("static one");
         __lastContext = context;
     }
 }