コード例 #1
0
ファイル: Proc.cs プロジェクト: chunlea/rubydotnetcompiler
 public object yield(Frame caller, ArgList args)
 {
     args.block = this.block;
     // return body.Calln(my_class, self, caller, args); // BBTAG: last_class should be nearest lexical class definition rather than Proc
     Class last_class = Init.rb_cObject;
     if (caller != null && caller.nesting().Length > 0)
         last_class = caller.nesting()[0];
     return body.Calln(last_class, self, caller, args);
 }
コード例 #2
0
ファイル: Class.cs プロジェクト: chunlea/rubydotnetcompiler
 public override object Call0(Class last_class, object recv, Frame caller, Proc block)
 {
     Class[] nesting = caller.nesting();
     if (nesting == null)
         return new Array();
     else
         return new Array(nesting);
 }
コード例 #3
0
ファイル: Eval.cs プロジェクト: chunlea/rubydotnetcompiler
        // ruby_cbase: gets the class attached to the current 'node' (i.e. the current lexical context)
        internal static Class ruby_cbase(Frame caller) {
            Class[] nesting = caller.nesting();

            if (nesting == null || nesting.Length == 0)
                return Ruby.Runtime.Init.rb_cObject;

            return nesting[0];
        }
コード例 #4
0
ファイル: Eval.cs プロジェクト: chunlea/rubydotnetcompiler
        internal static object const_get(Class current, string id, Frame caller) {
            if (current.const_defined(id, false))
                return current.const_get(id, caller);

            foreach (Class klass in caller.nesting())
                if (klass.const_defined(id, false))
                    return klass.const_get(id, caller);

            return current.const_get(id, caller);
        }
コード例 #5
0
ファイル: Eval.cs プロジェクト: chunlea/rubydotnetcompiler
        internal static bool const_defined(Class current, string id, Frame caller) {
            if (current.const_defined(id, false))
                return true;

            foreach (Class klass in caller.nesting())
                if (klass.const_defined(id, false))
                    return true;

            return current.const_defined(id, true);
        }
コード例 #6
0
ファイル: Class.cs プロジェクト: chunlea/rubydotnetcompiler
 internal void add_method(string name, MethodBody body, int arity, Frame caller)
 {
     if (caller != null && caller.scope_vmode == Access.ModuleFunction &&
         caller.nesting().Length > 0 && caller.nesting()[0] == this)
     {
         add_method(name, body, arity, Access.Private, caller);
         Class.rb_define_singleton_method(this, name, body, arity, caller);
     }
     else
     {
         add_method(name, body, arity, get_visibility_mode(caller), caller);
     }
 }
コード例 #7
0
ファイル: Class.cs プロジェクト: chunlea/rubydotnetcompiler
        internal Access get_visibility_mode(Frame caller)
        {
            Access access = Access.Public;
            Class nesting = Init.rb_cObject;

            if (caller != null)
            {
                if (caller.nesting().Length > 0)
                    nesting = caller.nesting()[0];

                if (nesting == this)
                    access = caller.scope_vmode;
            }
            return access;
        }