You've already forked linux-packaging-mono
Imported Upstream version 3.8.0
Former-commit-id: 6a76a29bd07d86e57c6c8da45c65ed5447d38a61
This commit is contained in:
@@ -1321,16 +1321,28 @@ namespace Mono.CSharp {
|
||||
return Parameters;
|
||||
}
|
||||
|
||||
protected override Expression DoResolve (ResolveContext ec)
|
||||
protected override Expression DoResolve (ResolveContext rc)
|
||||
{
|
||||
if (ec.HasSet (ResolveContext.Options.ConstantScope)) {
|
||||
ec.Report.Error (1706, loc, "Anonymous methods and lambda expressions cannot be used in the current context");
|
||||
if (rc.HasSet (ResolveContext.Options.ConstantScope)) {
|
||||
rc.Report.Error (1706, loc, "Anonymous methods and lambda expressions cannot be used in the current context");
|
||||
return null;
|
||||
}
|
||||
|
||||
//
|
||||
// Set class type, set type
|
||||
// Update top-level block generated duting parsing with actual top-level block
|
||||
//
|
||||
if (rc.HasAny (ResolveContext.Options.FieldInitializerScope | ResolveContext.Options.BaseInitializer) && rc.CurrentMemberDefinition.Parent.PartialContainer.PrimaryConstructorParameters != null) {
|
||||
var tb = rc.ConstructorBlock.ParametersBlock.TopBlock;
|
||||
if (Block.TopBlock != tb) {
|
||||
Block b = Block;
|
||||
while (b.Parent != Block.TopBlock && b != Block.TopBlock)
|
||||
b = b.Parent;
|
||||
|
||||
b.Parent = tb;
|
||||
tb.IncludeBlock (Block, Block.TopBlock);
|
||||
b.ParametersBlock.TopBlock = tb;
|
||||
}
|
||||
}
|
||||
|
||||
eclass = ExprClass.Value;
|
||||
|
||||
@@ -1341,7 +1353,7 @@ namespace Mono.CSharp {
|
||||
//
|
||||
type = InternalType.AnonymousMethod;
|
||||
|
||||
if (!DoResolveParameters (ec))
|
||||
if (!DoResolveParameters (rc))
|
||||
return null;
|
||||
|
||||
return this;
|
||||
@@ -1357,9 +1369,12 @@ namespace Mono.CSharp {
|
||||
// nothing, as we only exist to not do anything.
|
||||
}
|
||||
|
||||
public static void Error_AddressOfCapturedVar (ResolveContext ec, IVariableReference var, Location loc)
|
||||
public static void Error_AddressOfCapturedVar (ResolveContext rc, IVariableReference var, Location loc)
|
||||
{
|
||||
ec.Report.Error (1686, loc,
|
||||
if (rc.CurrentAnonymousMethod is AsyncInitializer)
|
||||
return;
|
||||
|
||||
rc.Report.Error (1686, loc,
|
||||
"Local variable or parameter `{0}' cannot have their address taken and be used inside an anonymous method, lambda expression or query expression",
|
||||
var.Name);
|
||||
}
|
||||
@@ -1723,6 +1738,7 @@ namespace Mono.CSharp {
|
||||
Modifiers modifiers;
|
||||
TypeDefinition parent = null;
|
||||
TypeParameters hoisted_tparams = null;
|
||||
ParametersCompiled method_parameters = parameters;
|
||||
|
||||
var src_block = Block.Original.Explicit;
|
||||
if (src_block.HasCapturedVariable || src_block.HasCapturedThis) {
|
||||
@@ -1770,6 +1786,18 @@ namespace Mono.CSharp {
|
||||
parent = storey = ec.CurrentAnonymousMethod.Storey;
|
||||
|
||||
modifiers = Modifiers.STATIC | Modifiers.PRIVATE;
|
||||
|
||||
//
|
||||
// Convert generated method to closed delegate method where unused
|
||||
// this argument is generated during compilation which speeds up dispatch
|
||||
// by about 25%
|
||||
//
|
||||
|
||||
//
|
||||
// Disabled for now due to JIT bug
|
||||
//
|
||||
//method_parameters = ParametersCompiled.Prefix (method_parameters,
|
||||
// new Parameter (null, null, 0, null, loc), ec.Module.Compiler.BuiltinTypes.Object);
|
||||
}
|
||||
|
||||
if (storey == null && hoisted_tparams == null)
|
||||
@@ -1795,7 +1823,7 @@ namespace Mono.CSharp {
|
||||
|
||||
return new AnonymousMethodMethod (parent,
|
||||
this, storey, new TypeExpression (ReturnType, Location), modifiers,
|
||||
member_name, parameters);
|
||||
member_name, method_parameters);
|
||||
}
|
||||
|
||||
protected override Expression DoResolve (ResolveContext ec)
|
||||
@@ -1824,7 +1852,7 @@ namespace Mono.CSharp {
|
||||
}
|
||||
|
||||
bool is_static = (method.ModFlags & Modifiers.STATIC) != 0;
|
||||
if (is_static && am_cache == null) {
|
||||
if (is_static && am_cache == null && !ec.IsStaticConstructor) {
|
||||
//
|
||||
// Creates a field cache to store delegate instance if it's not generic
|
||||
//
|
||||
|
||||
@@ -276,6 +276,16 @@ namespace Mono.CSharp
|
||||
ordered.Add (arg);
|
||||
}
|
||||
|
||||
public override void FlowAnalysis (FlowAnalysisContext fc, List<MovableArgument> movable = null)
|
||||
{
|
||||
foreach (var arg in ordered) {
|
||||
if (arg.ArgType != Argument.AType.Out)
|
||||
arg.FlowAnalysis (fc);
|
||||
}
|
||||
|
||||
base.FlowAnalysis (fc, ordered);
|
||||
}
|
||||
|
||||
public override Arguments Emit (EmitContext ec, bool dup_args, bool prepareAwait)
|
||||
{
|
||||
foreach (var a in ordered) {
|
||||
@@ -497,7 +507,7 @@ namespace Mono.CSharp
|
||||
return null;
|
||||
}
|
||||
|
||||
public void FlowAnalysis (FlowAnalysisContext fc)
|
||||
public virtual void FlowAnalysis (FlowAnalysisContext fc, List<MovableArgument> movable = null)
|
||||
{
|
||||
bool has_out = false;
|
||||
foreach (var arg in args) {
|
||||
@@ -506,7 +516,14 @@ namespace Mono.CSharp
|
||||
continue;
|
||||
}
|
||||
|
||||
arg.FlowAnalysis (fc);
|
||||
if (movable == null) {
|
||||
arg.FlowAnalysis (fc);
|
||||
continue;
|
||||
}
|
||||
|
||||
var ma = arg as MovableArgument;
|
||||
if (ma != null && !movable.Contains (ma))
|
||||
arg.FlowAnalysis (fc);
|
||||
}
|
||||
|
||||
if (!has_out)
|
||||
|
||||
@@ -207,7 +207,7 @@ namespace Mono.CSharp
|
||||
return;
|
||||
|
||||
if (Compiler.Settings.Target == Target.Exe) {
|
||||
a.Error_AttributeEmitError ("The executables cannot be satelite assemblies, remove the attribute or keep it empty");
|
||||
Report.Error (7059, a.Location, "Executables cannot be satellite assemblies. Remove the attribute or keep it empty");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -231,7 +231,8 @@ namespace Mono.CSharp
|
||||
|
||||
var vinfo = IsValidAssemblyVersion (value, true);
|
||||
if (vinfo == null) {
|
||||
a.Error_AttributeEmitError (string.Format ("Specified version `{0}' is not valid", value));
|
||||
Report.Error (7034, a.Location, "The specified version string `{0}' does not conform to the required format - major[.minor[.build[.revision]]]",
|
||||
value);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -322,13 +323,18 @@ namespace Mono.CSharp
|
||||
|
||||
if (a.Type == pa.InternalsVisibleTo) {
|
||||
string assembly_name = a.GetString ();
|
||||
if (assembly_name == null) {
|
||||
Report.Error (7030, a.Location, "Friend assembly reference cannot have `null' value");
|
||||
return;
|
||||
}
|
||||
|
||||
if (assembly_name.Length == 0)
|
||||
return;
|
||||
#if STATIC
|
||||
ParsedAssemblyName aname;
|
||||
ParseAssemblyResult r = Fusion.ParseAssemblyName (assembly_name, out aname);
|
||||
if (r != ParseAssemblyResult.OK) {
|
||||
Report.Warning (1700, 3, a.Location, "Assembly reference `{0}' is invalid and cannot be resolved",
|
||||
Report.Warning (1700, 3, a.Location, "Friend assembly reference `{0}' is invalid and cannot be resolved",
|
||||
assembly_name);
|
||||
return;
|
||||
}
|
||||
@@ -353,7 +359,7 @@ namespace Mono.CSharp
|
||||
} else if (a.Type == pa.AssemblyFileVersion) {
|
||||
vi_product_version = a.GetString ();
|
||||
if (string.IsNullOrEmpty (vi_product_version) || IsValidAssemblyVersion (vi_product_version, false) == null) {
|
||||
Report.Warning (1607, 1, a.Location, "The version number `{0}' specified for `{1}' is invalid",
|
||||
Report.Warning (7035, 1, a.Location, "The specified version string `{0}' does not conform to the recommended format major.minor.build.revision",
|
||||
vi_product_version, a.Name);
|
||||
return;
|
||||
}
|
||||
@@ -399,8 +405,8 @@ namespace Mono.CSharp
|
||||
}
|
||||
|
||||
var ci = a.Assembly.GetName ().CultureInfo;
|
||||
if (!ci.Equals (System.Globalization.CultureInfo.InvariantCulture)) {
|
||||
Report.Warning (1607, 1, "Referenced assembly `{0}' has different culture setting of `{1}'",
|
||||
if (!ci.Equals (CultureInfo.InvariantCulture)) {
|
||||
Report.Warning (8009, 1, "Referenced assembly `{0}' has different culture setting of `{1}'",
|
||||
a.Name, ci.Name);
|
||||
}
|
||||
|
||||
|
||||
@@ -645,6 +645,7 @@ namespace Mono.CSharp {
|
||||
public override void FlowAnalysis (FlowAnalysisContext fc)
|
||||
{
|
||||
source.FlowAnalysis (fc);
|
||||
((FieldExpr) target).SetFieldAssigned (fc);
|
||||
}
|
||||
|
||||
public bool IsDefaultInitializer {
|
||||
|
||||
@@ -74,10 +74,6 @@ namespace Mono.CSharp
|
||||
|
||||
protected override Expression DoResolve (ResolveContext rc)
|
||||
{
|
||||
if (rc.HasSet (ResolveContext.Options.FinallyScope)) {
|
||||
rc.Report.Error (1984, loc, "The `await' operator cannot be used in the body of a finally clause");
|
||||
}
|
||||
|
||||
if (rc.HasSet (ResolveContext.Options.LockScope)) {
|
||||
rc.Report.Error (1996, loc,
|
||||
"The `await' operator cannot be used in the body of a lock statement");
|
||||
@@ -244,7 +240,7 @@ namespace Mono.CSharp
|
||||
var fe_awaiter = new FieldExpr (awaiter, loc);
|
||||
fe_awaiter.InstanceExpression = new CompilerGeneratedThis (ec.CurrentType, loc);
|
||||
|
||||
Label skip_continuation = ec.DefineLabel ();
|
||||
Label skip_continuation = ec.DefineLabel ();
|
||||
|
||||
using (ec.With (BuilderContext.Options.OmitDebugInfo, true)) {
|
||||
//
|
||||
@@ -324,10 +320,6 @@ namespace Mono.CSharp
|
||||
return false;
|
||||
}
|
||||
|
||||
if (bc.HasSet (ResolveContext.Options.CatchScope)) {
|
||||
bc.Report.Error (1985, loc, "The `await' operator cannot be used in a catch clause");
|
||||
}
|
||||
|
||||
if (!base.Resolve (bc))
|
||||
return false;
|
||||
|
||||
@@ -447,6 +439,10 @@ namespace Mono.CSharp
|
||||
get; set;
|
||||
}
|
||||
|
||||
public StackFieldExpr HoistedReturnState {
|
||||
get; set;
|
||||
}
|
||||
|
||||
public override bool IsIterator {
|
||||
get {
|
||||
return false;
|
||||
@@ -464,9 +460,9 @@ namespace Mono.CSharp
|
||||
protected override BlockContext CreateBlockContext (BlockContext bc)
|
||||
{
|
||||
var ctx = base.CreateBlockContext (bc);
|
||||
var lambda = bc.CurrentAnonymousMethod as LambdaMethod;
|
||||
if (lambda != null)
|
||||
return_inference = lambda.ReturnTypeInference;
|
||||
var am = bc.CurrentAnonymousMethod as AnonymousMethodBody;
|
||||
if (am != null)
|
||||
return_inference = am.ReturnTypeInference;
|
||||
|
||||
ctx.Set (ResolveContext.Options.TryScope);
|
||||
|
||||
@@ -478,6 +474,24 @@ namespace Mono.CSharp
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public void EmitCatchBlock (EmitContext ec)
|
||||
{
|
||||
var catch_value = LocalVariable.CreateCompilerGenerated (ec.Module.Compiler.BuiltinTypes.Exception, block, Location);
|
||||
|
||||
ec.BeginCatchBlock (catch_value.Type);
|
||||
catch_value.EmitAssign (ec);
|
||||
|
||||
ec.EmitThis ();
|
||||
ec.EmitInt ((int) IteratorStorey.State.After);
|
||||
ec.Emit (OpCodes.Stfld, storey.PC.Spec);
|
||||
|
||||
((AsyncTaskStorey) Storey).EmitSetException (ec, new LocalVariableReference (catch_value, Location));
|
||||
|
||||
ec.Emit (OpCodes.Leave, move_next_ok);
|
||||
ec.EndExceptionBlock ();
|
||||
|
||||
}
|
||||
|
||||
protected override void EmitMoveNextEpilogue (EmitContext ec)
|
||||
{
|
||||
var storey = (AsyncTaskStorey) Storey;
|
||||
@@ -509,7 +523,6 @@ namespace Mono.CSharp
|
||||
MethodSpec builder_factory;
|
||||
MethodSpec builder_start;
|
||||
PropertySpec task;
|
||||
LocalVariable hoisted_return;
|
||||
int locals_captured;
|
||||
Dictionary<TypeSpec, List<Field>> stack_fields;
|
||||
Dictionary<TypeSpec, List<Field>> awaiter_fields;
|
||||
@@ -523,11 +536,7 @@ namespace Mono.CSharp
|
||||
|
||||
#region Properties
|
||||
|
||||
public LocalVariable HoistedReturn {
|
||||
get {
|
||||
return hoisted_return;
|
||||
}
|
||||
}
|
||||
public Expression HoistedReturnValue { get; set; }
|
||||
|
||||
public TypeSpec ReturnType {
|
||||
get {
|
||||
@@ -576,7 +585,7 @@ namespace Mono.CSharp
|
||||
return field;
|
||||
}
|
||||
|
||||
public Field AddCapturedLocalVariable (TypeSpec type)
|
||||
public Field AddCapturedLocalVariable (TypeSpec type, bool requiresUninitialized = false)
|
||||
{
|
||||
if (mutator != null)
|
||||
type = mutator.Mutate (type);
|
||||
@@ -584,7 +593,7 @@ namespace Mono.CSharp
|
||||
List<Field> existing_fields = null;
|
||||
if (stack_fields == null) {
|
||||
stack_fields = new Dictionary<TypeSpec, List<Field>> ();
|
||||
} else if (stack_fields.TryGetValue (type, out existing_fields)) {
|
||||
} else if (stack_fields.TryGetValue (type, out existing_fields) && !requiresUninitialized) {
|
||||
foreach (var f in existing_fields) {
|
||||
if (f.IsAvailableForReuse) {
|
||||
f.IsAvailableForReuse = false;
|
||||
@@ -717,7 +726,7 @@ namespace Mono.CSharp
|
||||
set_state_machine.Block.AddStatement (new StatementExpression (new Invocation (mg, args)));
|
||||
|
||||
if (has_task_return_type) {
|
||||
hoisted_return = LocalVariable.CreateCompilerGenerated (bt.TypeArguments[0], StateMachineMethod.Block, Location);
|
||||
HoistedReturnValue = TemporaryVariableReference.Create (bt.TypeArguments [0], StateMachineMethod.Block, Location);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -904,11 +913,11 @@ namespace Mono.CSharp
|
||||
};
|
||||
|
||||
Arguments args;
|
||||
if (hoisted_return == null) {
|
||||
if (HoistedReturnValue == null) {
|
||||
args = new Arguments (0);
|
||||
} else {
|
||||
args = new Arguments (1);
|
||||
args.Add (new Argument (new LocalVariableReference (hoisted_return, Location)));
|
||||
args.Add (new Argument (HoistedReturnValue));
|
||||
}
|
||||
|
||||
using (ec.With (BuilderContext.Options.OmitDebugInfo, true)) {
|
||||
|
||||
@@ -258,19 +258,22 @@ namespace Mono.CSharp {
|
||||
Report.Error (1970, loc, "Do not use `{0}' directly. Use `dynamic' keyword instead", GetSignatureForError ());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is rather hack. We report many emit attribute error with same error to be compatible with
|
||||
/// csc. But because csc has to report them this way because error came from ilasm we needn't.
|
||||
/// </summary>
|
||||
public void Error_AttributeEmitError (string inner)
|
||||
void Error_AttributeEmitError (string inner)
|
||||
{
|
||||
Report.Error (647, Location, "Error during emitting `{0}' attribute. The reason is `{1}'",
|
||||
Type.GetSignatureForError (), inner);
|
||||
}
|
||||
|
||||
public void Error_InvalidArgumentValue (TypeSpec attributeType)
|
||||
{
|
||||
Report.Error (591, Location, "Invalid value for argument to `{0}' attribute", attributeType.GetSignatureForError ());
|
||||
}
|
||||
|
||||
public void Error_InvalidSecurityParent ()
|
||||
{
|
||||
Error_AttributeEmitError ("it is attached to invalid parent");
|
||||
Report.Error (7070, Location,
|
||||
"Security attribute `{0}' is not valid on this declaration type. Security attributes are only valid on assembly, type and method declarations",
|
||||
Type.GetSignatureForError ());
|
||||
}
|
||||
|
||||
Attributable Owner {
|
||||
@@ -412,7 +415,7 @@ namespace Mono.CSharp {
|
||||
return ((MethodImplOptions) value | all) == all;
|
||||
}
|
||||
|
||||
static bool IsValidArgumentType (TypeSpec t)
|
||||
public static bool IsValidArgumentType (TypeSpec t)
|
||||
{
|
||||
if (t.IsArray) {
|
||||
var ac = (ArrayContainer) t;
|
||||
@@ -831,6 +834,7 @@ namespace Mono.CSharp {
|
||||
{
|
||||
SecurityAction action = GetSecurityActionValue ();
|
||||
bool for_assembly = Target == AttributeTargets.Assembly || Target == AttributeTargets.Module;
|
||||
var c = (Constant)pos_args [0].Expr;
|
||||
|
||||
switch (action) {
|
||||
#pragma warning disable 618
|
||||
@@ -853,11 +857,22 @@ namespace Mono.CSharp {
|
||||
#pragma warning restore 618
|
||||
|
||||
default:
|
||||
Error_AttributeEmitError ("SecurityAction is out of range");
|
||||
Report.Error (7049, c.Location, "Security attribute `{0}' has an invalid SecurityAction value `{1}'",
|
||||
Type.GetSignatureForError (), c.GetValueAsLiteral());
|
||||
return false;
|
||||
}
|
||||
|
||||
Error_AttributeEmitError (String.Concat ("SecurityAction `", action, "' is not valid for this declaration"));
|
||||
switch (Target) {
|
||||
case AttributeTargets.Assembly:
|
||||
Report.Error (7050, c.Location, "SecurityAction value `{0}' is invalid for security attributes applied to an assembly",
|
||||
c.GetSignatureForError ());
|
||||
break;
|
||||
default:
|
||||
Report.Error (7051, c.Location, "SecurityAction value `{0}' is invalid for security attributes applied to a type or a method",
|
||||
c.GetSignatureForError ());
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1026,44 +1041,42 @@ namespace Mono.CSharp {
|
||||
return;
|
||||
}
|
||||
} else if (Type == predefined.Guid) {
|
||||
string v = ((StringConstant) arg_expr).Value;
|
||||
try {
|
||||
string v = ((StringConstant) arg_expr).Value;
|
||||
new Guid (v);
|
||||
} catch (Exception e) {
|
||||
Error_AttributeEmitError (e.Message);
|
||||
} catch {
|
||||
Error_InvalidArgumentValue (Type);
|
||||
return;
|
||||
}
|
||||
} else if (Type == predefined.AttributeUsage) {
|
||||
int v = ((IntConstant) ((EnumConstant) arg_expr).Child).Value;
|
||||
if (v == 0) {
|
||||
context.Module.Compiler.Report.Error (591, Location, "Invalid value for argument to `{0}' attribute",
|
||||
"System.AttributeUsage");
|
||||
}
|
||||
if (v == 0)
|
||||
Error_InvalidArgumentValue (Type);
|
||||
} else if (Type == predefined.MarshalAs) {
|
||||
if (pos_args.Count == 1) {
|
||||
var u_type = (UnmanagedType) System.Enum.Parse (typeof (UnmanagedType), ((Constant) pos_args[0].Expr).GetValue ().ToString ());
|
||||
if (u_type == UnmanagedType.ByValArray && !(Owner is FieldBase)) {
|
||||
Error_AttributeEmitError ("Specified unmanaged type is only valid on fields");
|
||||
Report.Error (7055, pos_args [0].Expr.Location, "Unmanaged type `ByValArray' is only valid for fields");
|
||||
}
|
||||
}
|
||||
} else if (Type == predefined.DllImport) {
|
||||
if (pos_args.Count == 1 && pos_args[0].Expr is Constant) {
|
||||
var value = ((Constant) pos_args[0].Expr).GetValue () as string;
|
||||
if (string.IsNullOrEmpty (value))
|
||||
Error_AttributeEmitError ("DllName cannot be empty or null");
|
||||
Error_InvalidArgumentValue (Type);
|
||||
}
|
||||
} else if (Type == predefined.MethodImpl) {
|
||||
if (pos_args.Count == 1) {
|
||||
var value = (int) ((Constant) arg_expr).GetValueAsLong ();
|
||||
|
||||
if (!IsValidMethodImplOption (value)) {
|
||||
Error_AttributeEmitError ("Incorrect argument value");
|
||||
Error_InvalidArgumentValue (Type);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
arg_expr.EncodeAttributeValue (context, encoder, pt);
|
||||
arg_expr.EncodeAttributeValue (context, encoder, pt, pt);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1077,7 +1090,7 @@ namespace Mono.CSharp {
|
||||
|
||||
encoder.Encode (na.Key.Type);
|
||||
encoder.Encode (na.Value.Name);
|
||||
na.Value.Expr.EncodeAttributeValue (context, encoder, na.Key.Type);
|
||||
na.Value.Expr.EncodeAttributeValue (context, encoder, na.Key.Type, na.Key.Type);
|
||||
}
|
||||
} else {
|
||||
encoder.EncodeEmptyNamedArguments ();
|
||||
@@ -1527,7 +1540,7 @@ namespace Mono.CSharp {
|
||||
Encode ((byte) 0x54); // property
|
||||
Encode (property.MemberType);
|
||||
Encode (property.Name);
|
||||
value.EncodeAttributeValue (null, this, property.MemberType);
|
||||
value.EncodeAttributeValue (null, this, property.MemberType, property.MemberType);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -1539,7 +1552,7 @@ namespace Mono.CSharp {
|
||||
Encode ((byte) 0x53); // field
|
||||
Encode (field.MemberType);
|
||||
Encode (field.Name);
|
||||
value.EncodeAttributeValue (null, this, field.MemberType);
|
||||
value.EncodeAttributeValue (null, this, field.MemberType, field.MemberType);
|
||||
}
|
||||
|
||||
public void EncodeNamedArguments<T> (T[] members, Constant[] values) where T : MemberSpec, IInterfaceMemberSpec
|
||||
@@ -1559,7 +1572,7 @@ namespace Mono.CSharp {
|
||||
|
||||
Encode (member.MemberType);
|
||||
Encode (member.Name);
|
||||
values [i].EncodeAttributeValue (null, this, member.MemberType);
|
||||
values [i].EncodeAttributeValue (null, this, member.MemberType, member.MemberType);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -309,10 +309,10 @@ namespace Mono.CSharp {
|
||||
return new StringConstant (ec.BuiltinTypes, (string)left.GetValue () + (string)right.GetValue (),
|
||||
left.Location);
|
||||
|
||||
if (lt == InternalType.NullLiteral)
|
||||
if (lt == InternalType.NullLiteral || left.IsNull)
|
||||
return new StringConstant (ec.BuiltinTypes, "" + right.GetValue (), left.Location);
|
||||
|
||||
if (rt == InternalType.NullLiteral)
|
||||
if (rt == InternalType.NullLiteral || right.IsNull)
|
||||
return new StringConstant (ec.BuiltinTypes, left.GetValue () + "", left.Location);
|
||||
|
||||
return null;
|
||||
@@ -367,8 +367,8 @@ namespace Mono.CSharp {
|
||||
return null;
|
||||
|
||||
result = result.Reduce (ec, lt);
|
||||
if (result == null)
|
||||
return null;
|
||||
if (result == null || lt.IsEnum)
|
||||
return result;
|
||||
|
||||
return new EnumConstant (result, lt);
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
36761432a51625ec32235fbaa18324d0989c536d
|
||||
cda04c0e840c340724df311555d8b98032efd8bf
|
||||
@@ -155,6 +155,12 @@ namespace Mono.CSharp
|
||||
get { return member_context.IsStatic; }
|
||||
}
|
||||
|
||||
public bool IsStaticConstructor {
|
||||
get {
|
||||
return member_context.IsStatic && (flags & Options.ConstructorScope) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsAnonymousStoreyMutateRequired {
|
||||
get {
|
||||
return CurrentAnonymousMethod != null &&
|
||||
@@ -175,6 +181,12 @@ namespace Mono.CSharp
|
||||
}
|
||||
}
|
||||
|
||||
public bool NotifyEvaluatorOnStore {
|
||||
get {
|
||||
return Module.Evaluator != null && Module.Evaluator.ModificationListener != null;
|
||||
}
|
||||
}
|
||||
|
||||
// Has to be used for specific emitter errors only any
|
||||
// possible resolver errors have to be reported during Resolve
|
||||
public Report Report {
|
||||
@@ -204,6 +216,10 @@ namespace Mono.CSharp
|
||||
}
|
||||
}
|
||||
|
||||
public LocalVariable AsyncThrowVariable { get; set; }
|
||||
|
||||
public List<TryFinally> TryFinallyUnwind { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
public void AddStatementEpilog (IExpressionCleanup cleanupExpression)
|
||||
@@ -380,9 +396,9 @@ namespace Mono.CSharp
|
||||
//
|
||||
// Creates temporary field in current async storey
|
||||
//
|
||||
public StackFieldExpr GetTemporaryField (TypeSpec type)
|
||||
public StackFieldExpr GetTemporaryField (TypeSpec type, bool initializedFieldRequired = false)
|
||||
{
|
||||
var f = AsyncTaskStorey.AddCapturedLocalVariable (type);
|
||||
var f = AsyncTaskStorey.AddCapturedLocalVariable (type, initializedFieldRequired);
|
||||
var fexpr = new StackFieldExpr (f);
|
||||
fexpr.InstanceExpression = new CompilerGeneratedThis (CurrentType, Location.Null);
|
||||
return fexpr;
|
||||
@@ -518,8 +534,16 @@ namespace Mono.CSharp
|
||||
type = EnumSpec.GetUnderlyingType (type);
|
||||
|
||||
switch (type.BuiltinType) {
|
||||
case BuiltinTypeSpec.Type.Byte:
|
||||
case BuiltinTypeSpec.Type.Bool:
|
||||
//
|
||||
// Workaround MSIL limitation. Load bool element as single bit,
|
||||
// bool array can actually store any byte value
|
||||
//
|
||||
ig.Emit (OpCodes.Ldelem_U1);
|
||||
ig.Emit (OpCodes.Ldc_I4_0);
|
||||
ig.Emit (OpCodes.Cgt_Un);
|
||||
break;
|
||||
case BuiltinTypeSpec.Type.Byte:
|
||||
ig.Emit (OpCodes.Ldelem_U1);
|
||||
break;
|
||||
case BuiltinTypeSpec.Type.SByte:
|
||||
@@ -734,8 +758,12 @@ namespace Mono.CSharp
|
||||
ig.Emit (OpCodes.Ldind_U1);
|
||||
break;
|
||||
case BuiltinTypeSpec.Type.SByte:
|
||||
ig.Emit (OpCodes.Ldind_I1);
|
||||
break;
|
||||
case BuiltinTypeSpec.Type.Bool:
|
||||
ig.Emit (OpCodes.Ldind_I1);
|
||||
ig.Emit (OpCodes.Ldc_I4_0);
|
||||
ig.Emit (OpCodes.Cgt_Un);
|
||||
break;
|
||||
case BuiltinTypeSpec.Type.ULong:
|
||||
case BuiltinTypeSpec.Type.Long:
|
||||
@@ -1036,7 +1064,7 @@ namespace Mono.CSharp
|
||||
}
|
||||
}
|
||||
|
||||
if (call_op == OpCodes.Callvirt && (InstanceExpression.Type.IsGenericParameter || InstanceExpression.Type.IsStruct)) {
|
||||
if (call_op == OpCodes.Callvirt && (InstanceExpression.Type.IsGenericParameter || InstanceExpression.Type.IsStructOrEnum)) {
|
||||
ec.Emit (OpCodes.Constrained, InstanceExpression.Type);
|
||||
}
|
||||
|
||||
@@ -1076,7 +1104,7 @@ namespace Mono.CSharp
|
||||
//
|
||||
// Push the instance expression
|
||||
//
|
||||
if ((instance_type.IsStruct && (callOpcode == OpCodes.Callvirt || (callOpcode == OpCodes.Call && declaringType.IsStruct))) ||
|
||||
if ((instance_type.IsStructOrEnum && (callOpcode == OpCodes.Callvirt || (callOpcode == OpCodes.Call && declaringType.IsStruct))) ||
|
||||
instance_type.IsGenericParameter || declaringType.IsNullableType) {
|
||||
//
|
||||
// If the expression implements IMemoryLocation, then
|
||||
@@ -1098,7 +1126,7 @@ namespace Mono.CSharp
|
||||
return ReferenceContainer.MakeType (ec.Module, instance_type);
|
||||
}
|
||||
|
||||
if (instance_type.IsEnum || instance_type.IsStruct) {
|
||||
if (instance_type.IsStructOrEnum) {
|
||||
instance.Emit (ec);
|
||||
ec.Emit (OpCodes.Box, instance_type);
|
||||
return ec.BuiltinTypes.Object;
|
||||
|
||||
@@ -522,7 +522,7 @@ namespace Mono.CSharp {
|
||||
return Value ? 1 : 0;
|
||||
}
|
||||
|
||||
public override void EncodeAttributeValue (IMemberContext rc, AttributeEncoder enc, TypeSpec targetType)
|
||||
public override void EncodeAttributeValue (IMemberContext rc, AttributeEncoder enc, TypeSpec targetType, TypeSpec parameterType)
|
||||
{
|
||||
enc.Encode (Value);
|
||||
}
|
||||
@@ -573,7 +573,7 @@ namespace Mono.CSharp {
|
||||
Value = v;
|
||||
}
|
||||
|
||||
public override void EncodeAttributeValue (IMemberContext rc, AttributeEncoder enc, TypeSpec targetType)
|
||||
public override void EncodeAttributeValue (IMemberContext rc, AttributeEncoder enc, TypeSpec targetType, TypeSpec parameterType)
|
||||
{
|
||||
enc.Encode (Value);
|
||||
}
|
||||
@@ -673,7 +673,7 @@ namespace Mono.CSharp {
|
||||
Value = v;
|
||||
}
|
||||
|
||||
public override void EncodeAttributeValue (IMemberContext rc, AttributeEncoder enc, TypeSpec targetType)
|
||||
public override void EncodeAttributeValue (IMemberContext rc, AttributeEncoder enc, TypeSpec targetType, TypeSpec parameterType)
|
||||
{
|
||||
enc.Encode ((ushort) Value);
|
||||
}
|
||||
@@ -801,7 +801,7 @@ namespace Mono.CSharp {
|
||||
Value = v;
|
||||
}
|
||||
|
||||
public override void EncodeAttributeValue (IMemberContext rc, AttributeEncoder enc, TypeSpec targetType)
|
||||
public override void EncodeAttributeValue (IMemberContext rc, AttributeEncoder enc, TypeSpec targetType, TypeSpec parameterType)
|
||||
{
|
||||
enc.Encode (Value);
|
||||
}
|
||||
@@ -904,7 +904,7 @@ namespace Mono.CSharp {
|
||||
Value = v;
|
||||
}
|
||||
|
||||
public override void EncodeAttributeValue (IMemberContext rc, AttributeEncoder enc, TypeSpec targetType)
|
||||
public override void EncodeAttributeValue (IMemberContext rc, AttributeEncoder enc, TypeSpec targetType, TypeSpec parameterType)
|
||||
{
|
||||
enc.Encode (Value);
|
||||
}
|
||||
@@ -1017,7 +1017,7 @@ namespace Mono.CSharp {
|
||||
Value = v;
|
||||
}
|
||||
|
||||
public override void EncodeAttributeValue (IMemberContext rc, AttributeEncoder enc, TypeSpec targetType)
|
||||
public override void EncodeAttributeValue (IMemberContext rc, AttributeEncoder enc, TypeSpec targetType, TypeSpec parameterType)
|
||||
{
|
||||
enc.Encode (Value);
|
||||
}
|
||||
@@ -1126,7 +1126,7 @@ namespace Mono.CSharp {
|
||||
Value = v;
|
||||
}
|
||||
|
||||
public override void EncodeAttributeValue (IMemberContext rc, AttributeEncoder enc, TypeSpec targetType)
|
||||
public override void EncodeAttributeValue (IMemberContext rc, AttributeEncoder enc, TypeSpec targetType, TypeSpec parameterType)
|
||||
{
|
||||
enc.Encode (Value);
|
||||
}
|
||||
@@ -1302,7 +1302,7 @@ namespace Mono.CSharp {
|
||||
Value = v;
|
||||
}
|
||||
|
||||
public override void EncodeAttributeValue (IMemberContext rc, AttributeEncoder enc, TypeSpec targetType)
|
||||
public override void EncodeAttributeValue (IMemberContext rc, AttributeEncoder enc, TypeSpec targetType, TypeSpec parameterType)
|
||||
{
|
||||
enc.Encode (Value);
|
||||
}
|
||||
@@ -1419,7 +1419,7 @@ namespace Mono.CSharp {
|
||||
Value = v;
|
||||
}
|
||||
|
||||
public override void EncodeAttributeValue (IMemberContext rc, AttributeEncoder enc, TypeSpec targetType)
|
||||
public override void EncodeAttributeValue (IMemberContext rc, AttributeEncoder enc, TypeSpec targetType, TypeSpec parameterType)
|
||||
{
|
||||
enc.Encode (Value);
|
||||
}
|
||||
@@ -1550,7 +1550,7 @@ namespace Mono.CSharp {
|
||||
Value = v;
|
||||
}
|
||||
|
||||
public override void EncodeAttributeValue (IMemberContext rc, AttributeEncoder enc, TypeSpec targetType)
|
||||
public override void EncodeAttributeValue (IMemberContext rc, AttributeEncoder enc, TypeSpec targetType, TypeSpec parameterType)
|
||||
{
|
||||
enc.Encode (Value);
|
||||
}
|
||||
@@ -1674,7 +1674,7 @@ namespace Mono.CSharp {
|
||||
return base.ConvertImplicitly (type);
|
||||
}
|
||||
|
||||
public override void EncodeAttributeValue (IMemberContext rc, AttributeEncoder enc, TypeSpec targetType)
|
||||
public override void EncodeAttributeValue (IMemberContext rc, AttributeEncoder enc, TypeSpec targetType, TypeSpec parameterType)
|
||||
{
|
||||
enc.Encode (Value);
|
||||
}
|
||||
@@ -1803,7 +1803,7 @@ namespace Mono.CSharp {
|
||||
Value = v;
|
||||
}
|
||||
|
||||
public override void EncodeAttributeValue (IMemberContext rc, AttributeEncoder enc, TypeSpec targetType)
|
||||
public override void EncodeAttributeValue (IMemberContext rc, AttributeEncoder enc, TypeSpec targetType, TypeSpec parameterType)
|
||||
{
|
||||
enc.Encode (Value);
|
||||
}
|
||||
@@ -2088,7 +2088,7 @@ namespace Mono.CSharp {
|
||||
ec.Emit (OpCodes.Ldstr, Value);
|
||||
}
|
||||
|
||||
public override void EncodeAttributeValue (IMemberContext rc, AttributeEncoder enc, TypeSpec targetType)
|
||||
public override void EncodeAttributeValue (IMemberContext rc, AttributeEncoder enc, TypeSpec targetType, TypeSpec parameterType)
|
||||
{
|
||||
// cast to object
|
||||
if (type != targetType)
|
||||
@@ -2153,7 +2153,7 @@ namespace Mono.CSharp {
|
||||
return base.CreateExpressionTree (ec);
|
||||
}
|
||||
|
||||
public override void EncodeAttributeValue (IMemberContext rc, AttributeEncoder enc, TypeSpec targetType)
|
||||
public override void EncodeAttributeValue (IMemberContext rc, AttributeEncoder enc, TypeSpec targetType, TypeSpec parameterType)
|
||||
{
|
||||
switch (targetType.BuiltinType) {
|
||||
case BuiltinTypeSpec.Type.Object:
|
||||
@@ -2174,7 +2174,7 @@ namespace Mono.CSharp {
|
||||
break;
|
||||
}
|
||||
|
||||
base.EncodeAttributeValue (rc, enc, targetType);
|
||||
base.EncodeAttributeValue (rc, enc, targetType, parameterType);
|
||||
}
|
||||
|
||||
public override void Emit (EmitContext ec)
|
||||
@@ -2314,6 +2314,11 @@ namespace Mono.CSharp {
|
||||
}
|
||||
}
|
||||
|
||||
public override bool ContainsEmitWithAwait ()
|
||||
{
|
||||
return side_effect.ContainsEmitWithAwait ();
|
||||
}
|
||||
|
||||
public override object GetValue ()
|
||||
{
|
||||
return value.GetValue ();
|
||||
@@ -2341,6 +2346,11 @@ namespace Mono.CSharp {
|
||||
value.EmitSideEffect (ec);
|
||||
}
|
||||
|
||||
public override void FlowAnalysis (FlowAnalysisContext fc)
|
||||
{
|
||||
side_effect.FlowAnalysis (fc);
|
||||
}
|
||||
|
||||
public override bool IsDefaultValue {
|
||||
get { return value.IsDefaultValue; }
|
||||
}
|
||||
|
||||
@@ -664,7 +664,7 @@ namespace Mono.CSharp
|
||||
|
||||
ConstructorScope = 1 << 3,
|
||||
|
||||
AsyncBody = 1 << 4
|
||||
AsyncBody = 1 << 4,
|
||||
}
|
||||
|
||||
// utility helper for CheckExpr, UnCheckExpr, Checked and Unchecked statements
|
||||
|
||||
@@ -27,6 +27,15 @@ namespace Mono.CSharp {
|
||||
//
|
||||
static class Convert
|
||||
{
|
||||
[Flags]
|
||||
public enum UserConversionRestriction
|
||||
{
|
||||
None = 0,
|
||||
ImplicitOnly = 1,
|
||||
ProbingOnly = 1 << 1,
|
||||
NullableSourceOnly = 1 << 2
|
||||
|
||||
}
|
||||
//
|
||||
// From a one-dimensional array-type S[] to System.Collections.IList<T> and base
|
||||
// interfaces of this interface, provided there is an implicit reference conversion
|
||||
@@ -675,7 +684,7 @@ namespace Mono.CSharp {
|
||||
//
|
||||
public static bool ImplicitConversionExists (ResolveContext ec, Expression expr, TypeSpec target_type)
|
||||
{
|
||||
if (ImplicitStandardConversionExists (expr, target_type))
|
||||
if (ImplicitStandardConversionExists (ec, expr, target_type))
|
||||
return true;
|
||||
|
||||
if (expr.Type == InternalType.AnonymousMethod) {
|
||||
@@ -686,21 +695,27 @@ namespace Mono.CSharp {
|
||||
return ame.ImplicitStandardConversionExists (ec, target_type);
|
||||
}
|
||||
|
||||
// Conversion from __arglist to System.ArgIterator
|
||||
if (expr.Type == InternalType.Arglist)
|
||||
return target_type == ec.Module.PredefinedTypes.ArgIterator.TypeSpec;
|
||||
|
||||
return UserDefinedConversion (ec, expr, target_type,
|
||||
UserConversionRestriction.ImplicitOnly | UserConversionRestriction.ProbingOnly, Location.Null) != null;
|
||||
}
|
||||
|
||||
public static bool ImplicitStandardConversionExists (ResolveContext rc, Expression expr, TypeSpec target_type)
|
||||
{
|
||||
if (expr.eclass == ExprClass.MethodGroup) {
|
||||
if (target_type.IsDelegate && ec.Module.Compiler.Settings.Version != LanguageVersion.ISO_1) {
|
||||
if (target_type.IsDelegate && rc.Module.Compiler.Settings.Version != LanguageVersion.ISO_1) {
|
||||
MethodGroupExpr mg = expr as MethodGroupExpr;
|
||||
if (mg != null)
|
||||
return DelegateCreation.ImplicitStandardConversionExists (ec, mg, target_type);
|
||||
return DelegateCreation.ImplicitStandardConversionExists (rc, mg, target_type);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Conversion from __arglist to System.ArgIterator
|
||||
if (expr.Type == InternalType.Arglist)
|
||||
return target_type == ec.Module.PredefinedTypes.ArgIterator.TypeSpec;
|
||||
|
||||
return UserDefinedConversion (ec, expr, target_type, true, true, Location.Null) != null;
|
||||
return ImplicitStandardConversionExists (expr, target_type);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -911,7 +926,7 @@ namespace Mono.CSharp {
|
||||
// by making use of FindMostEncomp* methods. Applies the correct rules separately
|
||||
// for explicit and implicit conversion operators.
|
||||
//
|
||||
static TypeSpec FindMostSpecificSource (List<MethodSpec> list, TypeSpec sourceType, Expression source, bool apply_explicit_conv_rules)
|
||||
static TypeSpec FindMostSpecificSource (ResolveContext rc, List<MethodSpec> list, TypeSpec sourceType, Expression source, bool apply_explicit_conv_rules)
|
||||
{
|
||||
TypeSpec[] src_types_set = null;
|
||||
|
||||
@@ -937,12 +952,16 @@ namespace Mono.CSharp {
|
||||
var candidate_set = new List<TypeSpec> ();
|
||||
|
||||
foreach (TypeSpec param_type in src_types_set){
|
||||
if (ImplicitStandardConversionExists (source, param_type))
|
||||
if (ImplicitStandardConversionExists (rc, source, param_type))
|
||||
candidate_set.Add (param_type);
|
||||
}
|
||||
|
||||
if (candidate_set.Count != 0)
|
||||
if (candidate_set.Count != 0) {
|
||||
if (source.eclass == ExprClass.MethodGroup)
|
||||
return InternalType.FakeInternalType;
|
||||
|
||||
return FindMostEncompassedType (candidate_set);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
@@ -1010,7 +1029,7 @@ namespace Mono.CSharp {
|
||||
/// </summary>
|
||||
static public Expression ImplicitUserConversion (ResolveContext ec, Expression source, TypeSpec target, Location loc)
|
||||
{
|
||||
return UserDefinedConversion (ec, source, target, true, false, loc);
|
||||
return UserDefinedConversion (ec, source, target, UserConversionRestriction.ImplicitOnly, loc);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1018,10 +1037,10 @@ namespace Mono.CSharp {
|
||||
/// </summary>
|
||||
static Expression ExplicitUserConversion (ResolveContext ec, Expression source, TypeSpec target, Location loc)
|
||||
{
|
||||
return UserDefinedConversion (ec, source, target, false, false, loc);
|
||||
return UserDefinedConversion (ec, source, target, 0, loc);
|
||||
}
|
||||
|
||||
static void FindApplicableUserDefinedConversionOperators (IList<MemberSpec> operators, Expression source, TypeSpec target, bool implicitOnly, ref List<MethodSpec> candidates)
|
||||
static void FindApplicableUserDefinedConversionOperators (ResolveContext rc, IList<MemberSpec> operators, Expression source, TypeSpec target, UserConversionRestriction restr, ref List<MethodSpec> candidates)
|
||||
{
|
||||
if (source.Type.IsInterface) {
|
||||
// Neither A nor B are interface-types
|
||||
@@ -1043,14 +1062,17 @@ namespace Mono.CSharp {
|
||||
continue;
|
||||
|
||||
var t = op.Parameters.Types[0];
|
||||
if (source.Type != t && !ImplicitStandardConversionExists (source, t)) {
|
||||
if (implicitOnly)
|
||||
if (source.Type != t && !ImplicitStandardConversionExists (rc, source, t)) {
|
||||
if ((restr & UserConversionRestriction.ImplicitOnly) != 0)
|
||||
continue;
|
||||
|
||||
if (!ImplicitStandardConversionExists (new EmptyExpression (t), source.Type))
|
||||
continue;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((restr & UserConversionRestriction.NullableSourceOnly) != 0 && !t.IsNullableType)
|
||||
continue;
|
||||
|
||||
t = op.ReturnType;
|
||||
|
||||
if (t.IsInterface)
|
||||
@@ -1061,7 +1083,7 @@ namespace Mono.CSharp {
|
||||
t = Nullable.NullableInfo.GetUnderlyingType (t);
|
||||
|
||||
if (!ImplicitStandardConversionExists (new EmptyExpression (t), target)) {
|
||||
if (implicitOnly)
|
||||
if ((restr & UserConversionRestriction.ImplicitOnly) != 0)
|
||||
continue;
|
||||
|
||||
if (texpr == null)
|
||||
@@ -1082,7 +1104,7 @@ namespace Mono.CSharp {
|
||||
//
|
||||
// User-defined conversions
|
||||
//
|
||||
static Expression UserDefinedConversion (ResolveContext ec, Expression source, TypeSpec target, bool implicitOnly, bool probingOnly, Location loc)
|
||||
public static Expression UserDefinedConversion (ResolveContext rc, Expression source, TypeSpec target, UserConversionRestriction restr, Location loc)
|
||||
{
|
||||
List<MethodSpec> candidates = null;
|
||||
|
||||
@@ -1094,6 +1116,7 @@ namespace Mono.CSharp {
|
||||
TypeSpec target_type = target;
|
||||
Expression source_type_expr;
|
||||
bool nullable_source = false;
|
||||
var implicitOnly = (restr & UserConversionRestriction.ImplicitOnly) != 0;
|
||||
|
||||
if (source_type.IsNullableType) {
|
||||
// No unwrapping conversion S? -> T for non-reference types
|
||||
@@ -1119,13 +1142,13 @@ namespace Mono.CSharp {
|
||||
|
||||
var operators = MemberCache.GetUserOperator (source_type, Operator.OpType.Implicit, declared_only);
|
||||
if (operators != null) {
|
||||
FindApplicableUserDefinedConversionOperators (operators, source_type_expr, target_type, implicitOnly, ref candidates);
|
||||
FindApplicableUserDefinedConversionOperators (rc, operators, source_type_expr, target_type, restr, ref candidates);
|
||||
}
|
||||
|
||||
if (!implicitOnly) {
|
||||
operators = MemberCache.GetUserOperator (source_type, Operator.OpType.Explicit, declared_only);
|
||||
if (operators != null) {
|
||||
FindApplicableUserDefinedConversionOperators (operators, source_type_expr, target_type, false, ref candidates);
|
||||
FindApplicableUserDefinedConversionOperators (rc, operators, source_type_expr, target_type, restr, ref candidates);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1135,13 +1158,13 @@ namespace Mono.CSharp {
|
||||
|
||||
var operators = MemberCache.GetUserOperator (target_type, Operator.OpType.Implicit, declared_only);
|
||||
if (operators != null) {
|
||||
FindApplicableUserDefinedConversionOperators (operators, source_type_expr, target_type, implicitOnly, ref candidates);
|
||||
FindApplicableUserDefinedConversionOperators (rc, operators, source_type_expr, target_type, restr, ref candidates);
|
||||
}
|
||||
|
||||
if (!implicitOnly) {
|
||||
operators = MemberCache.GetUserOperator (target_type, Operator.OpType.Explicit, declared_only);
|
||||
if (operators != null) {
|
||||
FindApplicableUserDefinedConversionOperators (operators, source_type_expr, target_type, false, ref candidates);
|
||||
FindApplicableUserDefinedConversionOperators (rc, operators, source_type_expr, target_type, restr, ref candidates);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1163,7 +1186,7 @@ namespace Mono.CSharp {
|
||||
// Pass original source type to find the best match against input type and
|
||||
// not the unwrapped expression
|
||||
//
|
||||
s_x = FindMostSpecificSource (candidates, source.Type, source_type_expr, !implicitOnly);
|
||||
s_x = FindMostSpecificSource (rc, candidates, source.Type, source_type_expr, !implicitOnly);
|
||||
if (s_x == null)
|
||||
return null;
|
||||
|
||||
@@ -1183,16 +1206,18 @@ namespace Mono.CSharp {
|
||||
//
|
||||
// Unless running in probing more
|
||||
//
|
||||
if (!probingOnly) {
|
||||
MethodSpec ambig_arg = null;
|
||||
if ((restr & UserConversionRestriction.ProbingOnly) == 0) {
|
||||
MethodSpec ambig_arg = candidates [0];
|
||||
most_specific_operator = candidates [1];
|
||||
/*
|
||||
foreach (var candidate in candidates) {
|
||||
if (candidate.ReturnType == t_x)
|
||||
most_specific_operator = candidate;
|
||||
else if (candidate.Parameters.Types[0] == s_x)
|
||||
ambig_arg = candidate;
|
||||
}
|
||||
|
||||
ec.Report.Error (457, loc,
|
||||
*/
|
||||
rc.Report.Error (457, loc,
|
||||
"Ambiguous user defined operators `{0}' and `{1}' when converting from `{2}' to `{3}'",
|
||||
ambig_arg.GetSignatureForError (), most_specific_operator.GetSignatureForError (),
|
||||
source.Type.GetSignatureForError (), target.GetSignatureForError ());
|
||||
@@ -1208,21 +1233,21 @@ namespace Mono.CSharp {
|
||||
if (s_x != source_type) {
|
||||
var c = source as Constant;
|
||||
if (c != null) {
|
||||
source = c.Reduce (ec, s_x);
|
||||
source = c.Reduce (rc, s_x);
|
||||
if (source == null)
|
||||
c = null;
|
||||
}
|
||||
|
||||
if (c == null) {
|
||||
source = implicitOnly ?
|
||||
ImplicitConversionStandard (ec, source_type_expr, s_x, loc) :
|
||||
ExplicitConversionStandard (ec, source_type_expr, s_x, loc);
|
||||
ImplicitConversionStandard (rc, source_type_expr, s_x, loc) :
|
||||
ExplicitConversionStandard (rc, source_type_expr, s_x, loc);
|
||||
}
|
||||
} else {
|
||||
source = source_type_expr;
|
||||
}
|
||||
|
||||
source = new UserCast (most_specific_operator, source, loc).Resolve (ec);
|
||||
source = new UserCast (most_specific_operator, source, loc).Resolve (rc);
|
||||
|
||||
//
|
||||
// Convert result type when it's different to best operator return type
|
||||
@@ -1241,19 +1266,19 @@ namespace Mono.CSharp {
|
||||
var unwrap = Nullable.Unwrap.CreateUnwrapped (source);
|
||||
|
||||
source = implicitOnly ?
|
||||
ImplicitConversionStandard (ec, unwrap, target_type, loc) :
|
||||
ExplicitConversionStandard (ec, unwrap, target_type, loc);
|
||||
ImplicitConversionStandard (rc, unwrap, target_type, loc) :
|
||||
ExplicitConversionStandard (rc, unwrap, target_type, loc);
|
||||
|
||||
if (source == null)
|
||||
return null;
|
||||
|
||||
if (target.IsNullableType)
|
||||
source = new Nullable.LiftedConversion (source, unwrap, target).Resolve (ec);
|
||||
source = new Nullable.LiftedConversion (source, unwrap, target).Resolve (rc);
|
||||
}
|
||||
} else {
|
||||
source = implicitOnly ?
|
||||
ImplicitConversionStandard (ec, source, target_type, loc) :
|
||||
ExplicitConversionStandard (ec, source, target_type, loc);
|
||||
ImplicitConversionStandard (rc, source, target_type, loc) :
|
||||
ExplicitConversionStandard (rc, source, target_type, loc);
|
||||
|
||||
if (source == null)
|
||||
return null;
|
||||
@@ -1266,7 +1291,7 @@ namespace Mono.CSharp {
|
||||
// only non-nullable type we need to lift it manually
|
||||
//
|
||||
if (nullable_source && !s_x.IsNullableType)
|
||||
return new Nullable.LiftedConversion (source, source_type_expr, target).Resolve (ec);
|
||||
return new Nullable.LiftedConversion (source, source_type_expr, target).Resolve (rc);
|
||||
|
||||
//
|
||||
// Target is of nullable type but source type is not, wrap the result expression
|
||||
@@ -2230,6 +2255,7 @@ namespace Mono.CSharp {
|
||||
}
|
||||
|
||||
e = ExplicitUserConversion (ec, expr, target_type, loc);
|
||||
|
||||
if (e != null)
|
||||
return e;
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
f93324f30602ca2f956eff102b7674a76df37471
|
||||
2cfa7f1846374357ed745eab43bf41e85fa4e9d3
|
||||
@@ -1279,6 +1279,8 @@ namespace Mono.CSharp
|
||||
PushPosition ();
|
||||
current_token = Token.NONE;
|
||||
int next_token;
|
||||
int parens = 0;
|
||||
|
||||
switch (xtoken ()) {
|
||||
case Token.LITERAL:
|
||||
case Token.TRUE:
|
||||
@@ -1299,6 +1301,13 @@ namespace Mono.CSharp
|
||||
case Token.COLON:
|
||||
next_token = Token.INTERR_NULLABLE;
|
||||
break;
|
||||
|
||||
case Token.OPEN_PARENS:
|
||||
case Token.OPEN_PARENS_CAST:
|
||||
case Token.OPEN_PARENS_LAMBDA:
|
||||
next_token = -1;
|
||||
++parens;
|
||||
break;
|
||||
|
||||
default:
|
||||
next_token = -1;
|
||||
@@ -1317,14 +1326,19 @@ namespace Mono.CSharp
|
||||
|
||||
case Token.COLON:
|
||||
next_token = Token.INTERR;
|
||||
break;
|
||||
|
||||
break;
|
||||
|
||||
case Token.OPEN_PARENS:
|
||||
case Token.OPEN_PARENS_CAST:
|
||||
case Token.OPEN_PARENS_LAMBDA:
|
||||
++parens;
|
||||
goto default;
|
||||
|
||||
default:
|
||||
int ntoken;
|
||||
int interrs = 1;
|
||||
int colons = 0;
|
||||
int braces = 0;
|
||||
int parens = 0;
|
||||
//
|
||||
// All shorcuts failed, do it hard way
|
||||
//
|
||||
@@ -1342,9 +1356,13 @@ namespace Mono.CSharp
|
||||
--braces;
|
||||
continue;
|
||||
case Token.CLOSE_PARENS:
|
||||
if (parens > 0)
|
||||
if (parens > 0) {
|
||||
--parens;
|
||||
continue;
|
||||
continue;
|
||||
}
|
||||
|
||||
PopPosition ();
|
||||
return Token.INTERR_NULLABLE;
|
||||
}
|
||||
|
||||
if (braces != 0)
|
||||
|
||||
@@ -446,7 +446,8 @@ namespace Mono.CSharp {
|
||||
|
||||
public override bool ContainsEmitWithAwait ()
|
||||
{
|
||||
return false;
|
||||
var instance = method_group.InstanceExpression;
|
||||
return instance != null && instance.ContainsEmitWithAwait ();
|
||||
}
|
||||
|
||||
public static Arguments CreateDelegateMethodArguments (ResolveContext rc, AParametersCollection pd, TypeSpec[] types, Location loc)
|
||||
|
||||
@@ -1 +1 @@
|
||||
86c7931f13abbb6cc31055bdc6eb2339ccbce2c2
|
||||
f0a9de98b6103af652e3d63bcae44183a33246f7
|
||||
@@ -24,6 +24,11 @@ using System.Linq;
|
||||
namespace Mono.CSharp
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Experimental!
|
||||
/// </summary>
|
||||
public delegate void ValueModificationHandler (string variableName, int row, int column, object value);
|
||||
|
||||
/// <summary>
|
||||
/// Evaluator: provides an API to evaluate C# statements and
|
||||
/// expressions dynamically.
|
||||
@@ -71,6 +76,8 @@ namespace Mono.CSharp
|
||||
readonly ModuleContainer module;
|
||||
readonly ReflectionImporter importer;
|
||||
readonly CompilationSourceFile source_file;
|
||||
|
||||
int? listener_id;
|
||||
|
||||
public Evaluator (CompilerContext ctx)
|
||||
{
|
||||
@@ -291,6 +298,30 @@ namespace Mono.CSharp
|
||||
return compiled;
|
||||
}
|
||||
|
||||
static MethodInfo listener_proxy_value;
|
||||
internal void EmitValueChangedCallback (EmitContext ec, string name, TypeSpec type, Location loc)
|
||||
{
|
||||
if (listener_id == null)
|
||||
listener_id = ListenerProxy.Register (ModificationListener);
|
||||
|
||||
if (listener_proxy_value == null)
|
||||
listener_proxy_value = typeof (ListenerProxy).GetMethod ("ValueChanged");
|
||||
|
||||
#if STATIC
|
||||
throw new NotSupportedException ();
|
||||
#else
|
||||
// object value, int row, int col, string name, int listenerId
|
||||
if (type.IsStructOrEnum)
|
||||
ec.Emit (OpCodes.Box, type);
|
||||
|
||||
ec.EmitInt (loc.Row);
|
||||
ec.EmitInt (loc.Column);
|
||||
ec.Emit (OpCodes.Ldstr, name);
|
||||
ec.EmitInt (listener_id.Value);
|
||||
ec.Emit (OpCodes.Call, listener_proxy_value);
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Evaluates and expression or statement and returns any result values.
|
||||
/// </summary>
|
||||
@@ -341,6 +372,11 @@ namespace Mono.CSharp
|
||||
Console.WriteLine ("Interrupted!\n{0}", e);
|
||||
} finally {
|
||||
invoking = false;
|
||||
|
||||
if (listener_id != null) {
|
||||
ListenerProxy.Unregister (listener_id.Value);
|
||||
listener_id = null;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
@@ -448,6 +484,11 @@ namespace Mono.CSharp
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Experimental!
|
||||
/// </summary>
|
||||
public ValueModificationHandler ModificationListener { get; set; }
|
||||
|
||||
enum InputKind {
|
||||
EOF,
|
||||
StatementOrExpression,
|
||||
@@ -737,6 +778,7 @@ namespace Mono.CSharp
|
||||
}
|
||||
|
||||
module.EmitContainer ();
|
||||
|
||||
if (Report.Errors != 0){
|
||||
if (undo != null)
|
||||
undo.ExecuteUndo ();
|
||||
@@ -1257,5 +1299,38 @@ namespace Mono.CSharp
|
||||
undo_actions = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static class ListenerProxy
|
||||
{
|
||||
static readonly Dictionary<int, ValueModificationHandler> listeners = new Dictionary<int, ValueModificationHandler> ();
|
||||
|
||||
static int counter;
|
||||
|
||||
public static int Register (ValueModificationHandler listener)
|
||||
{
|
||||
lock (listeners) {
|
||||
var id = counter++;
|
||||
listeners.Add (id, listener);
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
public static void Unregister (int listenerId)
|
||||
{
|
||||
lock (listeners) {
|
||||
listeners.Remove (listenerId);
|
||||
}
|
||||
}
|
||||
|
||||
public static void ValueChanged (object value, int row, int col, string name, int listenerId)
|
||||
{
|
||||
ValueModificationHandler action;
|
||||
lock (listeners) {
|
||||
if (!listeners.TryGetValue (listenerId, out action))
|
||||
return;
|
||||
}
|
||||
|
||||
action (name, row, col, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
6976b97c8b1c65f12280680fe68c3ab7bb7c30e6
|
||||
0ab48acb382e4c47a8494814726d8a2c6ce99dff
|
||||
@@ -139,15 +139,22 @@ namespace Mono.CSharp
|
||||
var field = struct_info.Fields[i];
|
||||
|
||||
if (!fc.IsStructFieldDefinitelyAssigned (vi, field.Name)) {
|
||||
if (field.MemberDefinition is Property.BackingField) {
|
||||
var bf = field.MemberDefinition as Property.BackingField;
|
||||
if (bf != null) {
|
||||
if (bf.Initializer != null)
|
||||
continue;
|
||||
|
||||
fc.Report.Error (843, loc,
|
||||
"An automatically implemented property `{0}' must be fully assigned before control leaves the constructor. Consider calling the default struct contructor from a constructor initializer",
|
||||
field.GetSignatureForError ());
|
||||
} else {
|
||||
fc.Report.Error (171, loc,
|
||||
"Field `{0}' must be fully assigned before control leaves the constructor",
|
||||
field.GetSignatureForError ());
|
||||
|
||||
ok = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
fc.Report.Error (171, loc,
|
||||
"Field `{0}' must be fully assigned before control leaves the constructor",
|
||||
field.GetSignatureForError ());
|
||||
ok = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -620,6 +620,11 @@ namespace Mono.CSharp {
|
||||
spec.SetMetaInfo (type);
|
||||
}
|
||||
|
||||
public void Define (TypeParameter tp)
|
||||
{
|
||||
builder = tp.builder;
|
||||
}
|
||||
|
||||
public void EmitConstraints (GenericTypeParameterBuilder builder)
|
||||
{
|
||||
var attr = GenericParameterAttributes.None;
|
||||
@@ -1047,7 +1052,8 @@ namespace Mono.CSharp {
|
||||
continue;
|
||||
}
|
||||
|
||||
types [i] = ((TypeParameterSpec)t).GetEffectiveBase ();
|
||||
var tps = t as TypeParameterSpec;
|
||||
types [i] = tps != null ? tps.GetEffectiveBase () : t;
|
||||
}
|
||||
|
||||
if (HasTypeConstraint)
|
||||
@@ -1349,7 +1355,15 @@ namespace Mono.CSharp {
|
||||
|
||||
if (TypeArguments != null) {
|
||||
foreach (var t in TypeArguments) {
|
||||
if (((TypeParameterSpec) t).IsConvertibleToInterface (iface))
|
||||
var tps = t as TypeParameterSpec;
|
||||
if (tps != null) {
|
||||
if (tps.IsConvertibleToInterface (iface))
|
||||
return true;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (t.ImplementsInterface (iface, false))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1465,6 +1479,9 @@ namespace Mono.CSharp {
|
||||
if (ac != null)
|
||||
return ArrayContainer.MakeType (context.Module, et, ac.Rank);
|
||||
|
||||
if (ec is PointerContainer)
|
||||
return PointerContainer.MakeType (context.Module, et);
|
||||
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user