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