if (probe_type == null)
return null;
+ CheckObsoleteAttribute (probe_type);
+
expr = expr.Resolve (ec);
if (expr == null)
return null;
if (type == null)
return null;
+ CheckObsoleteAttribute (type);
+
eclass = ExprClass.Value;
if (expr is Constant){
return e;
}
+ if (type.IsPointer && !ec.InUnsafe) {
+ UnsafeError (loc);
+ return null;
+ }
expr = Convert.ExplicitConversion (ec, expr, type, loc);
return expr;
}
} else if (right is LongConstant){
long ll = ((LongConstant) right).Value;
- if (ll > 0)
+ if (ll >= 0)
right = new ULongConstant ((ulong) ll);
} else {
e = Convert.ImplicitNumericConversion (ec, right, l, loc);
oper == Operator.BitwiseOr ||
oper == Operator.ExclusiveOr){
if (l == r){
- if (!((l == TypeManager.int32_type) ||
- (l == TypeManager.uint32_type) ||
- (l == TypeManager.short_type) ||
- (l == TypeManager.ushort_type) ||
- (l == TypeManager.int64_type) ||
- (l == TypeManager.uint64_type))){
+ if (((l == TypeManager.int32_type) ||
+ (l == TypeManager.uint32_type) ||
+ (l == TypeManager.short_type) ||
+ (l == TypeManager.ushort_type) ||
+ (l == TypeManager.int64_type) ||
+ (l == TypeManager.uint64_type))){
type = l;
+ } else {
+ Error_OperatorCannotBeApplied ();
+ return null;
}
} else {
Error_OperatorCannotBeApplied ();
return null;
}
+ CheckObsoleteAttribute (e.Type);
+
if (local_info.LocalBuilder == null)
return ec.RemapLocalLValue (local_info, right_side);
//
// false is normal form, true is expanded form
//
- Hashtable candidate_to_form = new PtrHashtable ();
+ Hashtable candidate_to_form = null;
//
candidates.Add (candidate);
applicable_type = candidate.DeclaringType;
found_applicable = true;
- candidate_to_form [candidate] = false;
} else if (IsParamsMethodApplicable (ec, Arguments, candidate)) {
- // Candidate is applicable in expanded form
- candidates.Add (candidate);
- applicable_type = candidate.DeclaringType;
- found_applicable = true;
- candidate_to_form [candidate] = true;
- }
- }
+ if (candidate_to_form == null)
+ candidate_to_form = new PtrHashtable ();
+
+ // Candidate is applicable in expanded form
+ candidates.Add (candidate);
+ applicable_type = candidate.DeclaringType;
+ found_applicable = true;
+ candidate_to_form [candidate] = candidate;
+ }
+ }
//
for (int ix = 0; ix < candidate_top; ix++){
MethodBase candidate = (MethodBase) candidates [ix];
- bool cand_params = (bool) candidate_to_form [candidate];
+ bool cand_params = candidate_to_form != null && candidate_to_form.Contains (candidate);
bool method_params = false;
if (method != null)
- method_params = (bool) candidate_to_form [method];
+ method_params = candidate_to_form != null && candidate_to_form.Contains (method);
int x = BetterFunction (ec, Arguments,
candidate, cand_params,
// Now check that there are no ambiguities i.e the selected method
// should be better than all the others
//
- bool best_params = (bool) candidate_to_form [method];
+ bool best_params = candidate_to_form != null && candidate_to_form.Contains (method);
for (int ix = 0; ix < candidate_top; ix++){
MethodBase candidate = (MethodBase) candidates [ix];
// IsApplicable (ec, Arguments, method)))
// continue;
- bool cand_params = (bool) candidate_to_form [candidate];
+ bool cand_params = candidate_to_form != null && candidate_to_form.Contains (candidate);
int x = BetterFunction (ec, Arguments,
method, best_params,
candidate, cand_params,
"Could not find any applicable function for this argument list");
return null;
}
-
+
MethodInfo mi = method as MethodInfo;
if (mi != null) {
type = TypeManager.TypeToCoreType (mi.ReturnType);
- if (!mi.IsStatic && !mg.IsExplicitImpl && (mg.InstanceExpression == null))
+ if (!mi.IsStatic && !mg.IsExplicitImpl && (mg.InstanceExpression == null)) {
SimpleName.Error_ObjectRefRequired (ec, loc, mi.Name);
+ return null;
+ }
+
+ Expression iexpr = mg.InstanceExpression;
+ if (mi.IsStatic && (iexpr != null) && !(iexpr is This)) {
+ if (mg.IdenticalTypeName)
+ mg.InstanceExpression = null;
+ else {
+ MemberAccess.error176 (loc, mi.Name);
+ return null;
+ }
+ }
}
if (type.IsPointer){
}
}
+ /// <summary>
+ /// This checks the ConditionalAttribute on the method
+ /// </summary>
+ static bool IsMethodExcluded (MethodBase method, EmitContext ec)
+ {
+ if (method.IsConstructor)
+ return false;
+
+ IMethodData md = TypeManager.GetMethod (method);
+ if (md != null)
+ return md.IsExcluded (ec);
+
+ // For some methods (generated by delegate class) GetMethod returns null
+ // because they are not included in builder_to_method table
+ if (method.DeclaringType is TypeBuilder)
+ return false;
+
+ return AttributeTester.IsConditionalMethodExcluded (method);
+ }
+
/// <remarks>
/// is_base tells whether we want to force the use of the `call'
/// opcode instead of using callvirt. Call is required to call
}
//
- // This checks the `ConditionalAttribute' on the method, and the
- // ObsoleteAttribute
+ // This checks ObsoleteAttribute on the method and on the declaring type
//
- TypeManager.MethodFlags flags = TypeManager.GetMethodFlags (method, loc);
- if ((flags & TypeManager.MethodFlags.IsObsoleteError) != 0)
- return;
- if ((flags & TypeManager.MethodFlags.ShouldIgnore) != 0)
- return;
+ ObsoleteAttribute oa = AttributeTester.GetMethodObsoleteAttribute (method);
+ if (oa != null)
+ AttributeTester.Report_ObsoleteMessage (oa, TypeManager.CSharpSignature (method), loc);
+
+
+ oa = AttributeTester.GetObsoleteAttribute (method.DeclaringType);
+ if (oa != null) {
+ AttributeTester.Report_ObsoleteMessage (oa, method.DeclaringType.FullName, loc);
+ }
+
+ if (IsMethodExcluded (method, ec))
+ return;
if (!is_static){
if (decl_type.IsValueType)
if (type == null)
return null;
+ CheckObsoleteAttribute (type);
+
bool IsDelegate = TypeManager.IsDelegateType (type);
if (IsDelegate){
return this;
Expression ml;
- ml = MemberLookupFinal (ec, null, type, ".ctor",
+ // For member-lookup, treat 'new Foo (bar)' as call to 'foo.ctor (bar)', where 'foo' is of type 'Foo'.
+ ml = MemberLookupFinal (ec, type, type, ".ctor",
MemberTypes.Constructor,
AllBindingFlags | BindingFlags.DeclaredOnly, loc);
/// initialization data and the other which does not need dimensions
/// specified but where initialization data is mandatory.
/// </remarks>
- public class ArrayCreation : ExpressionStatement {
+ public class ArrayCreation : Expression {
Expression requested_base_type;
ArrayList initializers;
//
// Emits the initializers for the array
//
- void EmitStaticInitializers (EmitContext ec, bool is_expression)
+ void EmitStaticInitializers (EmitContext ec)
{
//
// First, the static data
fb = RootContext.MakeStaticData (data);
- if (is_expression)
- ig.Emit (OpCodes.Dup);
+ ig.Emit (OpCodes.Dup);
ig.Emit (OpCodes.Ldtoken, fb);
ig.Emit (OpCodes.Call,
TypeManager.void_initializearray_array_fieldhandle);
//
// This always expect the top value on the stack to be the array
//
- void EmitDynamicInitializers (EmitContext ec, bool is_expression)
+ void EmitDynamicInitializers (EmitContext ec)
{
ILGenerator ig = ec.ig;
int dims = bounds.Count;
num_automatic_initializers <= max_automatic_initializers) {
Type etype = e.Type;
- if (is_expression || i != top - 1)
- ig.Emit (OpCodes.Dup);
+ ig.Emit (OpCodes.Dup);
for (int idx = 0; idx < dims; idx++)
IntConstant.EmitInt (ig, current_pos [idx]);
}
}
- void DoEmit (EmitContext ec, bool is_statement)
+ public override void Emit (EmitContext ec)
{
ILGenerator ig = ec.ig;
// initialized. num_automatic_initializers will always be zero. See
// CheckIndices.
if (num_automatic_initializers > max_automatic_initializers)
- EmitStaticInitializers (ec, dynamic_initializers || !is_statement);
+ EmitStaticInitializers (ec);
if (dynamic_initializers)
- EmitDynamicInitializers (ec, !is_statement);
+ EmitDynamicInitializers (ec);
}
}
-
- public override void Emit (EmitContext ec)
- {
- DoEmit (ec, false);
- }
-
- public override void EmitStatement (EmitContext ec)
- {
- DoEmit (ec, true);
- }
public object EncodeAsAttribute ()
{
return null;
}
+ CheckObsoleteAttribute (typearg);
+
type = TypeManager.type_type;
eclass = ExprClass.Type;
return this;
if (type_queried == null)
return null;
+ CheckObsoleteAttribute (type_queried);
+
if (!TypeManager.IsUnmanagedType (type_queried)){
Report.Error (208, loc, "Cannot take the size of an unmanaged type (" + TypeManager.CSharpName (type_queried) + ")");
return null;
}
}
- static void error176 (Location loc, string name)
+ public static void error176 (Location loc, string name)
{
Report.Error (176, loc, "Static member `" +
name + "' cannot be accessed " +
"type name instead");
}
- static bool IdenticalNameAndTypeName (EmitContext ec, Expression left_original, Location loc)
+ static bool IdenticalNameAndTypeName (EmitContext ec, Expression left_original, Expression left, Location loc)
{
- if (left_original == null)
+ SimpleName sn = left_original as SimpleName;
+ if (sn == null || left == null || left.Type.Name != sn.Name)
return false;
- if (!(left_original is SimpleName))
- return false;
-
- SimpleName sn = (SimpleName) left_original;
-
- Type t = RootContext.LookupType (ec.DeclSpace, sn.Name, true, loc);
- if (t != null)
- return true;
-
- return false;
+ return RootContext.LookupType (ec.DeclSpace, sn.Name, true, loc) != null;
}
public static Expression ResolveMemberAccess (EmitContext ec, Expression member_lookup,
if (decl_type.IsSubclassOf (TypeManager.enum_type)) {
if (left_is_explicit && !left_is_type &&
- !IdenticalNameAndTypeName (ec, left_original, loc)) {
+ !IdenticalNameAndTypeName (ec, left_original, member_lookup, loc)) {
error176 (loc, fe.FieldInfo.Name);
return null;
}
// accessors and private field etc so there's no need
// to transform ourselves.
//
+ ee.InstanceExpression = left;
return ee;
}
if (!left_is_explicit)
left = null;
-
+
+ ee.InstanceExpression = left;
+
return ResolveMemberAccess (ec, ml, left, loc, left_original);
}
}
if (member_lookup is IMemberExpr) {
IMemberExpr me = (IMemberExpr) member_lookup;
+ MethodGroupExpr mg = me as MethodGroupExpr;
if (left_is_type){
- MethodGroupExpr mg = me as MethodGroupExpr;
if ((mg != null) && left_is_explicit && left.Type.IsInterface)
mg.IsExplicitImpl = left_is_explicit;
if (!me.IsStatic){
if ((ec.IsFieldInitializer || ec.IsStatic) &&
- IdenticalNameAndTypeName (ec, left_original, loc))
+ IdenticalNameAndTypeName (ec, left_original, member_lookup, loc))
return member_lookup;
-
+
SimpleName.Error_ObjectRefRequired (ec, loc, me.Name);
return null;
}
} else {
- if (!me.IsInstance){
- if (IdenticalNameAndTypeName (ec, left_original, loc))
+ if (!me.IsInstance) {
+ if (IdenticalNameAndTypeName (ec, left_original, left, loc))
return member_lookup;
if (left_is_explicit) {
error176 (loc, me.Name);
return null;
}
- }
+ }
//
// Since we can not check for instance objects in SimpleName,
}
}
+ if ((mg != null) && IdenticalNameAndTypeName (ec, left_original, left, loc))
+ mg.IdenticalTypeName = true;
+
me.InstanceExpression = left;
}
Type expr_type = expr.Type;
if (expr is TypeExpr){
if (!ec.DeclSpace.CheckAccessLevel (expr_type)){
- Error (122, "`" + expr_type + "' " +
- "is inaccessible because of its protection level");
+ Report.Error_T (122, loc, expr_type);
return null;
}
object value = en.LookupEnumValue (ec, Identifier, loc);
if (value != null){
+ ObsoleteAttribute oa = en.GetObsoleteAttribute (ec, Identifier);
+ if (oa != null) {
+ AttributeTester.Report_ObsoleteMessage (oa, en.GetSignatureForError (), Location);
+ }
+
Constant c = Constantify (value, en.UnderlyingType);
return new EnumConstant (c, expr_type);
}
+ } else {
+ CheckObsoleteAttribute (expr_type);
+
+ FieldInfo fi = expr_type.GetField (Identifier);
+ if (fi != null) {
+ ObsoleteAttribute oa = AttributeTester.GetMemberObsoleteAttribute (fi);
+ if (oa != null)
+ AttributeTester.Report_ObsoleteMessage (oa, TypeManager.GetFullNameSignature (fi), Location);
+ }
}
}
}
MemberInfo [] mi = TypeManager.MemberLookup (
caller_type, caller_type, lookup_type, MemberTypes.Property,
BindingFlags.Public | BindingFlags.Instance |
- BindingFlags.DeclaredOnly, p_name);
+ BindingFlags.DeclaredOnly, p_name, null);
if (mi == null || mi.Length == 0)
return null;