internal override void Defined(CodeGenContext context)
 {
     // Fixme: make sure CurrentRubyClass is not a singleton (see cvar_cbase)
     // Ruby.Variables.cvar_defined(ruby_cref, "vid");
     context.ruby_cbase(parent_scope);
     context.ldstr(vid.ToString());
     context.call(Runtime.Variables.cvar_defined);
 }
        internal override void Assign(CodeGenContext context, Node rhs)
        {
            // Fixme: make sure CurrentRubyClass is not a singleton (see cvar_cbase)

            // object value = rhs;
            bool created;
            ISimple value = context.PreCompute(rhs, "rhs", out created);

            // Ruby.Variables.cvar_set(caller, ruby_cref, "vid", value);
            context.ldloc(0);
            context.ruby_cbase(parent_scope);
            context.ldstr(vid.ToString());
            value.GenSimple(context);
            context.call(Runtime.Variables.cvar_set);

            context.ReleaseLocal(value, created);
        }
 public void GenSimple(CodeGenContext context)
 {
     // Fixme: make sure CurrentRubyClass is not a singleton (see cvar_cbase)
     // Ruby.Variables.cvar_get(caller, ruby_cref, "vid");
     context.ldloc(0);
     context.ruby_cbase(parent_scope);
     context.ldstr(vid.ToString());
     context.call(Runtime.Variables.cvar_get);
 }
        internal override void Assign(CodeGenContext context, Node rhs)
        {
            bool value_created;
            ISimple value;

            if (qualified) // Fixme: scope == null???
            {
                // object where = scope;
                bool where_created;
                ISimple where = context.PreCompute(scope, "scope", out where_created);
            
                // object value = rhs;
                value = context.PreCompute(rhs, "rhs", out value_created);

                context.ldloc(0);
                where.GenSimple(context);

                context.ReleaseLocal(where, where_created);
            }
            else
            {
                // object value = rhs;
                value = context.PreCompute(rhs, "rhs", out value_created);

                context.ldloc(0);
                context.ruby_cbase(parent_scope);
            }

            context.ldstr(vid.ToString());
            value.GenSimple(context);
            context.call(Runtime.Eval.set_const);

            context.ReleaseLocal(value, value_created);
        }
        internal override void GenCode0(CodeGenContext context)
        {
            if (qualified)
                if (scope != null)
                    scope.GenCode(context);
                else
                    context.ldsfld(Ruby.Compiler.Runtime.Init.rb_cObject);
            else
                context.ruby_cbase(parent_scope);

            context.ldstr(vid.ToString());
            context.ldloc(0);
            context.call(Runtime.Eval.get_const);
        }
         internal override void Defined(CodeGenContext context)
        {
            if (qualified)
                if (scope != null)
                {
                    // object result;
                    int result = context.CreateLocal("result", PrimitiveType.Object);
                    PERWAPI.CILLabel endLabel = context.NewLabel();
                    // try {
                    context.StartBlock(Clause.Try);
                    {
                        // result = Eval.const_defined(scope, vid, caller);
                        scope.GenCode(context);
                        context.ldstr(vid.ToString());
                        context.ldloc(0);
                        context.call(Runtime.Eval.const_defined);
                        context.stloc(result);
                        context.leave(endLabel);
                    }
                    TryBlock block = context.EndTryBlock();
                    // catch (System.Exception) {
                    context.StartBlock(Clause.Catch);
                    {
                        // result = null;
                        context.ldnull();
                        context.stloc(result);
                        context.leave(endLabel);
                    }
                    context.EndCatchBlock(Runtime.SystemExceptionRef, block);

                    context.CodeLabel(endLabel);
                    context.ldloc(result);
                    context.ReleaseLocal(result, true);
                }
                else
                {
                    context.ldsfld(Ruby.Compiler.Runtime.Init.rb_cObject);
                    context.ldstr(vid.ToString());
                    context.ldloc(0);
                    context.call(Runtime.Eval.const_defined);
                }
            else
            {
                context.ruby_cbase(parent_scope);
                context.ldstr(vid.ToString());
                context.ldloc(0);
                context.call(Runtime.Eval.const_defined);
            }
        }