5 // Cesar Lopez Nataren (cesar@ciencias.unam.mx)
7 // (C) 2003, Cesar Lopez Nataren
8 // (C) 2005, Novell Inc, (http://novell.com)
12 // Permission is hereby granted, free of charge, to any person obtaining
13 // a copy of this software and associated documentation files (the
14 // "Software"), to deal in the Software without restriction, including
15 // without limitation the rights to use, copy, modify, merge, publish,
16 // distribute, sublicense, and/or sell copies of the Software, and to
17 // permit persons to whom the Software is furnished to do so, subject to
18 // the following conditions:
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 using System.Reflection;
34 using System.Diagnostics;
35 using Microsoft.JScript.Vsa;
36 using System.Collections;
38 namespace Microsoft.JScript {
40 public sealed class LateBinding {
43 private static BindingFlags bind_flags = BindingFlags.Public;
44 private string right_hand_side;
46 public LateBinding (string name)
48 this.right_hand_side = name;
52 public LateBinding (string name, object obj)
54 throw new NotImplementedException ();
58 [DebuggerStepThroughAttribute]
59 [DebuggerHiddenAttribute]
60 public object Call (object [] arguments, bool construct, bool brackets,
73 type = SemanticAnalyser.map_to_prototype ((JSObject) obj);
75 MethodInfo method = type.GetMethod (right_hand_side, BindingFlags.Public | BindingFlags.Static);
76 object [] args = build_args (arguments, engine);
77 return method.Invoke (type, args);
80 throw new NotImplementedException ();
83 private object [] build_args (object [] arguments, VsaEngine engine)
85 ArrayList args = new ArrayList ();
90 foreach (object o in arguments)
92 return args.ToArray ();
95 [DebuggerStepThroughAttribute]
96 [DebuggerHiddenAttribute]
97 public static object CallValue (object thisObj, object val, object [] arguments,
98 bool construct, bool brackets, VsaEngine engine)
105 } else if (brackets) {
106 if (!(val is JSObject))
107 throw new Exception ("val has to be a JSObject");
109 JSObject js_val = (JSObject) val;
110 object res = js_val.GetField (Convert.ToString (arguments [0]));
111 if (res is JSFieldInfo)
112 return ((JSFieldInfo) res).GetValue (arguments [0]);
114 throw new NotImplementedException ();
120 [DebuggerStepThroughAttribute]
121 [DebuggerHiddenAttribute]
122 public static object CallValue2 (object val, object thisObj, object [] arguments,
123 bool construct, bool brackets, VsaEngine engine)
125 throw new NotImplementedException ();
129 public bool Delete ()
131 throw new NotImplementedException ();
135 public static bool DeleteMember (object obj, string name)
137 throw new NotImplementedException ();
140 [DebuggerStepThroughAttribute]
141 [DebuggerHiddenAttribute]
142 public object GetNonMissingValue ()
144 Type type = obj.GetType ();
145 MemberInfo [] members = type.GetMember (right_hand_side);
146 if (members.Length > 0) {
147 MemberInfo member = members [0];
148 MemberTypes member_type = member.MemberType;
150 switch (member_type) {
151 case MemberTypes.Property:
152 MethodInfo method = ((PropertyInfo) member).GetGetMethod ();
153 return method.Invoke (obj, new object [] {});
156 throw new NotImplementedException ();
159 [DebuggerStepThroughAttribute]
160 [DebuggerHiddenAttribute]
161 public object GetValue2 ()
163 throw new NotImplementedException ();
166 [DebuggerStepThroughAttribute]
167 [DebuggerHiddenAttribute]
168 public static void SetIndexedPropertyValueStatic (object obj, object [] arguments,
171 if (!(obj is JSObject))
172 throw new Exception ("obj should be a JSObject");
174 JSObject js_obj = (JSObject) obj;
175 foreach (object o in arguments)
176 js_obj.AddField (o, value);
179 [DebuggerStepThroughAttribute]
180 [DebuggerHiddenAttribute]
181 public void SetValue (object value)
183 throw new NotImplementedException ();