Esempio n. 1
0
 // TODO: I may want to change the requirement that DuckValue needs a 
 // class instances, same with interface instance
 public DuckValue(ClassInstance obj, InterfaceDefn i)
     : base(obj, i)
 {
     HeronType t = obj.Type;
     foreach (FunctionDefn f in i.GetAllMethods())
     {
         if (!obj.SupportsFunction(f))
             throw new Exception("Failed to duck-type, object of type " + t.GetName() + " does not match interface " + i.GetName());
     }
 }
Esempio n. 2
0
 public bool VerifyImplements(InterfaceDefn i)
 {
     foreach (FunctionDefn f in i.GetAllMethods())
     {
         if (!HasFunction(f))
         {
             return(false);
         }
     }
     return(true);
 }
Esempio n. 3
0
        public bool Implements(InterfaceDefn i)
        {
            foreach (FunctionDefn fd in i.GetAllMethods())
            {
                if (!ImplementsMethod(fd))
                {
                    return(false);
                }
            }

            return(true);
        }
Esempio n. 4
0
        // TODO: I may want to change the requirement that DuckValue needs a
        // class instances, same with interface instance
        public DuckValue(ClassInstance obj, InterfaceDefn i)
            : base(obj, i)
        {
            HeronType t = obj.Type;

            foreach (FunctionDefn f in i.GetAllMethods())
            {
                if (!obj.SupportsFunction(f))
                {
                    throw new Exception("Failed to duck-type, object of type " + t.GetName() + " does not match interface " + i.GetName());
                }
            }
        }
Esempio n. 5
0
        public bool Implements(InterfaceDefn i)
        {
            foreach (FunctionDefn fd in i.GetAllMethods())
                if (!ImplementsMethod(fd))
                    return false;

            return true;
        }