internal override void Emit (EmitContext ec)
{
var ig = ec.ig;
+ var type = this.Type;
- bool is_value_type = this.Type.IsValueType;
- if (is_value_type)
- throw new NotImplementedException ();
+ LocalBuilder local = null;
+ if (type.IsValueType) {
+ local = ig.DeclareLocal (type);
+ ig.Emit (OpCodes.Ldloca, local);
- foreach (var arg in arguments)
- arg.Emit (ec);
+ if (constructor == null) {
+ ig.Emit (OpCodes.Initobj, type);
+ ig.Emit (OpCodes.Ldloc, local);
+ return;
+ }
+ }
- ig.Emit (OpCodes.Newobj, constructor ?? GetDefaultConstructor (this.Type));
+ ec.EmitCollection (arguments);
+
+ if (type.IsValueType) {
+ ig.Emit (OpCodes.Call, constructor);
+ ig.Emit (OpCodes.Ldloc, local);
+ } else
+ ig.Emit (OpCodes.Newobj, constructor ?? GetDefaultConstructor (type));
}
static ConstructorInfo GetDefaultConstructor (Type type)