Ejemplo n.º 1
0
        /// <summary>
        /// Converts from a HeronValue to a specific System.Net type
        /// </summary>
        /// <param name="t"></param>
        /// <param name="v"></param>
        /// <returns></returns>
        public static Object Unmarshal(Type t, HeronValue v)
        {
            Object o = v.Unmarshal();

            Debug.Assert(o.GetType().Equals(t));
            return(o);
        }
Ejemplo n.º 2
0
        public override HeronValue Invoke(VM vm, HeronValue self, HeronValue[] args)
        {
            int nParams = method.GetParameters().Length;

            if (nParams != args.Length)
            {
                throw new Exception("Incorrect number of arguments " + args.Length + " expected " + nParams);
            }

            Object[] newArgs = new Object[args.Length];
            for (int i = 0; i < nParams; ++i)
            {
                ParameterInfo pi = method.GetParameters()[i];
                Type          pt = pi.ParameterType;
                Type          at = args[i].GetType();
                HeronValue    hv = args[i] as HeronValue;
                if (!pt.IsAssignableFrom(at))
                {
                    if (hv == null)
                    {
                        throw new Exception("Could not cast parameter " + i + " from " + at + " to " + pt);
                    }
                    newArgs[i] = hv.Unmarshal();
                }
                else
                {
                    newArgs[i] = hv;
                }
            }
            return(DotNetObject.Marshal(method.Invoke(self, newArgs)));
        }
Ejemplo n.º 3
0
        public override void SetAtIndex(HeronValue index, HeronValue val)
        {
            IntValue iv = index as IntValue;

            if (iv == null)
            {
                throw new Exception("Can only use index lists using integers");
            }
            list[iv.GetValue()] = val.Unmarshal();
        }
Ejemplo n.º 4
0
 public void Insert(HeronValue n, HeronValue v)
 {
     list.Insert((n as IntValue).GetValue(), v.Unmarshal());
 }
Ejemplo n.º 5
0
 public void Prepend(HeronValue v)
 {
     list.Insert(0, v.Unmarshal());
 }
Ejemplo n.º 6
0
 public void Add(HeronValue v)
 {
     list.Add(v.Unmarshal());
 }