internal override IReflect InferType(JSField inference_target) { MethodInfo @operator; if ((this.type == null) || (inference_target != null)) { @operator = this.GetOperator(base.operand.InferType(inference_target)); } else { @operator = this.GetOperator(this.type); } if (@operator != null) { this.metaData = @operator; return(@operator.ReturnType); } if (Microsoft.JScript.Convert.IsPrimitiveNumericType(this.type)) { return(this.type); } if (this.type == Typeob.Char) { return(this.type); } if (Typeob.JSObject.IsAssignableFrom(this.type)) { return(Typeob.Double); } return(Typeob.Object); }
internal override IReflect InferType(JSField inference_target) { MethodInfo oper; if (this.type1 == null || inference_target != null) { oper = this.GetOperator(this.operand1.InferType(inference_target), this.operand2.InferType(inference_target)); } else { oper = this.GetOperator(this.type1, this.type2); } if (oper != null) { this.metaData = oper; return(oper.ReturnType); } if (this.type1 == Typeob.String || this.type2 == Typeob.String) { return(Typeob.String); } if (Convert.IsPrimitiveNumericType(this.type1)) { if (Convert.IsPromotableTo(this.type2, this.type1) || ((this.operand2 is ConstantWrapper) && ((ConstantWrapper)this.operand2).IsAssignableTo(this.type1))) { return(this.type1); } else if (Convert.IsPrimitiveNumericType(this.type1) && Convert.IsPrimitiveNumericTypeFitForDouble(this.type2)) { return(Typeob.Double); } } return(Typeob.Object); }
internal override IReflect InferType(JSField inference_target) { MethodInfo oper; if (this.type == null || inference_target != null) { oper = this.GetOperator(this.operand.InferType(inference_target)); } else { oper = this.GetOperator(this.type); } if (oper != null) { this.metaData = oper; return(oper.ReturnType); } if (Convert.IsPrimitiveNumericType(this.type)) { return(this.type); } else if (this.type == Typeob.Char) { return(this.type); } else if (Typeob.JSObject.IsAssignableFrom(this.type)) { return(Typeob.Double); } else { return(Typeob.Object); } }
internal override IReflect InferType(JSField inference_target) { MethodInfo @operator; if ((base.type1 == null) || (inference_target != null)) { @operator = base.GetOperator(base.operand1.InferType(inference_target), base.operand2.InferType(inference_target)); } else { @operator = base.GetOperator(base.type1, base.type2); } if (@operator != null) { this.metaData = @operator; return(@operator.ReturnType); } if ((base.type1 == Typeob.String) || (base.type2 == Typeob.String)) { return(Typeob.String); } if (Microsoft.JScript.Convert.IsPrimitiveNumericType(base.type1)) { if (Microsoft.JScript.Convert.IsPromotableTo((IReflect)base.type2, (IReflect)base.type1) || ((base.operand2 is ConstantWrapper) && ((ConstantWrapper)base.operand2).IsAssignableTo(base.type1))) { return(base.type1); } if (Microsoft.JScript.Convert.IsPrimitiveNumericType(base.type1) && Microsoft.JScript.Convert.IsPrimitiveNumericTypeFitForDouble(base.type2)) { return(Typeob.Double); } } return(Typeob.Object); }
internal override IReflect InferType(JSField inference_target){ Debug.Assert(Globals.TypeRefs.InReferenceContext(this.type1)); Debug.Assert(Globals.TypeRefs.InReferenceContext(this.type2)); MethodInfo oper; if (this.type1 == null || inference_target != null){ oper = this.GetOperator(this.operand1.InferType(inference_target), this.operand2.InferType(inference_target)); }else oper = this.GetOperator(this.type1, this.type2); if (oper != null){ this.metaData = oper; return oper.ReturnType; } if (this.type1 == Typeob.Char && this.operatorTok == JSToken.Minus){ TypeCode t2 = Type.GetTypeCode(this.type2); if (Convert.IsPrimitiveNumericTypeCode(t2) || t2 == TypeCode.Boolean) return Typeob.Char; else if (t2 == TypeCode.Char) return Typeob.Int32; } if (Convert.IsPrimitiveNumericType(this.type1)) if (Convert.IsPromotableTo(this.type2, this.type1) || ((this.operand2 is ConstantWrapper) && ((ConstantWrapper)this.operand2).IsAssignableTo(this.type1))) return this.type1; else if (Convert.IsPrimitiveNumericType(this.type1) && Convert.IsPrimitiveNumericTypeFitForDouble(this.type2)) return Typeob.Double; return Typeob.Object; }
internal override IReflect InferType(JSField inference_target) { MethodInfo @operator; if ((base.type1 == null) || (inference_target != null)) { @operator = base.GetOperator(base.operand1.InferType(inference_target), base.operand2.InferType(inference_target)); } else { @operator = base.GetOperator(base.type1, base.type2); } if (@operator != null) { this.metaData = @operator; return(@operator.ReturnType); } if ((base.type1 == Typeob.Char) && (base.operatorTok == JSToken.Minus)) { TypeCode typeCode = Type.GetTypeCode(base.type2); if (Microsoft.JScript.Convert.IsPrimitiveNumericTypeCode(typeCode) || (typeCode == TypeCode.Boolean)) { return(Typeob.Char); } if (typeCode == TypeCode.Char) { return(Typeob.Int32); } } if ((Microsoft.JScript.Convert.IsPrimitiveNumericTypeFitForDouble(base.type1) || Typeob.JSObject.IsAssignableFrom(base.type1)) && (Microsoft.JScript.Convert.IsPrimitiveNumericTypeFitForDouble(base.type2) || Typeob.JSObject.IsAssignableFrom(base.type2))) { return(Typeob.Double); } return(Typeob.Object); }
internal override IReflect InferType(JSField inference_target) { if (this.method != null) { ParameterInfo[] parameters = this.method.GetParameters(); if ((parameters != null) && (parameters.Length != 0)) { return parameters[0].ParameterType; } return this.method.ReturnType; } ScriptObject parent = base.Globals.ScopeStack.Peek(); while (parent is WithObject) { parent = parent.GetParent(); } if (parent is GlobalScope) { return parent; } if (!(parent is FunctionScope) || !((FunctionScope) parent).isMethod) { return Typeob.Object; } ClassScope scope = (ClassScope) ((FunctionScope) parent).owner.enclosing_scope; if (this.isSuper) { return scope.GetSuperType(); } return scope; }
internal override IReflect InferType(JSField inference_target) { MethodInfo @operator; if ((base.type1 == null) || (inference_target != null)) { @operator = base.GetOperator(base.operand1.InferType(inference_target), base.operand2.InferType(inference_target)); } else { @operator = base.GetOperator(base.type1, base.type2); } if (@operator != null) { this.metaData = @operator; return @operator.ReturnType; } if ((base.type1 == Typeob.String) || (base.type2 == Typeob.String)) { return Typeob.String; } if (Microsoft.JScript.Convert.IsPrimitiveNumericType(base.type1)) { if (Microsoft.JScript.Convert.IsPromotableTo((IReflect) base.type2, (IReflect) base.type1) || ((base.operand2 is ConstantWrapper) && ((ConstantWrapper) base.operand2).IsAssignableTo(base.type1))) { return base.type1; } if (Microsoft.JScript.Convert.IsPrimitiveNumericType(base.type1) && Microsoft.JScript.Convert.IsPrimitiveNumericTypeFitForDouble(base.type2)) { return Typeob.Double; } } return Typeob.Object; }
internal override IReflect InferType(JSField inference_target) { MethodInfo oper; if (this.type1 == null) { oper = this.GetOperator(this.operand1.InferType(inference_target), this.operand2.InferType(inference_target)); } else { oper = this.GetOperator(this.type1, this.type2); } if (oper != null) { this.metaData = oper; return(oper.ReturnType); } if ((this.type1.IsPrimitive || Typeob.JSObject.IsAssignableFrom(this.type1)) && (this.type2.IsPrimitive || Typeob.JSObject.IsAssignableFrom(this.type2))) { return(Typeob.Int32); } else { return(Typeob.Object); } }
internal override IReflect InferType(JSField inference_target) { if (this.method != null) { ParameterInfo[] parameters = this.method.GetParameters(); if ((parameters != null) && (parameters.Length != 0)) { return(parameters[0].ParameterType); } return(this.method.ReturnType); } ScriptObject parent = base.Globals.ScopeStack.Peek(); while (parent is WithObject) { parent = parent.GetParent(); } if (parent is GlobalScope) { return(parent); } if (!(parent is FunctionScope) || !((FunctionScope)parent).isMethod) { return(Typeob.Object); } ClassScope scope = (ClassScope)((FunctionScope)parent).owner.enclosing_scope; if (this.isSuper) { return(scope.GetSuperType()); } return(scope); }
internal override IReflect InferType(JSField inference_target) { MethodInfo @operator; if ((base.type1 == null) || (inference_target != null)) { @operator = this.GetOperator(base.operand1.InferType(inference_target), base.operand2.InferType(inference_target)); } else { @operator = this.GetOperator(base.type1, base.type2); } if (@operator != null) { this.metaData = @operator; return(@operator.ReturnType); } if ((base.type1 == Typeob.String) || (base.type2 == Typeob.String)) { return(Typeob.String); } if ((base.type1 == Typeob.Char) && (base.type2 == Typeob.Char)) { return(Typeob.String); } if (Microsoft.JScript.Convert.IsPrimitiveNumericTypeFitForDouble(base.type1)) { if (base.type2 == Typeob.Char) { return(Typeob.Char); } if (Microsoft.JScript.Convert.IsPrimitiveNumericTypeFitForDouble(base.type2)) { return(Typeob.Double); } return(Typeob.Object); } if (Microsoft.JScript.Convert.IsPrimitiveNumericTypeFitForDouble(base.type2)) { if (base.type1 == Typeob.Char) { return(Typeob.Char); } if (Microsoft.JScript.Convert.IsPrimitiveNumericTypeFitForDouble(base.type1)) { return(Typeob.Double); } return(Typeob.Object); } if ((base.type1 == Typeob.Boolean) && (base.type2 == Typeob.Char)) { return(Typeob.Char); } if ((base.type1 == Typeob.Char) && (base.type2 == Typeob.Boolean)) { return(Typeob.Char); } return(Typeob.Object); }
internal override IReflect InferType(JSField inference_target) { if (!this.isFullyResolved) { return(Typeob.Object); } return(base.InferType(inference_target)); }
internal override IReflect GetInferredType(JSField inference_target) { if (this.field is JSMemberField) { return ((JSMemberField) this.field).GetInferredType(inference_target); } return this.field.FieldType; }
public BlockScope(ScriptObject parent, string name, int scopeId) : base(parent) { this.scopeId = scopeId; JSField field = (JSField)base.parent.GetField(name + ":" + this.scopeId, BindingFlags.Public); base.name_table[name] = field; base.field_table.Add(field); }
internal virtual IReflect GetInferredType(JSField inference_target) { if (this.type != null) { return(this.type.ToIReflect()); } return(Typeob.Object); }
internal override IReflect InferTypeOfCall(JSField inference_target, bool isConstructor) { if (!this.rootObjectInferredType.Equals(this.rootObject.InferType(inference_target))) { this.InvalidateBinding(); } return(base.InferTypeOfCall(null, isConstructor)); }
internal override IReflect GetInferredType(JSField inference_target) { if (this.field is JSMemberField) { return(((JSMemberField)this.field).GetInferredType(inference_target)); } return(this.field.FieldType); }
internal override IReflect InferType(JSField inference_target){ if (this.value == null || this.value is DBNull) return Typeob.Object; else if (this.value is ClassScope || this.value is TypedArray) return Typeob.Type; else if (this.value is EnumWrapper) return ((EnumWrapper)this.value).type; else return this.value.GetType(); }
internal override IReflect InferType(JSField inference_target) { IReflect reflect = base.operand1.InferType(inference_target); IReflect reflect2 = base.operand2.InferType(inference_target); if (reflect == reflect2) { return reflect; } return Typeob.Object; }
internal override IReflect InferType(JSField inference_target) { IReflect t1 = this.operand1.InferType(inference_target); IReflect t2 = this.operand2.InferType(inference_target); if (t1 == t2) { return(t1); } return(Typeob.Object); }
internal JSField[] GetFields() { int n = this.field_table.Count; JSField[] result = new JSField[n]; for (int i = 0; i < n; i++) { result[i] = (JSField)this.field_table[i]; } return(result); }
internal override IReflect InferType(JSField inference_target) { IReflect reflect = base.operand1.InferType(inference_target); IReflect reflect2 = base.operand2.InferType(inference_target); if (reflect == reflect2) { return(reflect); } return(Typeob.Object); }
internal JSField[] GetFields() { int count = base.field_table.Count; JSField[] fieldArray = new JSField[count]; for (int i = 0; i < count; i++) { fieldArray[i] = (JSField)base.field_table[i]; } return(fieldArray); }
internal override IReflect InferType(JSField inference_target) { if (base.members == null) { this.BindName(inference_target); } else if (!this.rootObjectInferredType.Equals(this.rootObject.InferType(inference_target))) { base.InvalidateBinding(); } return(base.InferType(null)); }
internal override IReflect GetInferredType(JSField inference_target){ if (this.outerField != null) return this.outerField.GetInferredType(inference_target); if (this.type != null) return base.GetInferredType(inference_target); if (this.inferred_type == null || this.inferred_type == Typeob.Object) return Typeob.Object; if (inference_target != null && inference_target != this){ if (this.dependents == null) this.dependents = new ArrayList(); this.dependents.Add(inference_target); } return this.inferred_type; }
private void ConvertFieldAndPropertyInfos(ArrayList vals) { for (int i = 0, n = vals.Count; i < n; i++) { JSField jsfld = vals[i] as JSField; if (jsfld != null) { vals[i] = jsfld.GetMetaData(); continue; } JSProperty jsprop = vals[i] as JSProperty; if (jsprop != null) { vals[i] = jsprop.metaData; continue; } } }
internal override IReflect InferType(JSField inference_target) { if ((this.value == null) || (this.value is DBNull)) { return Typeob.Object; } if ((this.value is ClassScope) || (this.value is TypedArray)) { return Typeob.Type; } if (this.value is EnumWrapper) { return ((EnumWrapper) this.value).classScopeOrType; } return Globals.TypeRefs.ToReferenceContext(this.value.GetType()); }
internal override IReflect InferType(JSField inference_target) { if (this.func is Binding) { return(((Binding)this.func).InferTypeOfCall(inference_target, this.isConstructor)); } else if (this.func is ConstantWrapper) { Object value = ((ConstantWrapper)this.func).value; if (value is Type || value is ClassScope || value is TypedArray) { return((IReflect)value); } } return(Typeob.Object); }
internal override IReflect InferType(JSField inference_target) { if ((this.value == null) || (this.value is DBNull)) { return(Typeob.Object); } if ((this.value is ClassScope) || (this.value is TypedArray)) { return(Typeob.Type); } if (this.value is EnumWrapper) { return(((EnumWrapper)this.value).classScopeOrType); } return(Globals.TypeRefs.ToReferenceContext(this.value.GetType())); }
internal override IReflect InferType(JSField inference_target){ MethodInfo oper; if (this.type1 == null){ oper = this.GetOperator(this.operand1.InferType(inference_target), this.operand2.InferType(inference_target)); }else oper = this.GetOperator(this.type1, this.type2); if (oper != null){ this.metaData = oper; return oper.ReturnType; } if ((this.type1.IsPrimitive || Typeob.JSObject.IsAssignableFrom(this.type1)) && (this.type2.IsPrimitive || Typeob.JSObject.IsAssignableFrom(this.type2))) return Typeob.Int32; else return Typeob.Object; }
internal override IReflect InferType(JSField inference_target) { if (this.func is Binding) { return(((Binding)this.func).InferTypeOfCall(inference_target, this.isConstructor)); } if (this.func is ConstantWrapper) { object obj2 = ((ConstantWrapper)this.func).value; if (((obj2 is Type) || (obj2 is ClassScope)) || (obj2 is TypedArray)) { return((IReflect)obj2); } } return(Typeob.Object); }
internal override IReflect InferType(JSField inference_target) { Debug.Assert(Globals.TypeRefs.InReferenceContext(this.type1)); Debug.Assert(Globals.TypeRefs.InReferenceContext(this.type2)); MethodInfo oper; if (this.type1 == null || inference_target != null) { oper = this.GetOperator(this.operand1.InferType(inference_target), this.operand2.InferType(inference_target)); } else { oper = this.GetOperator(this.type1, this.type2); } if (oper != null) { this.metaData = oper; return(oper.ReturnType); } if (this.type1 == Typeob.Char && this.operatorTok == JSToken.Minus) { TypeCode t2 = Type.GetTypeCode(this.type2); if (Convert.IsPrimitiveNumericTypeCode(t2) || t2 == TypeCode.Boolean) { return(Typeob.Char); } else if (t2 == TypeCode.Char) { return(Typeob.Int32); } } if (Convert.IsPrimitiveNumericType(this.type1)) { if (Convert.IsPromotableTo(this.type2, this.type1) || ((this.operand2 is ConstantWrapper) && ((ConstantWrapper)this.operand2).IsAssignableTo(this.type1))) { return(this.type1); } else if (Convert.IsPrimitiveNumericType(this.type1) && Convert.IsPrimitiveNumericTypeFitForDouble(this.type2)) { return(Typeob.Double); } } return(Typeob.Object); }
internal override IReflect InferType(JSField inference_target) { MethodInfo oper; if (this.type1 == null || inference_target != null) { oper = this.GetOperator(this.operand1.InferType(inference_target), this.operand2.InferType(inference_target)); } else { oper = this.GetOperator(this.type1, this.type2); } if (oper != null) { this.metaData = oper; return(oper.ReturnType); } return(BitwiseBinary.ResultType(this.type1, this.type2, this.operatorTok)); }
internal override IReflect InferType(JSField inference_target) { MethodInfo @operator; if ((base.type1 == null) || (inference_target != null)) { @operator = base.GetOperator(base.operand1.InferType(inference_target), base.operand2.InferType(inference_target)); } else { @operator = base.GetOperator(base.type1, base.type2); } if (@operator != null) { this.metaData = @operator; return(@operator.ReturnType); } return(ResultType(base.type1, base.type2, base.operatorTok)); }
internal override IReflect InferType(JSField inference_target) { if (this.value == null || this.value is DBNull) { return(Typeob.Object); } else if (this.value is ClassScope || this.value is TypedArray) { return(Typeob.Type); } else if (this.value is EnumWrapper) { return(((EnumWrapper)this.value).type); } else { return(this.value.GetType()); } }
internal override IReflect InferType(JSField inference_target){ MethodInfo oper; if (this.type1 == null || inference_target != null){ oper = this.GetOperator(this.operand1.InferType(inference_target), this.operand2.InferType(inference_target)); }else oper = this.GetOperator(this.type1, this.type2); if (oper != null){ this.metaData = oper; return oper.ReturnType; } if (this.type1 == Typeob.String || this.type2 == Typeob.String) return Typeob.String; if (Convert.IsPrimitiveNumericType(this.type1)) if (Convert.IsPromotableTo(this.type2, this.type1) || ((this.operand2 is ConstantWrapper) && ((ConstantWrapper)this.operand2).IsAssignableTo(this.type1))) return this.type1; else if (Convert.IsPrimitiveNumericType(this.type1) && Convert.IsPrimitiveNumericTypeFitForDouble(this.type2)) return Typeob.Double; return Typeob.Object; }
internal override IReflect InferType(JSField inference_target) { MethodInfo @operator; if (base.type1 == null) { @operator = base.GetOperator(base.operand1.InferType(inference_target), base.operand2.InferType(inference_target)); } else { @operator = base.GetOperator(base.type1, base.type2); } if (@operator != null) { this.metaData = @operator; return @operator.ReturnType; } if ((base.type1.IsPrimitive || Typeob.JSObject.IsAssignableFrom(base.type1)) && (base.type2.IsPrimitive || Typeob.JSObject.IsAssignableFrom(base.type2))) { return Typeob.Int32; } return Typeob.Object; }
internal override IReflect InferType(JSField inference_target) { MethodInfo oper; if (this.type1 == null || inference_target != null) { oper = this.GetOperator(this.operand1.InferType(inference_target), this.operand2.InferType(inference_target)); } else { oper = this.GetOperator(this.type1, this.type2); } if (oper != null) { this.metaData = oper; return(oper.ReturnType); } if (this.type1 == Typeob.Char && this.operatorTok == JSToken.Minus) { TypeCode t2 = Type.GetTypeCode(this.type2); if (Convert.IsPrimitiveNumericTypeCode(t2) || t2 == TypeCode.Boolean) { return(Typeob.Char); } else if (t2 == TypeCode.Char) { return(Typeob.Int32); } } if ((Convert.IsPrimitiveNumericTypeFitForDouble(this.type1) || Typeob.JSObject.IsAssignableFrom(this.type1)) && (Convert.IsPrimitiveNumericTypeFitForDouble(this.type2) || Typeob.JSObject.IsAssignableFrom(this.type2))) { return(Typeob.Double); } else { return(Typeob.Object); } }
internal override IReflect InferType(JSField inference_target){ if (this.method != null){ ParameterInfo[] pars = this.method.GetParameters(); if (pars == null || pars.Length == 0) return this.method.ReturnType; else return pars[0].ParameterType; } ScriptObject top = Globals.ScopeStack.Peek(); while (top is WithObject) top = top.GetParent(); if (top is GlobalScope) return top; else if (top is FunctionScope && ((FunctionScope)top).isMethod){ ClassScope csc = (ClassScope)((FunctionScope)top).owner.enclosing_scope; if (this.isSuper) return csc.GetSuperType(); else return csc; } return Typeob.Object; }
internal override IReflect InferType(JSField inference_target) { Debug.Assert(Globals.TypeRefs.InReferenceContext(this.method)); if (this.method != null) { ParameterInfo[] pars = this.method.GetParameters(); if (pars == null || pars.Length == 0) { return(this.method.ReturnType); } else { return(pars[0].ParameterType); } } ScriptObject top = Globals.ScopeStack.Peek(); while (top is WithObject) { top = top.GetParent(); } if (top is GlobalScope) { return(top); } else if (top is FunctionScope && ((FunctionScope)top).isMethod) { ClassScope csc = (ClassScope)((FunctionScope)top).owner.enclosing_scope; if (this.isSuper) { return(csc.GetSuperType()); } else { return(csc); } } return(Typeob.Object); }
internal override IReflect InferType(JSField inference_target) { MethodInfo @operator; if (base.type1 == null) { @operator = base.GetOperator(base.operand1.InferType(inference_target), base.operand2.InferType(inference_target)); } else { @operator = base.GetOperator(base.type1, base.type2); } if (@operator != null) { this.metaData = @operator; return(@operator.ReturnType); } if ((base.type1.IsPrimitive || Typeob.JSObject.IsAssignableFrom(base.type1)) && (base.type2.IsPrimitive || Typeob.JSObject.IsAssignableFrom(base.type2))) { return(Typeob.Int32); } return(Typeob.Object); }
private void ConvertFieldAndPropertyInfos(ArrayList vals) { int num = 0; int count = vals.Count; while (num < count) { JSField field = vals[num] as JSField; if (field != null) { vals[num] = field.GetMetaData(); } else { JSProperty property = vals[num] as JSProperty; if (property != null) { vals[num] = property.metaData; } } num++; } }
private void BindName(JSField inferenceTarget){ MemberInfo[] members = null; this.rootObject = this.rootObject.PartiallyEvaluate(); IReflect obType = this.rootObjectInferredType = this.rootObject.InferType(inferenceTarget); if (this.rootObject is ConstantWrapper){ Object ob = Convert.ToObject2(this.rootObject.Evaluate(), this.Engine); if (ob == null){ this.rootObject.context.HandleError(JSError.ObjectExpected); return; } ClassScope csc = ob as ClassScope; Type t = ob as Type; if (csc != null || t != null){ //object is a type. Look for static members on the type only. If none are found, look for instance members on type Type. if (csc != null) this.members = members = csc.GetMember(this.name, BindingFlags.Public|BindingFlags.NonPublic|BindingFlags.Static|BindingFlags.DeclaredOnly); else this.members = members = t.GetMember(this.name, BindingFlags.Public|BindingFlags.NonPublic|BindingFlags.Static|BindingFlags.DeclaredOnly); if (members.Length > 0) return; //found a binding //Look for instance members on type Type this.members = members = Typeob.Type.GetMember(this.name, BindingFlags.Public|BindingFlags.Instance); return; } Namespace ns = ob as Namespace; if (ns != null){ String fullname = ns.Name+"."+this.name; csc = this.Engine.GetClass(fullname); if (csc != null){ FieldAttributes attrs = FieldAttributes.Literal; if ((csc.owner.attributes&TypeAttributes.Public) == 0) attrs |= FieldAttributes.Private; this.members = new MemberInfo[]{new JSGlobalField(null, this.name, csc, attrs)}; return; }else{ t = this.Engine.GetType(fullname); if (t != null){ this.members = new MemberInfo[]{t}; return; } } }else if (ob is MathObject || ob is ScriptFunction && !(ob is FunctionObject)) //It is a built in constructor function obType = (IReflect)ob; } obType = this.ProvideWrapperForPrototypeProperties(obType); //Give up and go late bound if not enough is known about the object at compile time. if (obType == Typeob.Object && !this.isNonVirtual){ //The latter provides for super in classes that extend System.Object this.members = new MemberInfo[0]; return; } Type ty = obType as Type; //Interfaces are weird, call a helper if (ty != null && ty.IsInterface){ this.members = JSBinder.GetInterfaceMembers(this.name, ty); return; } ClassScope cs = obType as ClassScope; if (cs != null && cs.owner.isInterface){ this.members = cs.owner.GetInterfaceMember(this.name); return; } //Now run up the inheritance chain until a member is found while (obType != null){ cs = obType as ClassScope; if (cs != null){ //The FlattenHierachy flag here tells ClassScope to add in any overloads found on base classes members = this.members = obType.GetMember(this.name, BindingFlags.Public|BindingFlags.NonPublic|BindingFlags.Instance|BindingFlags.DeclaredOnly|BindingFlags.FlattenHierarchy); if (members.Length > 0) return; obType = cs.GetSuperType(); continue; } ty = obType as Type; if (ty == null){ //Dealing with the global scope via the this literal or with a built in object in fast mode this.members = obType.GetMember(this.name, BindingFlags.Public|BindingFlags.Instance); return; } members = this.members = ty.GetMember(this.name, BindingFlags.Public|BindingFlags.NonPublic|BindingFlags.Instance|BindingFlags.DeclaredOnly); if (members.Length > 0){ MemberInfo mem = LateBinding.SelectMember(members); if (mem == null){ //Found a method or methods. Need to add any overloads found in base classes. //Do another lookup, this time with the DeclaredOnly flag cleared and asking only for methods members = this.members = ty.GetMember(this.name, MemberTypes.Method, BindingFlags.Public|BindingFlags.NonPublic|BindingFlags.Instance); if (members.Length == 0) //Dealing with an indexed property, ask again this.members = ty.GetMember(this.name, MemberTypes.Property, BindingFlags.Public|BindingFlags.NonPublic|BindingFlags.Instance); } return; } obType = ty.BaseType; } }
internal override IReflect InferTypeOfCall(JSField inference_target, bool isConstructor){ if (!this.rootObjectInferredType.Equals(this.rootObject.InferType(inference_target))) this.InvalidateBinding(); return base.InferTypeOfCall(null, isConstructor); }
internal override IReflect InferType(JSField inference_target){ if (this.members == null){ this.BindName(inference_target); }else{ if (!this.rootObjectInferredType.Equals(this.rootObject.InferType(inference_target))) this.InvalidateBinding(); } return base.InferType(null); }
internal override IReflect InferType(JSField inferenceTarget){ return Typeob.RegExpObject; }
private string GetArrayString(JSField field, string name) { JSField jsField = this.GetArrayField(field, name); if (jsField != null) return jsField.GetValue(jsField).ToString(); else return null; }
internal override IReflect InferType(JSField inference_target){ return this.ToIReflect(); }
internal override IReflect InferType(JSField inference_target){ MethodInfo oper; if (this.type1 == null || inference_target != null){ oper = this.GetOperator(this.operand1.InferType(inference_target), this.operand2.InferType(inference_target)); }else oper = this.GetOperator(this.type1, this.type2); if (oper != null){ this.metaData = oper; return oper.ReturnType; } if (this.type1 == Typeob.Char && this.operatorTok == JSToken.Minus){ TypeCode t2 = Type.GetTypeCode(this.type2); if (Convert.IsPrimitiveNumericTypeCode(t2) || t2 == TypeCode.Boolean) return Typeob.Char; else if (t2 == TypeCode.Char) return Typeob.Int32; } if ((Convert.IsPrimitiveNumericTypeFitForDouble(this.type1) || Typeob.JSObject.IsAssignableFrom(this.type1)) && (Convert.IsPrimitiveNumericTypeFitForDouble(this.type2) || Typeob.JSObject.IsAssignableFrom(this.type2))) return Typeob.Double; else return Typeob.Object; }
internal override IReflect InferType(JSField inference_target) { return Typeob.String; }
internal PayloadSimpleProperty parseSimpleObject(PayloadObject parent, JSField field) { PayloadSimpleProperty payloadProperty = new PayloadSimpleProperty(parent); payloadProperty.Name = field.Name; object val = field.GetValue(field); if (val is System.DBNull) { payloadProperty.Value = null; payloadProperty.Type = null; payloadProperty.IsNull = true; } else { payloadProperty.Type = AstoriaUnitTests.Data.TypeData.FindForType(val.GetType()).GetEdmTypeName(); payloadProperty.Value = ConvertJsonValue(val); payloadProperty.IsNull = false; } return payloadProperty; }
internal override IReflect InferType(JSField inference_target){ if (!this.isFullyResolved) return Typeob.Object; return base.InferType(inference_target); }
private JSField GetArrayField(JSField field, string name) { JSObject fieldObject = (JSObject)field.GetValue(field); FieldInfo[] fields = fieldObject.GetFields(BindingFlags.Default); for (int i = 0; i < fields.Length; i++) { JSField indexField = (JSField)fields[i]; if (indexField.Name == name) return indexField; } return null; }
private JSField GetArrayField(JSField field, int index) { JSObject fieldObject = (JSObject)field.GetValue(field); FieldInfo[] fields = fieldObject.GetFields(BindingFlags.Default); JSField indexField = (JSField)fields[index]; return indexField; }
internal override IReflect InferType(JSField inference_target){ Debug.Assert(Globals.TypeRefs.InReferenceContext(this.type)); MethodInfo oper; if (this.type == null || inference_target != null){ oper = this.GetOperator(this.operand.InferType(inference_target)); }else oper = this.GetOperator(this.type); if (oper != null){ this.metaData = oper; return oper.ReturnType; } if (Convert.IsPrimitiveNumericType(this.type)) return this.type; else if (this.type == Typeob.Char) return this.type; else if (Typeob.JSObject.IsAssignableFrom(this.type)) return Typeob.Double; else return Typeob.Object; }
internal virtual IReflect GetInferredType(JSField inference_target){ if (this.type != null) return this.type.ToIReflect(); else return Typeob.Object; }
internal override IReflect InferType(JSField inference_target) { return Typeob.Boolean; }
internal override IReflect InferType(JSField inference_target) { return Typeob.ScriptFunction; }
internal override IReflect InferType(JSField inference_target){ return this.operand2.InferType(inference_target); }
internal PayloadComplexProperty parseComplexObject(PayloadObject parent, JSField field) { PayloadComplexProperty payloadProperty = new PayloadComplexProperty(parent); payloadProperty.Name = field.Name; JSObject fieldValue = (JSObject)field.GetValue(field); FieldInfo[] fieldInfo = fieldValue.GetFields(BindingFlags.Default); for (int j = 0; j < fieldInfo.Length; j++) { JSField currentField = (JSField)fieldInfo[j]; if (currentField.GetValue(currentField) is JSObject) { PayloadComplexProperty payloadComplexProperty = this.parseComplexObject(parent, (JSField)fieldInfo[j]); payloadProperty.PayloadProperties.Add(payloadComplexProperty.Name, payloadComplexProperty); } else { PayloadProperty payloadSimpleProperty = this.parseSimpleObject(parent, (JSField)fieldInfo[j]); payloadProperty.PayloadProperties.Add(payloadSimpleProperty.Name, payloadSimpleProperty); } } return payloadProperty; }