/// </remarks>
PendingImplementation pending;
- public TypeContainer (NamespaceEntry ns, TypeContainer parent, MemberName name,
+ public TypeContainer (NamespaceEntry ns, DeclSpace parent, MemberName name,
Attributes attrs, Kind kind)
: base (ns, parent, name, attrs)
{
public abstract class ClassOrStruct : TypeContainer {
ListDictionary declarative_security;
- public ClassOrStruct (NamespaceEntry ns, TypeContainer parent,
+ public ClassOrStruct (NamespaceEntry ns, DeclSpace parent,
MemberName name, Attributes attrs, Kind kind)
: base (ns, parent, name, attrs, kind)
{
Modifiers.STATIC |
Modifiers.UNSAFE;
- public Class (NamespaceEntry ns, TypeContainer parent, MemberName name, int mod,
+ public Class (NamespaceEntry ns, DeclSpace parent, MemberName name, int mod,
Attributes attrs)
: base (ns, parent, name, attrs, Kind.Class)
{
Modifiers.UNSAFE |
Modifiers.PRIVATE;
- public Struct (NamespaceEntry ns, TypeContainer parent, MemberName name,
+ public Struct (NamespaceEntry ns, DeclSpace parent, MemberName name,
int mod, Attributes attrs)
: base (ns, parent, name, attrs, Kind.Struct)
{
Modifiers.UNSAFE |
Modifiers.PRIVATE;
- public Interface (NamespaceEntry ns, TypeContainer parent, MemberName name, int mod,
+ public Interface (NamespaceEntry ns, DeclSpace parent, MemberName name, int mod,
Attributes attrs)
: base (ns, parent, name, attrs, Kind.Interface)
{
static string[] attribute_targets = new string [] { "method", "return" };
- public MethodCore (TypeContainer parent, GenericMethod generic,
+ public MethodCore (DeclSpace parent, GenericMethod generic,
Expression type, int mod, int allowed_mod, bool is_iface,
MemberName name, Attributes attrs, Parameters parameters)
: base (parent, generic, type, mod, allowed_mod, Modifiers.PRIVATE,
return true;
// Is null for System.Object while compiling corlib and base interfaces
- if (Parent.BaseCache == null) {
+ if (ParentContainer.BaseCache == null) {
if ((RootContext.WarningLevel >= 4) && ((ModFlags & Modifiers.NEW) != 0)) {
Report.Warning (109, 4, Location, "The member `{0}' does not hide an inherited member. The new keyword is not required", GetSignatureForError ());
}
}
if (Name == "Equals" && Parameters.Count == 1 && ParameterTypes [0] == TypeManager.object_type)
- Parent.Mark_HasEquals ();
+ ParentContainer.Mark_HasEquals ();
else if (Name == "GetHashCode" && Parameters.Empty)
- Parent.Mark_HasGetHashCode ();
+ ParentContainer.Mark_HasGetHashCode ();
if ((ModFlags & Modifiers.OVERRIDE) != 0) {
ObsoleteAttribute oa = AttributeTester.GetMethodObsoleteAttribute (base_method);
return true;
}
- MemberInfo conflict_symbol = Parent.FindBaseMemberWithSameName (Name, !(this is Property));
+ MemberInfo conflict_symbol = ParentContainer.FindBaseMemberWithSameName (Name, !(this is Property));
if ((ModFlags & Modifiers.OVERRIDE) != 0) {
if (conflict_symbol != null) {
Report.SymbolRelatedToPreviousError (conflict_symbol);
public bool CheckAbstractAndExtern (bool has_block)
{
- if (Parent.Kind == Kind.Interface)
+ if (ParentContainer.Kind == Kind.Interface)
return true;
if (has_block) {
public class SourceMethod : ISourceMethod
{
- TypeContainer container;
+ DeclSpace parent;
MethodBase builder;
- protected SourceMethod (TypeContainer container, MethodBase builder,
+ protected SourceMethod (DeclSpace parent, MethodBase builder,
ISourceFile file, Location start, Location end)
{
- this.container = container;
+ this.parent = parent;
this.builder = builder;
- CodeGen.SymbolWriter.OpenMethod (
- file, this, start.Row, start.Column, end.Row, start.Column);
+ CodeGen.SymbolWriter.OpenMethod (file, this, start.Row, start.Column, end.Row, start.Column);
}
public string Name {
}
public int NamespaceID {
- get { return container.NamespaceEntry.SymbolFileID; }
+ get { return parent.NamespaceEntry.SymbolFileID; }
}
public int Token {
CodeGen.SymbolWriter.CloseMethod ();
}
- public static SourceMethod Create (TypeContainer parent,
- MethodBase builder, Block block)
+ public static SourceMethod Create (DeclSpace parent, MethodBase builder, Block block)
{
if (CodeGen.SymbolWriter == null)
return null;
//
// return_type can be "null" for VOID values.
//
- public Method (TypeContainer parent, GenericMethod generic,
+ public Method (DeclSpace parent, GenericMethod generic,
Expression return_type, int mod, bool is_iface,
MemberName name, Parameters parameters, Attributes attrs)
: base (parent, generic, return_type, mod,
protected override bool CheckForDuplications ()
{
- ArrayList ar = Parent.Methods;
- if (ar != null) {
+ ArrayList ar = ParentContainer.Methods;
+ if (ar != null) {
int arLen = ar.Count;
for (int i = 0; i < arLen; i++) {
}
}
- ar = Parent.Properties;
+ ar = ParentContainer.Properties;
if (ar != null) {
for (int i = 0; i < ar.Count; ++i) {
PropertyBase pb = (PropertyBase) ar [i];
}
}
- ar = Parent.Indexers;
+ ar = ParentContainer.Indexers;
if (ar != null) {
for (int i = 0; i < ar.Count; ++i) {
PropertyBase pb = (PropertyBase) ar [i];
}
}
- ar = Parent.Events;
+ ar = ParentContainer.Events;
if (ar != null) {
for (int i = 0; i < ar.Count; ++i) {
Event ev = (Event) ar [i];
protected override MethodInfo FindOutBaseMethod (ref Type base_ret_type)
{
- MethodInfo mi = (MethodInfo) Parent.BaseCache.FindMemberToOverride (
+ MethodInfo mi = (MethodInfo) ParentContainer.BaseCache.FindMemberToOverride (
Parent.TypeBuilder, Name, ParameterTypes, GenericMethod, false);
if (mi == null)
return true;
}
- public EmitContext CreateEmitContext (TypeContainer tc, ILGenerator ig)
+ public EmitContext CreateEmitContext (DeclSpace tc, ILGenerator ig)
{
EmitContext ec = new EmitContext (this,
- tc, ds, Location, ig, ReturnType, ModFlags, false);
+ tc, this.ds, Location, ig, ReturnType, ModFlags, false);
Iterator iterator = tc as Iterator;
if (iterator != null)
// The spec claims that static is not permitted, but
// my very own code has static constructors.
//
- public Constructor (TypeContainer ds, string name, int mod, Parameters args,
+ public Constructor (DeclSpace parent, string name, int mod, Parameters args,
ConstructorInitializer init, Location loc)
- : base (ds, null, null, mod, AllowedModifiers, false,
+ : base (parent, null, null, mod, AllowedModifiers, false,
new MemberName (name, loc), null, args)
{
Initializer = init;
}
public bool HasCompliantArgs {
- get {
- return has_compliant_args;
- }
+ get { return has_compliant_args; }
}
public override AttributeTargets AttributeTargets {
- get {
- return AttributeTargets.Constructor;
- }
+ get { return AttributeTargets.Constructor; }
}
protected override bool CheckForDuplications ()
{
- ArrayList ar = Parent.InstanceConstructors;
+ ArrayList ar = ParentContainer.InstanceConstructors;
if (ar != null) {
int arLen = ar.Count;
if (!CheckForDuplications ())
return false;
- if (Parent.Kind == Kind.Struct) {
+ if (ParentContainer.Kind == Kind.Struct) {
if (ParameterTypes.Length == 0) {
Report.Error (568, Location,
"Structs cannot contain explicit parameterless constructors");
if ((ModFlags & Modifiers.UNSAFE) != 0)
ConstructorBuilder.InitLocals = false;
- if (Parent.IsComImport) {
+ if (ParentContainer.IsComImport) {
if (!IsDefault ()) {
Report.Error (669, Location, "`{0}': A class with the ComImport attribute cannot have a user-defined constructor",
Parent.GetSignatureForError ());
// If this is a non-static `struct' constructor and doesn't have any
// initializer, it must initialize all of the struct's fields.
- if ((Parent.Kind == Kind.Struct) &&
+ if ((ParentContainer.Kind == Kind.Struct) &&
((ModFlags & Modifiers.STATIC) == 0) && (Initializer == null))
Block.AddThisVariable (Parent, Location);
}
if ((ModFlags & Modifiers.STATIC) == 0){
- if (Parent.Kind == Kind.Class && Initializer == null)
+ if (ParentContainer.Kind == Kind.Class && Initializer == null)
Initializer = new GeneratedBaseInitializer (Location);
//
// Classes can have base initializers and instance field initializers.
//
- if (Parent.Kind == Kind.Class){
+ if (ParentContainer.Kind == Kind.Class){
if ((ModFlags & Modifiers.STATIC) == 0){
//
get {
CallingConventions cc = Parameters.CallingConvention;
- if (Parent.Kind == Kind.Class)
+ if (ParentContainer.Kind == Kind.Class)
if ((ModFlags & Modifiers.STATIC) == 0)
cc |= CallingConventions.HasThis;
}
}
- public EmitContext CreateEmitContext (TypeContainer tc, ILGenerator ig)
+ public EmitContext CreateEmitContext (DeclSpace ds, ILGenerator ig)
{
ILGenerator ig_ = ConstructorBuilder.GetILGenerator ();
return new EmitContext (this, Parent, Location, ig_, null, ModFlags, true);
Attributes OptAttributes { get; }
ToplevelBlock Block { get; set; }
- EmitContext CreateEmitContext (TypeContainer tc, ILGenerator ig);
+ EmitContext CreateEmitContext (DeclSpace ds, ILGenerator ig);
ObsoleteAttribute GetObsoleteAttribute ();
string GetSignatureForError ();
bool IsExcluded ();
this.parent_method = parent_method;
}
- public bool Define (TypeContainer container)
+ public bool Define (DeclSpace parent)
{
string name = method.MethodName.Basename;
string method_name = method.MethodName.FullName;
+ TypeContainer container = ((TypeContainer) parent).PartialContainer;
+
PendingImplementation pending = container.PendingImplementations;
if (pending != null){
if (member is Indexer) // TODO: test it, but it should work without this IF
//
// Emits the code
//
- public void Emit (TypeContainer container)
+ public void Emit (DeclSpace parent)
{
EmitContext ec;
if ((flags & MethodAttributes.PinvokeImpl) == 0)
- ec = method.CreateEmitContext (container, builder.GetILGenerator ());
+ ec = method.CreateEmitContext (parent, builder.GetILGenerator ());
else
- ec = method.CreateEmitContext (container, null);
+ ec = method.CreateEmitContext (parent, null);
- if (method.GetObsoleteAttribute () != null || container.GetObsoleteAttribute () != null)
+ if (method.GetObsoleteAttribute () != null || parent.GetObsoleteAttribute () != null)
ec.TestObsoleteMethodUsage = false;
method.ParameterInfo.ApplyAttributes (MethodBuilder);
ToplevelBlock block = method.Block;
- SourceMethod source = SourceMethod.Create (
- container, MethodBuilder, method.Block);
+ SourceMethod source = SourceMethod.Create (parent, MethodBuilder, method.Block);
//
// Handle destructors specially
// TODO: Should derive from MethodCore
public class Destructor : Method {
- public Destructor (TypeContainer ds, Expression return_type, int mod,
+ public Destructor (DeclSpace parent, Expression return_type, int mod,
string name, Parameters parameters, Attributes attrs,
Location l)
- : base (ds, null, return_type, mod, false, new MemberName (name, l),
+ : base (parent, null, return_type, mod, false, new MemberName (name, l),
parameters, attrs)
{ }
set { SetMemberName (new MemberName (MemberName.Left, value, Location)); }
}
- public new TypeContainer Parent {
- get { return (TypeContainer) base.Parent; }
- }
-
public TypeContainer ParentContainer {
get { return ((TypeContainer) Parent).PartialContainer; }
}
//
// The constructor is only exposed to our children
//
- protected MemberBase (TypeContainer parent, GenericMethod generic,
+ protected MemberBase (DeclSpace parent, GenericMethod generic,
Expression type, int mod, int allowed_mod, int def_mod,
MemberName name, Attributes attrs)
: base (parent, name, attrs)
protected virtual bool CheckBase ()
{
- if ((ModFlags & Modifiers.PROTECTED) != 0 && Parent.Kind == Kind.Struct) {
+ if ((ModFlags & Modifiers.PROTECTED) != 0 && ParentContainer.Kind == Kind.Struct) {
Report.Error (666, Location, "`{0}': new protected member declared in struct", GetSignatureForError ());
return false;
}
MethodAttributes.NewSlot |
MethodAttributes.Virtual;
} else {
- if (!Parent.MethodModifiersValid (this))
+ if (!ParentContainer.MethodModifiersValid (this))
return false;
flags = Modifiers.MethodAttr (ModFlags);
/// </summary>
public MemberInfo conflict_symbol;
- protected FieldBase (TypeContainer parent, Expression type, int mod,
+ protected FieldBase (DeclSpace parent, Expression type, int mod,
int allowed_mod, MemberName name, Attributes attrs)
: base (parent, null, type, mod, allowed_mod, Modifiers.PRIVATE,
name, attrs)
if (IsInterface)
return true;
- conflict_symbol = Parent.FindBaseMemberWithSameName (Name, false);
+ conflict_symbol = ParentContainer.FindBaseMemberWithSameName (Name, false);
if (conflict_symbol == null) {
if ((RootContext.WarningLevel >= 4) && ((ModFlags & Modifiers.NEW) != 0)) {
Report.Warning (109, 4, Location, "The member `{0}' does not hide an inherited member. The new keyword is not required", GetSignatureForError ());
public abstract class FieldMember : FieldBase
{
- protected FieldMember (TypeContainer parent, Expression type, int mod,
+ protected FieldMember (DeclSpace parent, Expression type, int mod,
int allowed_mod, MemberName name, Attributes attrs)
: base (parent, type, mod, allowed_mod | Modifiers.ABSTRACT, name, attrs)
{
{
status |= Status.HAS_OFFSET;
- if (!Parent.HasExplicitLayout) {
+ if (!ParentContainer.HasExplicitLayout) {
Report.Error (636, Location, "The FieldOffset attribute can only be placed on members of types marked with the StructLayout(LayoutKind.Explicit)");
return;
}
Modifiers.INTERNAL |
Modifiers.PRIVATE;
- public FixedField (TypeContainer parent, Expression type, int mod, string name,
+ public FixedField (DeclSpace parent, Expression type, int mod, string name,
Expression size_expr, Attributes attrs, Location loc):
base (parent, type, mod, AllowedModifiers, new MemberName (name, loc), attrs)
{
Report.Warning (-23, 1, Location, "Only private or internal fixed sized buffers are supported by .NET 1.x");
#endif
- if (Parent.Kind != Kind.Struct) {
+ if (ParentContainer.Kind != Kind.Struct) {
Report.Error (1642, Location, "`{0}': Fixed size buffer fields may only be members of structs",
GetSignatureForError ());
return false;
Modifiers.UNSAFE |
Modifiers.READONLY;
- public Field (TypeContainer parent, Expression type, int mod, string name,
+ public Field (DeclSpace parent, Expression type, int mod, string name,
Attributes attrs, Location loc)
: base (parent, type, mod, AllowedModifiers, new MemberName (name, loc),
attrs)
FieldAttributes fa = Modifiers.FieldAttr (ModFlags);
- if (Parent.Kind == Kind.Struct &&
+ if (ParentContainer.Kind == Kind.Struct &&
((fa & FieldAttributes.Static) == 0) &&
MemberType == Parent.TypeBuilder &&
!TypeManager.IsBuiltinType (MemberType)){
public abstract Parameters ParameterInfo { get ; }
public abstract Type ReturnType { get; }
- public abstract EmitContext CreateEmitContext(TypeContainer tc, ILGenerator ig);
+ public abstract EmitContext CreateEmitContext (DeclSpace ds, ILGenerator ig);
#endregion
throw new NotSupportedException ();
}
- public virtual void Emit (TypeContainer container)
+ public virtual void Emit (DeclSpace parent)
{
- EmitMethod (container);
+ EmitMethod (parent);
if (declarative_security != null) {
foreach (DictionaryEntry de in declarative_security) {
block = null;
}
- protected virtual void EmitMethod (TypeContainer container)
+ protected virtual void EmitMethod (DeclSpace parent)
{
- method_data.Emit (container);
+ method_data.Emit (parent);
}
public override bool IsClsComplianceRequired()
{
}
- public override MethodBuilder Define(TypeContainer container)
+ public override MethodBuilder Define (DeclSpace parent)
{
- base.Define (container);
+ base.Define (parent);
method_data = new MethodData (method, ModFlags, flags, this);
- if (!method_data.Define (container))
+ if (!method_data.Define (parent))
return null;
return method_data.MethodBuilder;
new Type[] { method.MemberType });
}
- public override MethodBuilder Define (TypeContainer container)
+ public override MethodBuilder Define (DeclSpace parent)
{
DefineParameters ();
if (IsDummy)
return null;
- base.Define (container);
+ base.Define (parent);
method_data = new MethodData (method, ModFlags, flags, this);
- if (!method_data.Define (container))
+ if (!method_data.Define (parent))
return null;
return method_data.MethodBuilder;
return method.IsClsComplianceRequired ();
}
- public virtual MethodBuilder Define (TypeContainer container)
+ public virtual MethodBuilder Define (DeclSpace parent)
{
if (!method.CheckAbstractAndExtern (block != null))
return null;
+ TypeContainer container = ((TypeContainer) parent).PartialContainer;
+
//
// Check for custom access modifier
//
Report.Error (442, Location, "`{0}': abstract properties cannot have private accessors", GetSignatureForError ());
}
- CheckModifiers (container, ModFlags);
+ CheckModifiers (ModFlags);
ModFlags |= (method.ModFlags & (~Modifiers.Accessibility));
ModFlags |= Modifiers.PROPERTY_CUSTOM;
flags = Modifiers.MethodAttr (ModFlags);
}
}
- public override EmitContext CreateEmitContext (TypeContainer tc,
- ILGenerator ig)
+ public override EmitContext CreateEmitContext (DeclSpace ds, ILGenerator ig)
{
return new EmitContext (method,
- tc, method.ds, method.Location, ig, ReturnType,
+ ds, method.ds, method.Location, ig, ReturnType,
method.ModFlags, false);
}
return method.GetSignatureForError () + '.' + prefix.Substring (0, 3);
}
- void CheckModifiers (TypeContainer container, int modflags)
+ void CheckModifiers (int modflags)
{
int flags = 0;
int mflags = method.ModFlags & Modifiers.Accessibility;
protected EmitContext ec;
- public PropertyBase (TypeContainer parent, Expression type, int mod_flags,
+ public PropertyBase (DeclSpace parent, Expression type, int mod_flags,
int allowed_mod, bool is_iface, MemberName name,
Parameters parameters, Attributes attrs)
: base (parent, null, type, mod_flags, allowed_mod, is_iface, name,
protected override bool CheckForDuplications ()
{
- ArrayList ar = Parent.Indexers;
+ ArrayList ar = ParentContainer.Indexers;
if (ar != null) {
int arLen = ar.Count;
}
}
- ar = Parent.Properties;
+ ar = ParentContainer.Properties;
if (ar != null) {
int arLen = ar.Count;
// TODO: rename to Resolve......
protected override MethodInfo FindOutBaseMethod (ref Type base_ret_type)
{
- PropertyInfo base_property = Parent.BaseCache.FindMemberToOverride (
+ PropertyInfo base_property = ParentContainer.BaseCache.FindMemberToOverride (
Parent.TypeBuilder, Name, ParameterTypes, null, true) as PropertyInfo;
if (base_property == null)
const int AllowedInterfaceModifiers =
Modifiers.NEW;
- public Property (TypeContainer ds, Expression type, int mod, bool is_iface,
+ public Property (DeclSpace parent, Expression type, int mod, bool is_iface,
MemberName name, Attributes attrs, Accessor get_block,
Accessor set_block)
- : base (ds, type, mod,
+ : base (parent, type, mod,
is_iface ? AllowedInterfaceModifiers : AllowedModifiers,
is_iface, name, Parameters.EmptyReadOnlyParameters, attrs)
{
static string[] attribute_targets = new string [] { "event" }; // "property" target was disabled for 2.0 version
- public EventProperty (TypeContainer parent, Expression type, int mod_flags,
+ public EventProperty (DeclSpace parent, Expression type, int mod_flags,
bool is_iface, MemberName name,
Attributes attrs, Accessor add, Accessor remove)
: base (parent, type, mod_flags, is_iface, name, attrs)
static string[] attribute_targets = new string [] { "event", "field", "method" };
static string[] attribute_targets_interface = new string[] { "event", "method" };
- public EventField (TypeContainer parent, Expression type, int mod_flags,
+ public EventField (DeclSpace parent, Expression type, int mod_flags,
bool is_iface, MemberName name,
Attributes attrs)
: base (parent, type, mod_flags, is_iface, name, attrs)
}
- public abstract class DelegateMethod: AbstractPropertyEventMethod
+ public abstract class DelegateMethod : AbstractPropertyEventMethod
{
protected readonly Event method;
ImplicitParameter param_attr;
return method.IsClsComplianceRequired ();
}
- public MethodBuilder Define (TypeContainer container)
+ public MethodBuilder Define (DeclSpace parent)
{
method_data = new MethodData (method, method.ModFlags,
method.flags | MethodAttributes.HideBySig | MethodAttributes.SpecialName, this);
- if (!method_data.Define (container))
+ if (!method_data.Define (parent))
return null;
MethodBuilder mb = method_data.MethodBuilder;
}
- protected override void EmitMethod (TypeContainer tc)
+ protected override void EmitMethod (DeclSpace parent)
{
if (block != null) {
- base.EmitMethod (tc);
+ base.EmitMethod (parent);
return;
}
}
}
- public override EmitContext CreateEmitContext (TypeContainer tc,
- ILGenerator ig)
+ public override EmitContext CreateEmitContext (DeclSpace ds, ILGenerator ig)
{
return new EmitContext (
- tc, method.Parent, Location, ig, ReturnType,
+ ds, method.Parent, Location, ig, ReturnType,
method.ModFlags, false);
}
public MethodBuilder AddBuilder, RemoveBuilder;
Parameters parameters;
- protected Event (TypeContainer parent, Expression type, int mod_flags,
+ protected Event (DeclSpace parent, Expression type, int mod_flags,
bool is_iface, MemberName name, Attributes attrs)
: base (parent, type, mod_flags,
is_iface ? AllowedInterfaceModifiers : AllowedModifiers,
//
// Are we implementing an interface ?
//
- public Indexer (TypeContainer parent, Expression type, MemberName name, int mod,
+ public Indexer (DeclSpace parent, Expression type, MemberName name, int mod,
bool is_iface, Parameters parameters, Attributes attrs,
Accessor get_block, Accessor set_block)
: base (parent, type, mod,
ShortName = base_IndexerName;
}
- if (!Parent.AddToMemberContainer (this) ||
- !Parent.AddToMemberContainer (Get) || !Parent.AddToMemberContainer (Set))
+ if (!ParentContainer.AddToMemberContainer (this) ||
+ !ParentContainer.AddToMemberContainer (Get) || !ParentContainer.AddToMemberContainer (Set))
return false;
if (!CheckBase ())
static string[] attribute_targets = new string [] { "method", "return" };
- public Operator (TypeContainer parent, OpType type, Expression ret_type,
+ public Operator (DeclSpace parent, OpType type, Expression ret_type,
int mod_flags, Parameters parameters,
ToplevelBlock block, Attributes attrs, Location loc)
: base (parent, null, ret_type, mod_flags, AllowedModifiers, false,
}
}
- protected override bool CheckForDuplications()
+ protected override bool CheckForDuplications ()
{
- ArrayList ar = Parent.Operators;
+ ArrayList ar = ParentContainer.Operators;
if (ar != null) {
int arLen = ar.Count;
}
}
- ar = Parent.Methods;
+ ar = ParentContainer.Methods;
if (ar != null) {
int arLen = ar.Count;