private static Item CompileNewArray(ByteCodeGenerator generator, NewNode.NewArrayNode node) { var elemType = node.GetType(generator); var type = node.GetType(generator); foreach (var expression in node.Dimensions) { new ExpressionCompiler(expression).Compile(generator).Coerce(PrimativeTypes.Int).Load(); type = new Array(type); } var ndims = (byte)node.Dimensions.Count; var elemcode = TypeCodeHelper.ArrayCode((type as Array).ArrayType); if (elemcode == 0 || (elemcode == 1 && ndims == 1)) { generator.EmitAnewarray(generator.Manager.AddConstantClass(elemType), type); } else if (elemcode == 1) { generator.EmitMultianewarray(ndims, generator.Manager.AddConstantClass(type), type); } else { generator.EmitNewarray(elemcode, type); } return new StackItem(generator, type); }