//
// This behaves like a property ;-)
//
- readonly public RootContext RootContext;
+ public readonly RootContext RootContext;
+
+ // Attributes for this type
+ protected Attributes attributes;
public TypeContainer (RootContext rc, TypeContainer parent, string name) : base (name)
{
}
}
+ public ArrayList Indexers {
+ get {
+ return indexers;
+ }
+ }
+
+ public ArrayList Operators {
+ get {
+ return operators;
+ }
+ }
+
+ public ArrayList Delegates {
+ get {
+ return delegates;
+ }
+ }
+
+ public Attributes OptAttributes {
+ get {
+ return attributes;
+ }
+ }
+
public Namespace Namespace {
get {
return my_namespace;
foreach (Event e in Events)
e.Define (this);
}
+
+ if (Indexers != null) {
+ foreach (Indexer i in Indexers)
+ i.Define (this);
+ }
+
+ if (Operators != null) {
+ foreach (Operator o in Operators)
+ o.Define (this);
+ }
+
+ if (Delegates != null) {
+ foreach (Delegate d in Delegates)
+ d.Define (this);
+ }
+
+
}
//
{
return RootContext.LookupType (this, name, silent);
}
+
+ // <summary>
+ // This method returns the members of this type just like Type.FindMembers would
+ // Only, we need to use this for types which are _being_ defined because MS' brain
+ // dead implementation can't take care of that ;-)
+ // </summary>
+ public MemberInfo [] FindMembers (MemberTypes mt, BindingFlags bf, MemberFilter filter, object criteria)
+ {
+ // FIXME : Need to actually take care of all the various
+ // arguments being passed in but for now, we only bother with
+ // the MemberTypes and criteria arguments.
+
+ switch (mt) {
+
+ case MemberTypes.All:
+
+ break;
+
+ case MemberTypes.Constructor:
+
+ break;
+
+ case MemberTypes.Custom:
+
+ break;
+
+ case MemberTypes.Event:
+
+ break;
+
+ case MemberTypes.Field:
+
+ break;
+
+ case MemberTypes.Method:
+
+ break;
+
+ case MemberTypes.NestedType:
+
+ break;
+
+ case MemberTypes.Property:
+
+ break;
+
+ case MemberTypes.TypeInfo:
+
+ break;
+
+ }
+
+ return null;
+
+ }
+
}
public class Class : TypeContainer {
Modifiers.ABSTRACT |
Modifiers.SEALED;
- public Class (RootContext rc, TypeContainer parent, string name, int mod)
+ public Class (RootContext rc, TypeContainer parent, string name, int mod, Attributes attrs)
: base (rc, parent, name)
{
int accmods;
accmods = Modifiers.PRIVATE;
this.mod_flags = Modifiers.Check (AllowedModifiers, mod, accmods);
+ this.attributes = attrs;
}
//
Modifiers.INTERNAL |
Modifiers.PRIVATE;
- public Struct (RootContext rc, TypeContainer parent, string name, int mod)
+ public Struct (RootContext rc, TypeContainer parent, string name, int mod, Attributes attrs)
: base (rc, parent, name)
{
int accmods;
this.mod_flags = Modifiers.Check (AllowedModifiers, mod, accmods);
this.mod_flags |= Modifiers.SEALED;
+ this.attributes = attrs;
+
}
//
public readonly string Name;
public readonly int ModFlags;
public MethodBuilder MethodBuilder;
+ public readonly Attributes OptAttributes;
Block block;
// return_type can be "null" for VOID values.
- public Method (string return_type, int mod, string name, Parameters parameters)
+ public Method (string return_type, int mod, string name, Parameters parameters, Attributes attrs)
{
Name = name;
ReturnType = return_type;
Parameters = parameters;
ModFlags = Modifiers.Check (AllowedModifiers, mod, Modifiers.PRIVATE);
+ OptAttributes = attrs;
}
// <summary>
GetCallingConvention (parent is Class),
ret_type, parameters);
+ //
+ // This is used to track the Entry Point,
+ //
+ // FIXME: Allow pluggable entry point, check arguments, etc.
+ //
+ if (Name == "Main"){
+ if ((ModFlags & Modifiers.STATIC) != 0){
+ parent.RootContext.EntryPoint = MethodBuilder;
+ }
+ }
+
//
// Define each type attribute (in/out/ref) and
// the argument names.
public readonly Object Initializer;
public readonly string Name;
public readonly int ModFlags;
+ public readonly Attributes OptAttributes;
// <summary>
// Modifiers allowed in a class declaration
Modifiers.STATIC |
Modifiers.READONLY;
- public Field (string type, int mod, string name, Object expr_or_array_init)
+ public Field (string type, int mod, string name, Object expr_or_array_init, Attributes attrs)
{
Type = type;
ModFlags = Modifiers.Check (AllowedModifiers, mod, Modifiers.PRIVATE);
Name = name;
Initializer = expr_or_array_init;
+ OptAttributes = attrs;
}
}
public readonly int ModFlags;
public Block Get, Set;
public PropertyBuilder PropertyBuilder;
+ public Attributes OptAttributes;
const int AllowedModifiers =
Modifiers.NEW |
Modifiers.ABSTRACT |
Modifiers.VIRTUAL;
- public Property (string type, string name, int mod_flags, Block get_block, Block set_block)
+ public Property (string type, string name, int mod_flags, Block get_block, Block set_block, Attributes attrs)
{
Type = type;
Name = name;
ModFlags = Modifiers.Check (AllowedModifiers, mod_flags, Modifiers.PRIVATE);
Get = get_block;
Set = set_block;
+ OptAttributes = attrs;
}
public void Define (TypeContainer parent)
MethodAttributes method_attr = Modifiers.MethodAttr(ModFlags);
- // FIXME - Right now using Modifiers.MethodAttributes
- // Guess we need to add a special method for ProprtyAttributes
- // in modifiers.cs - when we get final comments from miguel
- // abt why access modifiers like new internal etc are not handled
- // in modifiers.cs
-
// FIXME - how to handle PropertyAttributes.HasDefault
PropertyAttributes prop_attr = PropertyAttributes.RTSpecialName |
PropertyAttributes.SpecialName;
- Type tp = System.Type.GetType(Type);
+ Type tp = parent.LookupType (Type, false);
Type [] prop_type = new Type [1];
prop_type [0] = tp;
public readonly Block Add;
public readonly Block Remove;
public EventBuilder EventBuilder;
-
- public Event (string type, string name, Object init, int flags, Block add_block, Block rem_block)
+ public Attributes OptAttributes;
+
+ public Event (string type, string name, Object init, int flags, Block add_block, Block rem_block,
+ Attributes attrs)
{
Type = type;
Name = name;
ModFlags = Modifiers.Check (AllowedModifiers, flags, Modifiers.PRIVATE);
Add = add_block;
Remove = rem_block;
+ OptAttributes = attrs;
}
public void Define (TypeContainer parent)
MethodBuilder mb;
- Type t = System.Type.GetType (Type);
+ Type t = parent.LookupType (Type, false);
Type [] p_type = new Type [1];
p_type [0] = t;
public readonly int ModFlags;
public readonly Block Get;
public readonly Block Set;
+ public Attributes OptAttributes;
+ public MethodBuilder GetMethodBuilder;
+ public MethodBuilder SetMethodBuilder;
+
public Indexer (string type, string int_type, int flags, Parameters parms,
- Block get_block, Block set_block)
+ Block get_block, Block set_block, Attributes attrs)
{
Type = type;
FormalParameters = parms;
Get = get_block;
Set = set_block;
+ OptAttributes = attrs;
+ }
+
+ public void Define (TypeContainer parent)
+ {
+ MethodAttributes attr = Modifiers.MethodAttr (ModFlags);
+
+ Type ret_type = parent.LookupType (Type, false);
+ Type [] param_types = FormalParameters.GetParameterInfo (parent);
+
+ GetMethodBuilder = parent.TypeBuilder.DefineMethod ("get_Item", attr, ret_type, param_types);
+ SetMethodBuilder = parent.TypeBuilder.DefineMethod ("set_Item", attr, ret_type, param_types);
+
+ Parameter [] p = FormalParameters.FixedParameters;
+
+ if (p != null) {
+ int i;
+
+ for (i = 0; i < p.Length; ++i) {
+ GetMethodBuilder.DefineParameter (i + 1, p [i].Attributes, p [i].Name);
+ SetMethodBuilder.DefineParameter (i + 1, p [i].Attributes, p [i].Name);
+ }
+
+ if (i != param_types.Length)
+ Console.WriteLine ("Implement type definition for params");
+ }
+
}
+
}
public class Operator {
public readonly string SecondArgName;
public readonly int ModFlags;
public readonly Block Block;
+ public Attributes OptAttributes;
+ public MethodBuilder OperatorMethodBuilder;
public Operator (OpType type, string ret_type, int flags, string arg1type, string arg1name,
- string arg2type, string arg2name, Block block)
+ string arg2type, string arg2name, Block block, Attributes attrs)
{
OperatorType = type;
ReturnType = ret_type;
SecondArgType = arg2type;
SecondArgName = arg2name;
Block = block;
+ OptAttributes = attrs;
}
-
- public static void CheckUnaryOperator (OpType op)
- {
- switch (op) {
- case OpType.Bang : case OpType.Tilde : case OpType.Increment : case OpType.Decrement :
- case OpType.True : case OpType.False : case OpType.Plus : case OpType.Minus :
+ public void Define (TypeContainer parent)
+ {
+ MethodAttributes attr = Modifiers.MethodAttr (ModFlags);
- break;
-
- default :
- // We have an error
-
- CSharpParser.error (1019, "Overloadable unary operator expected");
- break;
-
- }
- }
+ string name = "Operator" + OperatorType;
- public static void CheckBinaryOperator (OpType op)
- {
- switch (op) {
+ Type ret_type = parent.LookupType (ReturnType, false);
- case OpType.Plus : case OpType.Minus : case OpType.Star : case OpType.Div :
- case OpType.Percent : case OpType.BitAnd : case OpType.BitOr : case OpType.Carret :
- case OpType.ShiftLeft : case OpType.ShiftRight : case OpType.Eq : case OpType.NotEq :
- case OpType.GreaterThan : case OpType.LesserThan : case OpType.GreaterOrEq :
- case OpType.LesserOrEq :
+ Type [] param_types = new Type [2];
- break;
+ param_types [0] = parent.LookupType (FirstArgType, false);
+ if (SecondArgType != null)
+ param_types [1] = parent.LookupType (SecondArgType, false);
+
+ OperatorMethodBuilder = parent.TypeBuilder.DefineMethod (name, attr, ret_type, param_types);
- default :
+ OperatorMethodBuilder.DefineParameter (1, ParameterAttributes.None, FirstArgName);
- CSharpParser.error (1020, "Overloadable binary operator expected");
- break;
- }
+ if (SecondArgType != null)
+ OperatorMethodBuilder.DefineParameter (2, ParameterAttributes.None, SecondArgName);
}
+
}