slot() public method

public slot ( string name ) : Slot
name string
return Slot
Exemplo n.º 1
0
        private static object doTrap(object self, string name, List args, Type type)
        {
            Slot slot = type.slot(name, true);

            if (slot is Method)
            {
                Method m = (Method)slot;
                return(m.m_func.callOn(self, args));
            }
            else
            {
                Field f       = (Field)slot;
                int   argSize = (args == null) ? 0 : args.sz();
                if (argSize == 0)
                {
                    return(FanUtil.box(f.get(self)));
                }

                if (argSize == 1)
                {
                    object val = args.get(0);
                    f.set(self, val);
                    return(FanUtil.box(val));
                }

                throw ArgErr.make("Invalid number of args to get or set field '" + name + "'").val;
            }
        }
Exemplo n.º 2
0
Arquivo: Enum.cs Projeto: nomit007/f4
 protected static Enum doFromStr(Type t, string name, bool check)
 {
     // the compiler marks the value fields with the Enum flag
       Slot slot = t.slot(name, false);
       if (slot != null && (slot.m_flags & FConst.Enum) != 0)
       {
     try
     {
       return (Enum)((Field)slot).get(null);
     }
     catch (System.Exception)
     {
     }
       }
       if (!check) return null;
       throw ParseErr.make(t.qname(), name).val;
 }
Exemplo n.º 3
0
        protected static Enum doFromStr(Type t, string name, bool check)
        {
            // the compiler marks the value fields with the Enum flag
            Slot slot = t.slot(name, false);

            if (slot != null && (slot.m_flags & FConst.Enum) != 0)
            {
                try
                {
                    return((Enum)((Field)slot).get(null));
                }
                catch (System.Exception)
                {
                }
            }
            if (!check)
            {
                return(null);
            }
            throw ParseErr.make(t.qname(), name).val;
        }
Exemplo n.º 4
0
        public static Slot find(string qname, bool check)
        {
            string typeName, slotName;

            try
            {
                int dot = qname.IndexOf('.');
                typeName = qname.Substring(0, dot);
                slotName = qname.Substring(dot + 1);
            }
            catch (Exception)
            {
                throw Err.make("Invalid slot qname \"" + qname + "\", use <pod>::<type>.<slot>").val;
            }
            Type type = Type.find(typeName, check);

            if (type == null)
            {
                return(null);
            }
            return(type.slot(slotName, check));
        }
Exemplo n.º 5
0
 /// <summary>
 /// typeLiteral := type "#"
 /// slotLiteral := type "#" id
 /// </summary>
 private object readTypeOrSlotLiteral(int line, Type t)
 {
     consume(Token.POUND, "Expected '#' for type literal");
       if (curt == Token.ID && !isEndOfStmt(line))
       {
     string slotName = consumeId("slot literal name");
     return t.slot(slotName);
       }
       else
       {
     return t;
       }
 }
Exemplo n.º 6
0
        private static object doTrap(object self, string name, List args, Type type)
        {
            Slot slot = type.slot(name, true);
              if (slot is Method)
              {
            Method m = (Method)slot;
            return m.m_func.callOn(self, args);
              }
              else
              {
            Field f = (Field)slot;
            int argSize = (args == null) ? 0 : args.sz();
            if (argSize == 0)
            {
              return FanUtil.box(f.get(self));
            }

            if (argSize == 1)
            {
              object val = args.get(0);
              f.set(self, val);
              return FanUtil.box(val);
            }

            throw ArgErr.make("Invalid number of args to get or set field '" + name + "'").val;
              }
        }