Esempio n. 1
0
File: LpObject.cs Progetto: baban/lp
        public LpObject doMethod(System.Object method, LpObject self, LpObject[] args, LpObject block)
        {
            LpMethod m = null;

            if (null != (m = method as LpMethod))
            {
                return(m.funcall(self, args, block));
            }
            else
            {
                var klass = (method as LpObject);
                switch (klass.class_name)
                {
                case "Macro":
                    return(LpMacro.call((LpObject)method, args, block));

                case "Lambda":
                case "Block":
                    return(LpLambda.call((LpObject)method, args, block));

                default:
                    return(null);
                }
            }
        }
Esempio n. 2
0
File: LpObject.cs Progetto: baban/lp
        public LpObject funcall(string name, LpObject self, LpObject[] args, LpObject block)
        {
            LpObject ret = execMethod(name, self, args, block);

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

            LpMethod m = null;

            // method_missing
            m = methods["method_missing"] as LpMethod;
            if (null != m)
            {
                return(m.funcall(self, args, block));
            }

            // superclass
            if (null != superclass)
            {
                return(superclass.funcall(name, self, args, block));
            }

            throw new Error.LpNoMethodError();
        }
Esempio n. 3
0
File: LpObject.cs Progetto: baban/lp
        public LpMethod searchMethod(string name, LpObject self)
        {
            LpMethod m = (LpMethod)self.methods[name];

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

            // method_missing
            m = methods["method_missing"] as LpMethod;
            if (null != m)
            {
                return(m);
            }

            // superclass
            if (null != superclass)
            {
                return(superclass.searchMethod(name, self));
            }

            return(null);
        }