internal virtual ArrayObject Unshift(Object[] args) { Debug.PreCondition(args != null && args.Length > 0); uint oldLength = this.len; int numArgs = args.Length; ulong newLength = oldLength + (ulong)numArgs; this.SetLength(newLength); if (newLength <= this.denseArrayLength) { for (int i = (int)(oldLength - 1); i >= 0; i--) { this.denseArray[i + numArgs] = this.denseArray[i]; } ArrayObject.Copy(args, 0, this.denseArray, 0, args.Length); } else { for (long i = oldLength - 1; i >= 0; i--) { this.SetValueAtIndex((uint)(i + numArgs), this.GetValueAtIndex((uint)i)); } for (uint i = 0; i < numArgs; i++) { this.SetValueAtIndex(i, args[i]); } } return(this); }
public sealed override bool IsDefined(Type type, bool inherit) { Debug.PreCondition(type == typeof(ParamArrayAttribute)); Object[] attrs = this.attributes; if (attrs == null) { this.attributes = attrs = CustomAttribute.GetCustomAttributes(this.parameter, type, true); } return(attrs.Length > 0); }
public sealed override Object[] GetCustomAttributes(Type type, bool inherit) { Debug.PreCondition(type == typeof(ParamArrayAttribute)); Object[] attrs = this.attributes; if (attrs != null) { return(attrs); } return(this.attributes = CustomAttribute.GetCustomAttributes(this.parameter, type, true)); }
public sealed override bool IsDefined(Type type, bool inherit) { Debug.PreCondition(type == Typeob.JSFunctionAttribute); Object[] attrs = this.attributes; if (attrs == null) { this.attributes = attrs = this.method.GetCustomAttributes(type, true); } return(attrs.Length > 0); }
public override void SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture) { Debug.PreCondition(binder == null && culture == null); FieldAccessor accessor = this.fieldAccessor; if (accessor == null) { this.fieldAccessor = accessor = FieldAccessor.GetAccessorFor(this.field); } accessor.SetValue(obj, value); }
internal Completion Evaluate(Object expression) { Debug.PreCondition(this.case_value != null); if (StrictEquality.JScriptStrictEquals(this.case_value.Evaluate(), expression)) { return((Completion)this.statements.Evaluate()); } else { return(null); } }
private void Realloc(uint newLength) { Debug.PreCondition(this.denseArrayLength >= this.len); Debug.PreCondition(newLength <= ArrayObject.MaxIndex); uint oldDenseLength = this.denseArrayLength; uint newDenseLength = oldDenseLength * 2; if (newDenseLength < newLength) { newDenseLength = newLength; } Object[] newArray = new Object[(int)newDenseLength]; if (oldDenseLength > 0) { ArrayObject.Copy(this.denseArray, newArray, (int)oldDenseLength); } for (int i = (int)oldDenseLength; i < newDenseLength; i++) { newArray[i] = Missing.Value; } this.denseArray = newArray; this.denseArrayLength = newDenseLength; }
internal void TranslateToConditionalBranch(ILGenerator il, Type etype, bool branchIfTrue, Label label, bool shortForm) { Debug.PreCondition(this.case_value != null); Type t1 = etype; Type t2 = Convert.ToType(this.case_value.InferType(null)); if (t1 != t2 && t1.IsPrimitive && t2.IsPrimitive) { if (t1 == Typeob.Single && t2 == Typeob.Double) { t2 = Typeob.Single; } else if (Convert.IsPromotableTo(t2, t1)) { t2 = t1; } else if (Convert.IsPromotableTo(t1, t2)) { t1 = t2; } } bool nonPrimitive = true; if (t1 == t2 && t1 != Typeob.Object) { Convert.Emit(this, il, etype, t1); if (!t1.IsPrimitive && t1.IsValueType) { il.Emit(OpCodes.Box, t1); } this.case_value.context.EmitLineInfo(il); this.case_value.TranslateToIL(il, t1); if (t1 == Typeob.String) { il.Emit(OpCodes.Call, CompilerGlobals.stringEqualsMethod); } else if (!t1.IsPrimitive) { if (t1.IsValueType) { il.Emit(OpCodes.Box, t1); } il.Emit(OpCodes.Callvirt, CompilerGlobals.equalsMethod); } else { nonPrimitive = false; } } else { Convert.Emit(this, il, etype, Typeob.Object); this.case_value.context.EmitLineInfo(il); this.case_value.TranslateToIL(il, Typeob.Object); il.Emit(OpCodes.Call, CompilerGlobals.jScriptStrictEqualsMethod); } if (branchIfTrue) { if (nonPrimitive) { il.Emit(shortForm ? OpCodes.Brtrue_S : OpCodes.Brtrue, label); } else { il.Emit(shortForm ? OpCodes.Beq_S : OpCodes.Beq, label); } } else { if (nonPrimitive) { il.Emit(shortForm ? OpCodes.Brfalse_S : OpCodes.Brfalse, label); } else { il.Emit(shortForm ? OpCodes.Bne_Un_S : OpCodes.Bne_Un, label); } } }
internal override void TranslateToIL(ILGenerator il, Type rtype) { Debug.PreCondition(rtype == Typeob.Void); return; }