예제 #1
0
        //public object ExecuteReader(TextReader reader)
        //{
        //    Parser parser = new Parser(reader);
        //    object result = null;

        //    for (var command = parser.ParseCommand(); command != null; command = parser.ParseCommand())
        //        result = command.Evaluate(this.rootcontext);

        //    return result;
        //}

        private static object NewInstance(RubyObject obj, Context context, IList <object> values)
        {
            var newobj = ((RubyClass)obj).CreateInstance();

            var initialize = newobj.GetMethod("initialize");

            if (initialize != null)
            {
                initialize.Apply(newobj, context, values);
            }

            return(newobj);
        }
예제 #2
0
        private static object GetSingletonMethods(RubyObject obj, Context context, IList <object> values)
        {
            //var result = new RubyArray();

            //var names = obj.SingletonClass.GetOwnInstanceMethodNames();

            //foreach (var name in names)
            //{
            //    Symbol symbol = new Symbol(name);

            //    if (!result.Contains(symbol))
            //        result.Add(symbol);
            //}

            //return result;
            throw new NotImplementedException();
        }
예제 #3
0
        public object Apply(RubyObject self, Context context, IList <object> values)
        {
            Context newcontext = new Context(self, this.context);

            int k  = 0;
            int cv = values.Count;

            foreach (var parameter in this.parameters)
            {
                newcontext.SetLocalValue(parameter, values[k]);
                k++;
            }

            return(RubyObject.Eval(body));

            //return this.body.Evaluate(newcontext);
        }
예제 #4
0
 private static object GetClass(RubyObject obj, Context context, IList <object> values)
 {
     return(obj.Class);
 }
예제 #5
0
 private static object GetSuperClass(RubyObject obj, Context context, IList <object> values)
 {
     return(((RubyClass)obj).SuperClass);
 }
예제 #6
0
 private static object GetName(RubyObject obj, Context context, IList <object> values)
 {
     return(((RubyClass)obj).Name);
 }
예제 #7
0
 public Context(RubyObject self, Context parent)
 {
     this.self   = self;
     this.parent = parent;
 }
예제 #8
0
 public Context(RubyClass module, Context parent)
 {
     this.module = module;
     this.parent = parent;
     this.self   = module;
 }
예제 #9
0
 public RubyObject(RubyObject prototype)
 {
     this["prototype"] = prototype;
 }
예제 #10
0
 public object Apply(RubyObject self, Context context, IList <object> values)
 {
     return(this.lambda(self, context, values));
 }