X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fmcs%2Fdynamic.cs;h=0246c43a1b67fa9cba25972b19e283fd7558a5b2;hb=a4a84a1325565b912b1fe4d19d40cfd0affa1a3a;hp=ade105cb00a9b30f30f107a02243f99e59fcde64;hpb=4e27e86d537d8487c07153581efe762dcb7a5b7c;p=mono.git diff --git a/mcs/mcs/dynamic.cs b/mcs/mcs/dynamic.cs index ade105cb00a..0246c43a1b6 100644 --- a/mcs/mcs/dynamic.cs +++ b/mcs/mcs/dynamic.cs @@ -13,7 +13,7 @@ using System; using System.Linq; using SLE = System.Linq.Expressions; -#if NET_4_0 +#if NET_4_0 || MONODROID using System.Dynamic; #endif @@ -63,7 +63,7 @@ namespace Mono.CSharp // public class RuntimeValueExpression : Expression, IDynamicAssign, IMemoryLocation { -#if !NET_4_0 +#if !NET_4_0 && !MONODROID public class DynamicMetaObject { public TypeSpec RuntimeType; @@ -146,7 +146,7 @@ namespace Mono.CSharp return base.MakeExpression (ctx); #else - #if NET_4_0 +#if NET_4_0 || MONODROID if (type.IsStruct && !obj.Expression.Type.IsValueType) return SLE.Expression.Unbox (obj.Expression, type.GetMetaInfo ()); @@ -181,7 +181,7 @@ namespace Mono.CSharp return this; } -#if NET_4_0 +#if NET_4_0 || MONODROID public override SLE.Expression MakeExpression (BuilderContext ctx) { #if STATIC @@ -447,6 +447,7 @@ namespace Mono.CSharp d.CreateContainer (); d.DefineContainer (); d.Define (); + d.PrepareEmit (); site.AddTypeContainer (d); del_type = new TypeExpression (d.CurrentType, loc); @@ -495,41 +496,40 @@ namespace Mono.CSharp FieldExpr site_field_expr = new FieldExpr (MemberCache.GetMember (gt, field), loc); BlockContext bc = new BlockContext (ec.MemberContext, null, ec.BuiltinTypes.Void); - SymbolWriter.OpenCompilerGeneratedBlock (ec); Arguments args = new Arguments (1); args.Add (new Argument (binder)); StatementExpression s = new StatementExpression (new SimpleAssign (site_field_expr, new Invocation (new MemberAccess (instanceAccessExprType, "Create"), args))); - - if (s.Resolve (bc)) { - Statement init = new If (new Binary (Binary.Operator.Equality, site_field_expr, new NullLiteral (loc), loc), s, loc); - init.Emit (ec); - } - - args = new Arguments (1 + dyn_args_count); - args.Add (new Argument (site_field_expr)); - if (arguments != null) { - int arg_pos = 1; - foreach (Argument a in arguments) { - if (a is NamedArgument) { - // Name is not valid in this context - args.Add (new Argument (a.Expr, a.ArgType)); - } else { - args.Add (a); - } - - if (inflate_using_mvar && a.Type != targs[arg_pos].Type) - a.Expr.Type = targs[arg_pos].Type; - ++arg_pos; + using (ec.With (BuilderContext.Options.OmitDebugInfo, true)) { + if (s.Resolve (bc)) { + Statement init = new If (new Binary (Binary.Operator.Equality, site_field_expr, new NullLiteral (loc)), s, loc); + init.Emit (ec); } - } - Expression target = new DelegateInvocation (new MemberAccess (site_field_expr, "Target", loc).Resolve (bc), args, loc).Resolve (bc); - if (target != null) - target.Emit (ec); + args = new Arguments (1 + dyn_args_count); + args.Add (new Argument (site_field_expr)); + if (arguments != null) { + int arg_pos = 1; + foreach (Argument a in arguments) { + if (a is NamedArgument) { + // Name is not valid in this context + args.Add (new Argument (a.Expr, a.ArgType)); + } else { + args.Add (a); + } + + if (inflate_using_mvar && a.Type != targs[arg_pos].Type) + a.Expr.Type = targs[arg_pos].Type; + + ++arg_pos; + } + } - SymbolWriter.CloseCompilerGeneratedBlock (ec); + Expression target = new DelegateInvocation (new MemberAccess (site_field_expr, "Target", loc).Resolve (bc), args, loc).Resolve (bc); + if (target != null) + target.Emit (ec); + } } public static MemberAccess GetBinderNamespace (Location loc) @@ -608,7 +608,9 @@ namespace Mono.CSharp public override void EmitStatement (EmitContext ec) { var stmt = new If (condition, new StatementExpression (invoke), new StatementExpression (assign), loc); - stmt.Emit (ec); + using (ec.With (BuilderContext.Options.OmitDebugInfo, true)) { + stmt.Emit (ec); + } } } @@ -733,15 +735,6 @@ namespace Mono.CSharp this.member = member; } - // - // When a return type is known not to be dynamic - // - public DynamicInvocation (ATypeNameExpression member, Arguments args, TypeSpec type, Location loc) - : this (member, args, loc) - { - this.type = type; - } - public static DynamicInvocation CreateSpecialNameInvoke (ATypeNameExpression member, Arguments args, Location loc) { return new DynamicInvocation (member, args, loc) { @@ -957,7 +950,7 @@ namespace Mono.CSharp sealed class DynamicSiteClass : HoistedStoreyClass { public DynamicSiteClass (TypeDefinition parent, MemberBase host, TypeParameters tparams) - : base (parent, MakeMemberName (host, "DynamicSite", parent.DynamicSitesCounter, tparams, Location.Null), tparams, Modifiers.STATIC) + : base (parent, MakeMemberName (host, "DynamicSite", parent.DynamicSitesCounter, tparams, Location.Null), tparams, Modifiers.STATIC, MemberKind.Class) { parent.DynamicSitesCounter++; }