Ejemplo n.º 1
0
 public static MutableString/*!*/ BaseToMutableString(IRubyObject/*!*/ self) {
     if (self is RubyObject) {
         return ToMutableString(self);
     } else {
         return MutableString.CreateMutable(self.BaseToString());
     }
 }
Ejemplo n.º 2
0
        private static RubyClass /*!*/ GetImmediateClass(object self)
        {
            IRubyObject rubyObj = self as IRubyObject;

            ContractUtils.RequiresNotNull(rubyObj, "self");
            return(rubyObj.ImmediateClass);
        }
Ejemplo n.º 3
0
        private void CopyInstanceDataFrom(IRubyObject/*!*/ source, bool copyFrozenState) {
            // copy instance data, but not the state:
            var sourceData = source.TryGetInstanceData();
            if (sourceData != null) {
                _instanceData = new RubyInstanceData();
                sourceData.CopyInstanceVariablesTo(_instanceData);
            }

            // copy flags:
            SetTaint(this, IsTainted(source));
            if (copyFrozenState && IsFrozen(source)) {
                Freeze(this);
            }
        }
Ejemplo n.º 4
0
        public object Invoke <TScope>(CallSite /*!*/ callSite, TScope /*!*/ scope, object self)
        {
            IRubyObject obj = self as IRubyObject;

            if (obj != null && obj.ImmediateClass.Version.Method == Version)
            {
                // TODO: optimize
                RubyInstanceData data = obj.TryGetInstanceData();
                return((data != null) ? data.GetInstanceVariable(Name) : null);
            }
            else
            {
                return(((CallSite <Func <CallSite, TScope, object, object> >)callSite).Update(callSite, scope, self));
            }
        }
Ejemplo n.º 5
0
        public object Invoke <TScope>(CallSite /*!*/ callSite, TScope /*!*/ scope, object self, T0 arg0)
        {
            IRubyObject obj = self as IRubyObject;

            if (obj != null && obj.ImmediateClass.Version.Method == Version)
            {
                var result = (object)arg0;
                // TODO: optimize
                obj.ImmediateClass.Context.SetInstanceVariable(obj, Name, result);
                return(result);
            }
            else
            {
                return(((CallSite <Func <CallSite, TScope, object, T0, object> >)callSite).Update(callSite, scope, self, arg0));
            }
        }
Ejemplo n.º 6
0
        private void CopyInstanceDataFrom(IRubyObject /*!*/ source, bool copyFrozenState)
        {
            // copy instance data, but not the state:
            var sourceData = source.TryGetInstanceData();

            if (sourceData != null)
            {
                _instanceData = new RubyInstanceData();
                sourceData.CopyInstanceVariablesTo(_instanceData);
            }

            // copy flags:
            SetTaint(this, IsTainted(source));
            if (copyFrozenState && IsFrozen(source))
            {
                Freeze(this);
            }
        }
Ejemplo n.º 7
0
 public static bool IsFrozen(IRubyObject/*!*/ obj) {
     var instanceData = obj.TryGetInstanceData();
     return instanceData != null && instanceData.Frozen;
 }
Ejemplo n.º 8
0
 public Meta(Expression /*!*/ expression, Restrictions /*!*/ restrictions, IRubyObject /*!*/ value)
     : base(expression, restrictions, value)
 {
     ContractUtils.RequiresNotNull(value, "value");
 }
Ejemplo n.º 9
0
 public RubyObjectDebugView(IRubyObject /*!*/ obj)
 {
     Assert.NotNull(obj);
     _obj = obj;
 }
Ejemplo n.º 10
0
 public RubyObjectDebugView(IRubyObject/*!*/ obj) {
     Assert.NotNull(obj);
     _obj = obj;
 }
Ejemplo n.º 11
0
 public Meta(Expression/*!*/ expression, BindingRestrictions/*!*/ restrictions, IRubyObject/*!*/ value)
     : base(expression, restrictions, value) {
     ContractUtils.RequiresNotNull(value, "value");
 }
Ejemplo n.º 12
0
 public static void SetTaint(IRubyObject/*!*/ obj, bool value) {
     obj.GetInstanceData().Tainted = value;
 }
Ejemplo n.º 13
0
 public static MetaObject/*!*/ GetMetaObject(IRubyObject/*!*/ obj, Expression/*!*/ parameter) {
     return new RubyObject.Meta(parameter, Restrictions.Empty, obj);
 }
Ejemplo n.º 14
0
 public static DynamicMetaObject/*!*/ GetMetaObject(IRubyObject/*!*/ obj, MSA.Expression/*!*/ parameter) {
     return new RubyObject.Meta(parameter, BindingRestrictions.Empty, obj);
 }
Ejemplo n.º 15
0
 public static void Freeze(IRubyObject /*!*/ obj)
 {
     obj.GetInstanceData().Freeze();
 }
Ejemplo n.º 16
0
        public static bool IsTainted(IRubyObject /*!*/ obj)
        {
            var instanceData = obj.TryGetInstanceData();

            return(instanceData != null && instanceData.Tainted);
        }
Ejemplo n.º 17
0
 public static MutableString/*!*/ ToMutableString(IRubyObject/*!*/ self) {
     return RubyUtils.FormatObject(self.ImmediateClass.GetNonSingletonClass().Name, self.GetInstanceData().ObjectId, self.IsTainted);
 }
Ejemplo n.º 18
0
 public static bool ValueEquals(IRubyObject self, object other) {
     return object.ReferenceEquals(self, other);
 }
Ejemplo n.º 19
0
 public static int Hash(IRubyObject self) {
     return self == null ? RubyUtils.NilObjectId : RuntimeHelpers.GetHashCode(self);
 }
Ejemplo n.º 20
0
 public static bool IsTainted(IRubyObject/*!*/ obj) {
     var instanceData = obj.TryGetInstanceData();
     return instanceData != null && instanceData.Tainted;
 }
Ejemplo n.º 21
0
 public static RubyContext/*!*/ GetContextFromIRubyObject(IRubyObject/*!*/ obj) {
     return obj.ImmediateClass.Context;
 }
Ejemplo n.º 22
0
 public static void Freeze(IRubyObject/*!*/ obj) {
     obj.GetInstanceData().Freeze();
 }
Ejemplo n.º 23
0
        public static bool IsFrozen(IRubyObject /*!*/ obj)
        {
            var instanceData = obj.TryGetInstanceData();

            return(instanceData != null && instanceData.Frozen);
        }
Ejemplo n.º 24
0
 public static bool ValueEquals([NotNull] IRubyObject /*!*/ self, object other)
 {
     return(self.BaseEquals(other));
 }
Ejemplo n.º 25
0
 public static void SetTaint(IRubyObject /*!*/ obj, bool value)
 {
     obj.GetInstanceData().Tainted = value;
 }