break;
case ExprClass.MethodGroup:
+ if (!RootContext.V2){
if ((flags & ResolveFlags.MethodGroup) == 0) {
((MethodGroupExpr) e).ReportUsageError ();
return null;
}
+ }
break;
case ExprClass.Value:
/// </remarks>
public abstract void Emit (EmitContext ec);
+ public virtual void EmitBranchable (EmitContext ec, Label target, bool onTrue)
+ {
+ Emit (ec);
+ ec.ig.Emit (onTrue ? OpCodes.Brtrue : OpCodes.Brfalse, target);
+ }
+
/// <summary>
/// Protected constructor. Only derivate types should
/// be able to be created
Report.Error (
122, loc, "`" + TypeManager.CSharpName (qualifier_type) + "." +
name + "' is inaccessible due to its protection level");
- else
+ else if (name == ".ctor") {
+ Report.Error (143, loc, String.Format ("The type {0} has no constructors defined",
+ TypeManager.CSharpName (queried_type)));
+ } else {
Report.Error (
122, loc, "`" + name + "' is inaccessible due to its " +
"protection level");
}
+ }
static public MemberInfo GetFieldFromEvent (EventExpr event_expr)
{
"a `" + sb.ToString () + "' was expected");
}
- static void Error_ConstantValueCannotBeConverted (Location l, string val, Type t)
+ static public void Error_ConstantValueCannotBeConverted (Location l, string val, Type t)
{
Report.Error (31, l, "Constant value `" + val + "' cannot be converted to " +
TypeManager.CSharpName (t));
public class EmptyCast : Expression {
protected Expression child;
+ public Expression Child {
+ get {
+ return child;
+ }
+ }
+
public EmptyCast (Expression child, Type return_type)
{
eclass = child.eclass;
alias_value = null;
if (ec.ResolvingTypeTree){
- if (alias_value != null){
- if ((t = RootContext.LookupType (ds, alias_value, true, loc)) != null)
- return new TypeExpression (t, loc);
- }
-
int errors = Report.Errors;
- Type dt = ec.DeclSpace.FindType (loc, Name);
+ Type dt = ds.FindType (loc, Name);
if (Report.Errors != errors)
return null;
if (dt != null)
return new TypeExpression (dt, loc);
+
+ if (alias_value != null){
+ if ((t = RootContext.LookupType (ds, alias_value, true, loc)) != null)
+ return new TypeExpression (t, loc);
+ }
}
//
return new SimpleName (alias_value, loc);
}
- if (ec.IsGeneric){
- TypeParameterExpr generic_type = ds.LookupGeneric (Name, loc);
-
- if (generic_type != null)
- return generic_type.ResolveAsTypeTerminal (ec);
- }
+ TypeParameterExpr generic_type = ds.LookupGeneric (Name, loc);
+ if (generic_type != null)
+ return generic_type.ResolveAsTypeTerminal (ec);
//
// Stage 2: Lookup up if we are an alias to a type
FieldBase fb = TypeManager.GetField (FieldInfo);
if (fb != null)
- fb.IsAssigned = true;
+ fb.SetAssigned ();
//
// InitOnly fields can only be assigned in constructors
// Handle initonly fields specially: make a copy and then
// get the address of the copy.
//
- if (FieldInfo.IsInitOnly && !ec.IsConstructor){
+ bool need_copy;
+ if (FieldInfo.IsInitOnly){
+ need_copy = true;
+ if (ec.IsConstructor){
+ if (FieldInfo.IsStatic){
+ if (ec.IsStatic)
+ need_copy = false;
+ } else
+ need_copy = false;
+ }
+ } else
+ need_copy = false;
+
+ if (need_copy){
LocalBuilder local;
-
Emit (ec);
local = ig.DeclareLocal (type);
ig.Emit (OpCodes.Stloc, local);
return;
}
- if (FieldInfo.IsStatic)
+
+ if (FieldInfo.IsStatic){
ig.Emit (OpCodes.Ldsflda, FieldInfo);
- else {
+ } else {
//
// In the case of `This', we call the AddressOf method, which will
// only load the pointer, and not perform an Ldobj immediately after