Ejemplo n.º 1
0
        public Slot AddData(object data, Type type)
        {
            Slot result;

            if (IsBound)
            {
                _data.Add(data);
                _types.Add(type);

                result = new IndexSlot(_dataSlot, _data.Count - 1);
                if (type != typeof(object))
                {
                    // Use a CastSlot around an IndexSlot since we just want a cast and not a full conversion
                    result = new CastSlot(result, type);
                }
            }
            else
            {
                int index = AddStaticData(data);

                result = _cg.TypeGen.AddStaticField(type, "#SlotStorage" + index.ToString());
            }
            return(result);
        }
Ejemplo n.º 2
0
        public Slot AddData(object data, Type type)
        {
            Slot result;

            if (IsBound) {
                _data.Add(data);
                _types.Add(type);

                result = new IndexSlot(_dataSlot, _data.Count - 1);
                if (type != typeof(object)) {
                    // Use a CastSlot around an IndexSlot since we just want a cast and not a full conversion
                    result = new CastSlot(result, type);
                }
            } else {
                int index = AddStaticData(data);

                result = _cg.TypeGen.AddStaticField(type, "#SlotStorage" + index.ToString());

            }
            return result;
        }
Ejemplo n.º 3
0
 private Slot GetArgumentSlot(CodeGen cg)
 {
     Slot arg;
     if (_block != null && _block.ParameterArray) {
         // If not part of parameter array, get the normal parameter slot
         if (!_parameterArray) {
             arg = cg.GetArgumentSlot(_parameter);
         } else {
             Debug.Assert(cg.ParamsSlot != null);
             Debug.Assert(cg.ParamsSlot.Type == typeof(object[]));
             arg = new IndexSlot(cg.ParamsSlot, _parameter);
             if (_type != typeof(object)) {
                 arg = new CastSlot(arg, _type);
             }
         }
     } else {
         arg = cg.GetArgumentSlot(_parameter);
     }
     return arg;
 }