コード例 #1
0
ファイル: ArrayObject.cs プロジェクト: zhangaz1/IronJS
        public override void Put(string name, BoxedValue value)
        {
            if (name == "length")
            {
                this.PutLength(TypeConverter.ToNumber(value));
                this.SetAttrs("length", DescriptorAttrs.DontEnum); //TODO: Shouldn't `PutLength` keep the `DontEnum` flag?
                return;
            }

            uint index;

            if (TypeConverter.TryToIndex(name, out index))  //TODO: I changed this to use TryToIndex, but that forgoes checking that `index.ToString() == name`, which may be necessary.
            {
                this.Put(index, value);
                return;
            }

            base.Put(name, value);
        }
コード例 #2
0
ファイル: CommonObject.cs プロジェクト: zhangaz1/IronJS
        public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result)
        {
            var item = this.Find(binder.Name);

            if (item.HasValue)
            {
                var box = item.Value;
                if (box.IsFunction)
                {
                    var func      = box.Func;
                    var boxedArgs = args.Select(a => BoxedValue.Box(a)).ToArray();
                    var ret       = func.Call(this, boxedArgs);
                    result = ret.UnboxObject();
                    return(true);
                }
            }

            result = null;
            return(false);
        }
コード例 #3
0
        public static BoxedValue Box(object value)
        {
            if (value is double)
            {
                return(Box((double)value));
            }
            if (value is int)
            {
                return(Box((int)value));
            }
            if (value is bool)
            {
                return(Box((bool)value));
            }
            if (value is string)
            {
                return(Box((string)value));
            }
            if (value is SuffixString)
            {
                return(Box((SuffixString)value));
            }
            if (value is FunctionObject)
            {
                return(Box((FunctionObject)value));
            }
            if (value is CommonObject)
            {
                return(Box((CommonObject)value));
            }
            if (value is Undefined)
            {
                return(Box((Undefined)value));
            }

            var box = new BoxedValue();

            box.Clr = value;
            box.Tag = TypeTags.Clr;
            return(box);
        }
コード例 #4
0
        /// <summary>
        /// Puts the <paramref name="value"/> at the specified <paramref name="index"/>.
        /// </summary>
        /// <param name="index">The index.</param>
        /// <param name="value">The value.</param>
        public override void Put(uint index, BoxedValue value)
        {
            var ii = (int)index;

            if (LinkIntact && ii < LinkMap.Length)
            {
                var link = LinkMap[ii];
                switch (link.Item1)
                {
                case ParameterStorageType.Private:
                    PrivateScope[link.Item2] = value;
                    break;

                case ParameterStorageType.Shared:
                    SharedScope[link.Item2] = value;
                    break;
                }
            }

            base.Put(index, value);
        }
コード例 #5
0
        public static BoxedValue JsBox(object o)
        {
            if (o is BoxedValue)
            {
                return((BoxedValue)o);
            }

            if (o == null)
            {
                return(Environment.BoxedNull);
            }

            var tag = TypeTag.OfType(o.GetType());

            switch (tag)
            {
            case TypeTags.Bool: return(BoxedValue.Box((bool)o));

            case TypeTags.Number: return(BoxedValue.Box((double)o));

            default: return(BoxedValue.Box(o, tag));
            }
        }
コード例 #6
0
ファイル: TypeConverter.cs プロジェクト: zhangaz1/IronJS
        public static object ToClrObject(BoxedValue v)
        {
            switch (v.Tag)
            {
            case TypeTags.Undefined:
                return(null);

            case TypeTags.Bool:
                return(v.Bool);

            case TypeTags.Object:
            case TypeTags.Function:
            case TypeTags.String:
            case TypeTags.Clr:
                return(v.Clr);

            case TypeTags.SuffixString:
                return(v.Clr.ToString());

            default:
                return(v.Number);
            }
        }
コード例 #7
0
ファイル: CommonObject.cs プロジェクト: zhangaz1/IronJS
        //----------------------------------------------------------------------------

        public virtual void Put(uint index, BoxedValue value)
        {
            this.Put(index.ToString(), value);
        }
コード例 #8
0
ファイル: TypeConverter.cs プロジェクト: zhangaz1/IronJS
 public static int ToInteger(BoxedValue b)
 {
     return(ToInteger(ToNumber(b)));
 }
コード例 #9
0
ファイル: TypeConverter.cs プロジェクト: zhangaz1/IronJS
 public static ushort ToUInt16(BoxedValue b)
 {
     return((ushort)(uint)ToNumber(b));
 }
コード例 #10
0
ファイル: TypeConverter.cs プロジェクト: zhangaz1/IronJS
 public static BoxedValue ToBoxedValue(bool b)
 {
     return(BoxedValue.Box(b));
 }
コード例 #11
0
 static Undefined()
 {
     instance = new Undefined();
     boxed    = BoxedValue.Box(instance, TypeTags.Undefined);
 }
コード例 #12
0
ファイル: CommonObject.cs プロジェクト: zhangaz1/IronJS
 public void Put(Undefined index, BoxedValue value)
 {
     this.Put("undefined", value);
 }
コード例 #13
0
ファイル: TypeConverter.cs プロジェクト: zhangaz1/IronJS
 public static BoxedValue ToBoxedValue(FunctionObject f)
 {
     return(BoxedValue.Box(f));
 }
コード例 #14
0
ファイル: TypeConverter.cs プロジェクト: zhangaz1/IronJS
 public static BoxedValue ToBoxedValue(CommonObject o)
 {
     return(BoxedValue.Box(o));
 }
コード例 #15
0
ファイル: TypeConverter.cs プロジェクト: zhangaz1/IronJS
 public static BoxedValue ToBoxedValue(SuffixString s)
 {
     return(BoxedValue.Box(s));
 }
コード例 #16
0
ファイル: TypeConverter.cs プロジェクト: zhangaz1/IronJS
 public static BoxedValue ToPrimitive(BoxedValue v)
 {
     return(ToPrimitive(v, DefaultValueHint.None));
 }
コード例 #17
0
ファイル: TypeConverter.cs プロジェクト: zhangaz1/IronJS
 public static BoxedValue ToPrimitive(string s, DefaultValueHint hint)
 {
     return(BoxedValue.Box(s));
 }
コード例 #18
0
ファイル: TypeConverter.cs プロジェクト: zhangaz1/IronJS
 public static BoxedValue ToPrimitive(double d, DefaultValueHint hint)
 {
     return(BoxedValue.Box(d));
 }
コード例 #19
0
ファイル: TypeConverter.cs プロジェクト: zhangaz1/IronJS
 public static BoxedValue ToPrimitive(bool b, DefaultValueHint hint)
 {
     return(BoxedValue.Box(b));
 }
コード例 #20
0
ファイル: CommonObject.cs プロジェクト: zhangaz1/IronJS
 public void Put(string name, BoxedValue value, ushort attrs)
 {
     this.Put(name, value);
     this.SetAttrs(name, attrs);
 }
コード例 #21
0
ファイル: CommonObject.cs プロジェクト: zhangaz1/IronJS
 public void Put(bool index, BoxedValue value)
 {
     this.Put(TypeConverter.ToString(index), value);
 }
コード例 #22
0
 public override void Put(uint index, double value)
 {
     this.Put(index, BoxedValue.Box(value));
 }
コード例 #23
0
ファイル: TypeConverter.cs プロジェクト: zhangaz1/IronJS
 public static BoxedValue ToBoxedValue(BoxedValue v)
 {
     return(v);
 }
コード例 #24
0
 public void Put(uint index, BoxedValue value)
 {
     this.storage[index] = value;
 }
コード例 #25
0
ファイル: TypeConverter.cs プロジェクト: zhangaz1/IronJS
 public static BoxedValue ToBoxedValue(object c)
 {
     return(BoxedValue.Box(c));
 }
コード例 #26
0
ファイル: TypeConverter.cs プロジェクト: zhangaz1/IronJS
 public static BoxedValue ToBoxedValue(double d)
 {
     return(BoxedValue.Box(d));
 }
コード例 #27
0
 public override void Put(uint index, object value, uint tag)
 {
     this.Put(index, BoxedValue.Box(value, tag));
 }
コード例 #28
0
ファイル: TypeConverter.cs プロジェクト: zhangaz1/IronJS
 public static int ToInt32(BoxedValue b)
 {
     return((int)(uint)ToNumber(b));
 }
コード例 #29
0
 public bool TryGet(uint index, out BoxedValue value)
 {
     return(this.storage.TryGetValue(index, out value));
 }
コード例 #30
0
ファイル: TypeConverter.cs プロジェクト: zhangaz1/IronJS
 public static uint ToUInt32(BoxedValue b)
 {
     return((uint)ToNumber(b));
 }