public AdditionResult AddClass (Class c)
{
AdditionResult res;
-
+
if ((res = IsValid (c.Basename)) != AdditionResult.Success)
return res;
-
+
+
+
DefineName (c.Name, c);
types.Add (c);
-
+
+ // FIXME: Do we really need to explicitly add an empty default static constructor?
+ // Apparently we don't
+/* if (c.default_static_constructor == null)
+ {
+ bool isModule = c is Mono.MonoBASIC.Module;
+ Constructor dc = new Constructor ("New", Parameters.EmptyReadOnlyParameters, null, c.Location);
+ dc.ModFlags = isModule ? Modifiers.PUBLIC | Modifiers.STATIC : Modifiers.PUBLIC;
+ c.AddConstructor (dc);
+ }
+*/
+ // --------------------------------------------------------------
+
return AdditionResult.Success;
}
fields.Add (field);
- if (field.HasInitializer){
- if ((field.ModFlags & Modifiers.STATIC) != 0){
+ if (field.HasInitializer){
+ if ((field.ModFlags & Modifiers.STATIC) != 0) {
if (initialized_static_fields == null)
initialized_static_fields = new ArrayList ();
Modifiers.ABSTRACT |
Modifiers.SEALED |
Modifiers.UNSAFE;
-
+
public Class (TypeContainer parent, string name, int mod, Attributes attrs, Location l)
: base (parent, name, l)
{
public Method (Expression return_type, int mod, string name, Parameters parameters,
Attributes attrs, Location l)
: base (return_type, mod, AllowedModifiers, name, attrs, parameters, l)
- { }
+ {
+ Implements = null;
+ }
+
+ public Method (Expression return_type, int mod, string name, Parameters parameters,
+ Attributes attrs, Expression impl_what, Location l)
+ : base (return_type, mod, AllowedModifiers, name, attrs, parameters, l)
+ {
+ Implements = impl_what;
+ }
//
// Returns the `System.Type' for the ReturnType of this
if (Name == "Main" &&
((ModFlags & Modifiers.STATIC) != 0) &&
(RootContext.MainClass == null ||
- RootContext.MainClass == parent.TypeBuilder.FullName)){
+ RootContext.MainClass == parent.TypeBuilder.FullName ||
+ (RootContext.RootNamespace != null &&
+ RootContext.RootNamespace.Length > 0 &&
+ (RootContext.RootNamespace + "." + RootContext.MainClass) == parent.TypeBuilder.FullName))) {
if (IsEntryPoint (MethodBuilder, ParameterInfo)) {
if (RootContext.EntryPoint == null) {
RootContext.EntryPoint = MethodBuilder;
loc);
if (parent_constructor_group == null){
- Report.Error (1501, loc,
- "Can not find a constructor for this argument list");
+ string s = String.Format ("'{0}': Can not find a constructor for this argument list", t);
+ Report.Error (1501, loc, s);
return false;
}
-
+
parent_constructor = (ConstructorInfo) Invocation.OverloadResolve (ec,
(MethodGroupExpr) parent_constructor_group, argument_list, loc);
if (parent_constructor == null){
- Report.Error (1501, loc,
- "Can not find a constructor for this argument list");
+ string s = String.Format ("'{0}': Can not find a constructor for this argument list", t);
+ Report.Error (1501, loc, s);
return false;
}
abstract public class MemberBase : MemberCore {
public Expression Type;
public readonly Attributes OptAttributes;
+ public Expression Implements;
protected MethodAttributes flags;
return true;
}
- public void Emit (TypeContainer tc)
+ public virtual void Emit (TypeContainer tc)
{
//
// The PropertyBuilder can be null for explicit implementations, in that
Attributes attrs, Location loc, string set_name,
Parameters p_get, Parameters p_set)
: base (type, name, mod_flags, AllowedModifiers,
- p_set, // FIXME ???????????
+ p_set,
get_block, set_block, attrs, loc)
{
set_parameter_name = set_name;
get_params = p_get;
set_params = p_set;
+ Implements = null;
}
+
+ public Property (Expression type, string name, int mod_flags,
+ Accessor get_block, Accessor set_block,
+ Attributes attrs, Location loc, string set_name,
+ Parameters p_get, Parameters p_set, Expression impl_what)
+ : base (type, name, mod_flags, AllowedModifiers,
+ p_set,
+ get_block, set_block, attrs, loc)
+ {
+ set_parameter_name = set_name;
+ get_params = p_get;
+ set_params = p_set;
+ Implements = impl_what;
+ }
public Property (Expression type, string name, int mod_flags,
Accessor get_block, Accessor set_block,
return true;
}
- public void Emit (TypeContainer tc)
+ public override void Emit (TypeContainer tc)
{
base.Emit (tc);
- if (GetData != null) \r
+ if (GetData != null)
{
Parameters = get_params;
GetData.Emit (tc, Get.Block, Get);
}
- if (SetData != null) \r
+ if (SetData != null)
{
Parameters = set_params;
SetData.Emit (tc, Set.Block, Set);
/// </summary>
public static MemberFilter method_signature_filter;
+ /// <summary>
+ /// This delegate is used to extract methods which have the
+ /// same signature as the argument except for the name
+ /// </summary>
+ public static MemberFilter method_signature_noname_filter;
+
/// <summary>
/// This delegate is used to extract inheritable methods which
/// have the same signature as the argument. By inheritable,
static MethodSignature ()
{
method_signature_filter = new MemberFilter (MemberSignatureCompare);
+ method_signature_noname_filter = new MemberFilter (MemberSignatureCompareNoName);
inheritable_method_signature_filter = new MemberFilter (
InheritableMemberSignatureCompare);
inheritable_property_signature_filter = new MemberFilter (
return true;
}
+ static bool MemberSignatureCompareNoName (MemberInfo m, object filter_criteria)
+ {
+ return MemberSignatureCompare (m, filter_criteria, false);
+ }
+
static bool MemberSignatureCompare (MemberInfo m, object filter_criteria)
+ {
+ return MemberSignatureCompare (m, filter_criteria, true);
+ }
+
+ static bool MemberSignatureCompare (MemberInfo m, object filter_criteria, bool use_name)
{
MethodSignature sig = (MethodSignature) filter_criteria;
- if (m.Name != sig.Name)
+ if (use_name && (m.Name != sig.Name))
return false;
Type ReturnType;