Example #1
0
 public void Append(Mixed key, Mixed value)
 {
     // if value isn't on heap yet, determine new place on heap and store it there
     if (value.__placeOnHeap == 0) {
         value.__placeOnHeap = ++Runtime.maxPlaceOnHeap;
         Runtime.heap[value.__placeOnHeap] = value;
     }
     // append value to array
     if (key == null) {
         keys.Add(new Integer(++maxKey));
         values.Add(value.__placeOnHeap);
     }
     else if (key is Boolean) {
         Integer intKey = PHP.Core.Convert.ToInteger(key);
         Append(intKey, value);
     }
     else if (key is Integer) {
         int index = keys.IndexOf(key);
         if (index > -1) {
             keys[index] = key;
             values[index] = value.__placeOnHeap;
         }
         else {
             keys.Add(key);
             values.Add(value.__placeOnHeap);
         }
         int keyValue = ((Integer)key).value;
         if (keyValue > maxKey)
             maxKey = keyValue;
     }
     else if (key is Double) {
         Integer intKey = PHP.Core.Convert.ToInteger(key);
         Append(intKey, value);
     }
     else if (key is String) {
         string keyValue = ((String)key).value;
         if (IsStandardInteger(keyValue)) {
             int intKeyValue = System.Convert.ToInt32(keyValue);
             Integer intKey = new Integer(intKeyValue);
             Append(intKey, value);
         }
         else {
             int index = keys.IndexOf(key);
             if (index > -1) {
                 keys[index] = key;
                 values[index] = value.__placeOnHeap;
             }
             else {
                 keys.Add(key);
                 values.Add(value.__placeOnHeap);
             }
         }
     }
     else if (key is Null) {
         String stringKey = PHP.Core.Convert.ToString(key);
         Append(stringKey, value);
     }
     // other data types are not allowed for keys, so ignore them
     else
         Report.Warn(402);
 }
Example #2
0
 public void Append(Mixed value)
 {
     Append(null, value);
 }
Example #3
0
 public void Remove(Mixed key)
 {
     if (key == null)
         return;
     else if (key is Boolean) {
         Integer intKey = PHP.Core.Convert.ToInteger(key);
         Remove(intKey);
     }
     else if (key is Integer) {
         int index = keys.IndexOf(key);
         if (index > -1) {
             keys.RemoveAt(index);
             values.RemoveAt(index);
         }
     }
     else if (key is Double) {
         Integer intKey = PHP.Core.Convert.ToInteger(key);
         Remove(intKey);
     }
     else if (key is String) {
         string keyValue = ((String)key).value;
         if (IsStandardInteger(keyValue)) {
             int intKeyValue = System.Convert.ToInt32(keyValue);
             Integer intKey = new Integer(intKeyValue);
             Remove(intKey);
         }
         else {
             int index = keys.IndexOf(key);
             if (index > -1) {
                 keys.RemoveAt(index);
                 values.RemoveAt(index);
             }
         }
     }
     else if (key is Null) {
         String stringKey = PHP.Core.Convert.ToString(key);
         Remove(stringKey);
     }
     // other data types are not allowed for keys, so ignore them
     else
         Report.Warn(402);
 }
Example #4
0
 public stdClass(Mixed scalar)
     : base()
 {
     this.scalar = scalar;
 }
Example #5
0
 public Mixed Get(Mixed key)
 {
     if (key is Boolean) {
         Integer intKey = PHP.Core.Convert.ToInteger(key);
         return Get(intKey);
     }
     else if (key is Integer) {
         int index = keys.IndexOf(key);
         if (index > -1) {
             int placeOnHeap = (int)values[index];
             return Runtime.LoadFromHeap(placeOnHeap);
         }
         else
             return new Null();
     }
     else if (key is Double) {
         Integer intKey = PHP.Core.Convert.ToInteger(key);
         return Get(intKey);
     }
     else if (key is String) {
         string keyValue = ((String)key).value;
         if (IsStandardInteger(keyValue)) {
             int intKeyValue = System.Convert.ToInt32(keyValue);
             Integer intKey = new Integer(intKeyValue);
             return Get(intKey);
         }
         else {
             int index = keys.IndexOf(key);
             if (index > -1) {
                 int placeOnHeap = (int)values[index];
                 return Runtime.LoadFromHeap(placeOnHeap);
             }
             else
                 return new Null();
         }
     }
     else if (key is Null) {
         String stringKey = PHP.Core.Convert.ToString(key);
         return Get(stringKey);
     }
     // other data types are not allowed for keys, so ignore them
     else {
         Report.Warn(402);
         return new Null();
     }
 }