2005-02-11 Miguel de Icaza <miguel@novell.com>
+ * codegen.cs (EmitContext): Introduce the `MethodIsStatic'
+ variable. This one is represents the actual low-level declaration
+ of the method, as opposed to the semantic level `IsStatic'.
+
+ An anonymous method which is hosted into a static method might be
+ actually an instance method. IsStatic would reflect the
+ container, while MethodIsStatic represents the actual code
+ generated.
+
+ * expression.cs (ParameterReference): Use the new MethodIsStatic
+ instead of IsStatic.
+
* anonymous.cs (AnonymousMethod.Compatible): Pass the
Modifiers.STATIC to the Anonymous' Method EmitContext if static is
set on the current EmitContext.
throw new Exception ("Type host is null");
if (current_type == type_host && ec.IsStatic){
- if (ec.IsStatic)
+ if (ec.IsStatic){
method_modifiers |= Modifiers.STATIC;
+ }
current_type = null;
}
method_modifiers, false, new MemberName ("<#AnonymousMethod>" + anonymous_method_count++),
Parameters, null, loc);
method.Block = Block;
-
//
// Swap the TypeBuilder while we define the method, then restore
// Adjust based on the computed state of the
// method from CreateMethodHost
- if ((method_modifiers & Modifiers.STATIC) != 0)
- aec.IsStatic = true;
+ aec.MethodIsStatic = (method_modifiers & Modifiers.STATIC) != 0;
aec.EmitMeta (Block, amp);
aec.EmitResolvedTopBlock (Block, unreachable);
/// </summary>
public bool IsStatic;
+ /// <summary>
+ /// Whether the actual created method is static or instance method.
+ /// Althoug the method might be declared as `static', if an anonymous
+ /// method is involved, we might turn this into an instance method.
+ ///
+ /// So this reflects the low-level staticness of the method, while
+ /// IsStatic represents the semantic, high-level staticness.
+ /// </summary>
+ public bool MethodIsStatic;
+
/// <summary>
/// Whether we are emitting a field initializer
/// </summary>
}
Phase current_phase;
-
FlowBranching current_flow_branching;
-
+
public EmitContext (DeclSpace parent, DeclSpace ds, Location l, ILGenerator ig,
Type return_type, int code_flags, bool is_constructor)
{
ConstantCheckState = true;
IsStatic = (code_flags & Modifiers.STATIC) != 0;
+ MethodIsStatic = IsStatic;
InIterator = (code_flags & Modifiers.METHOD_YIELDS) != 0;
RemapToProxy = InIterator;
ReturnType = return_type;
ILGenerator ig = ec.ig;
int arg_idx = idx;
- if (!ec.IsStatic)
+ Console.WriteLine ("Loading: " + ec.MethodIsStatic);
+ if (!ec.MethodIsStatic)
arg_idx++;
+
EmitLdArg (ig, arg_idx);
ILGenerator ig = ec.ig;
int arg_idx = idx;
- if (!ec.IsStatic)
+ Console.WriteLine ("Loading: {0} at {1}", ec.MethodIsStatic, ec.id);
+ if (!ec.MethodIsStatic)
arg_idx++;
EmitLdArg (ig, arg_idx);
prepared = prepare_for_load;
- if (!ec.IsStatic)
+ if (!ec.MethodIsStatic)
arg_idx++;
if (is_ref && !prepared)
int arg_idx = idx;
- if (!ec.IsStatic)
+ if (!ec.MethodIsStatic)
arg_idx++;
if (is_ref){