Beispiel #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);
        }
Beispiel #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();
        }
Beispiel #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);
        }
Beispiel #4
0
 private static object GetClass(RubyObject obj, Context context, IList <object> values)
 {
     return(obj.Class);
 }
Beispiel #5
0
 private static object GetSuperClass(RubyObject obj, Context context, IList <object> values)
 {
     return(((RubyClass)obj).SuperClass);
 }
Beispiel #6
0
 private static object GetName(RubyObject obj, Context context, IList <object> values)
 {
     return(((RubyClass)obj).Name);
 }
Beispiel #7
0
 public Context(RubyObject self, Context parent)
 {
     this.self   = self;
     this.parent = parent;
 }
Beispiel #8
0
 public Context(RubyClass module, Context parent)
 {
     this.module = module;
     this.parent = parent;
     this.self   = module;
 }
 public RubyObject(RubyObject prototype)
 {
     this["prototype"] = prototype;
 }
Beispiel #10
0
 public object Apply(RubyObject self, Context context, IList <object> values)
 {
     return(this.lambda(self, context, values));
 }