void EmitArray(IType type, ExpressionCollection items)
{
EmitLoadLiteral(items.Count);
_il.Emit(OpCodes.Newarr, GetSystemType(type));
if (items.Count == 0)
return;
var inlineStores = 0;
if (items.Count > InlineArrayItemCountLimit && TypeSystemServices.IsPrimitiveNumber(type))
{
//packed array are only supported for a literal array of
//an unique primitive type. check that all items are literal
//and count number of actual stores in order to build/emit
//a packed array only if is is an advantage
foreach (Expression item in items)
{
if ((item.NodeType != NodeType.IntegerLiteralExpression
&& item.NodeType != NodeType.DoubleLiteralExpression)
|| type != item.ExpressionType)
{
inlineStores = 0;
break;
}
if (IsZeroEquivalent(item))
continue;
++inlineStores;
}
}
if (inlineStores <= InlineArrayItemCountLimit)
EmitInlineArrayInit(type, items);
else
EmitPackedArrayInit(type, items);
}