Exemple #1
0
        /// <summary>
        /// Sets the value associated with the named field
        /// </summary>
        /// <param name="name"></param>
        /// <param name="val"></param>
        public virtual void SetField(string name, HeronValue val)
        {
            HeronType t  = Type;
            FieldDefn fi = t.GetField(name);

            fi.SetValue(this, val);
        }
Exemple #2
0
        /// <summary>
        /// Given a name returns the appropriate field (or method)
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public virtual HeronValue GetFieldOrMethod(string name)
        {
            HeronType          t = Type;
            ExposedMethodValue m = t.GetMethod(name);

            if (m != null)
            {
                return(m.CreateBoundMethod(this));
            }
            FieldDefn f = t.GetField(name);

            if (f != null)
            {
                return(f.GetValue(this));
            }
            return(null);
        }
Exemple #3
0
        public override HeronValue GetFieldOrMethod(string name)
        {
            HeronValue v = type.GetField(name);

            if (v != null)
            {
                return(v);
            }

            ExposedMethodValue m = type.GetMethod(name);

            if (m != null)
            {
                return(m.CreateBoundMethod(null));
            }
            throw new Exception("The function '" + name + "' is not available on " + type.name);
        }