The Labs \ Source Viewer \ SSCLI \ Microsoft.JScript \ ArgumentsObject

  1. // ==++==
  2. //
  3. //
  4. // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
  5. //
  6. // The use and distribution terms for this software are contained in the file
  7. // named license.txt, which can be found in the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by the
  9. // terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. //
  13. //
  14. // ==--==
  15. namespace Microsoft.JScript
  16. {
  17.    
  18.     using System;
  19.     using System.Diagnostics;
  20.    
  21.     public sealed class ArgumentsObject : JSObject
  22.     {
  23.         private object[] arguments;
  24.         private string[] formal_names;
  25.         private ScriptObject scope;
  26.        
  27.         public object callee;
  28.         public object caller;
  29.         public object length;
  30.        
  31.         internal ArgumentsObject(ScriptObject parent, object[] arguments, FunctionObject function, Closure callee, ScriptObject scope, ArgumentsObject caller) : base(parent)
  32.         {
  33.             this.arguments = arguments;
  34.             this.formal_names = function.formal_parameters;
  35.             this.scope = scope;
  36.             this.callee = callee;
  37.             this.caller = caller;
  38.             this.length = arguments.Length;
  39.             this.noExpando = false;
  40.         }
  41.        
  42.         internal override object GetValueAtIndex(uint index)
  43.         {
  44.             if (index < this.arguments.Length)
  45.                 return this.arguments[(int)index];
  46.             else
  47.                 return base.GetValueAtIndex(index);
  48.         }
  49.        
  50.         #if !DEBUG
  51.         [DebuggerStepThroughAttribute()]
  52.         [DebuggerHiddenAttribute()]
  53.         #endif
  54.         internal override object GetMemberValue(string name)
  55.         {
  56.             long index = ArrayObject.Array_index_for(name);
  57.             if (index < 0)
  58.                 return base.GetMemberValue(name);
  59.             else
  60.                 return this.GetValueAtIndex((uint)index);
  61.         }
  62.        
  63.         internal override void SetValueAtIndex(uint index, object value)
  64.         {
  65.             if (index < this.arguments.Length)
  66.                 this.arguments[(int)index] = value;
  67.             else
  68.                 base.SetValueAtIndex(index, value);
  69.         }
  70.        
  71.         internal object[] ToArray()
  72.         {
  73.             return this.arguments;
  74.         }
  75.     }
  76.    
  77. }

Developer Fusion