static public Type char_ptr_type;
static public Type short_type;
static public Type decimal_type;
+ static public Type date_type;
static public Type bool_type;
static public Type sbyte_type;
static public Type byte_type;
static public Expression system_int32_expr, system_uint32_expr;
static public Expression system_int64_expr, system_uint64_expr;
static public Expression system_char_expr, system_void_expr;
+ static public Expression system_date_expr;
static public Expression system_asynccallback_expr;
static public Expression system_iasyncresult_expr;
//
static public ConstructorInfo cons_param_array_attribute;
static public ConstructorInfo void_decimal_ctor_five_args;
+ static public ConstructorInfo void_datetime_ctor_ticks_arg;
static public ConstructorInfo unverifiable_code_ctor;
// <remarks>
static Hashtable indexer_arguments;
// <remarks>
- // Maybe `method_arguments' should be replaced and only
+ // Maybe 'method_arguments' should be replaced and only
// method_internal_params should be kept?
// <remarks>
static Hashtable method_internal_params;
system_uint64_expr = new TypeLookupExpression ("System.UInt64");
system_char_expr = new TypeLookupExpression ("System.Char");
system_void_expr = new TypeLookupExpression ("System.Void");
+ system_date_expr = new TypeLookupExpression ("System.DateTime");
system_asynccallback_expr = new TypeLookupExpression ("System.AsyncCallback");
system_iasyncresult_expr = new TypeLookupExpression ("System.IAsyncResult");
}
//
// This probably never happens, as we catch this before
//
- Report.Error (-17, "The type `" + name + "' has already been defined.");
+ Report.Error (-17, "The type '" + name + "' has already been defined.");
return;
}
tc = builder_to_declspace [t] as TypeContainer;
Report.Warning (
- 1595, "The type `" + name + "' is defined in an existing assembly;"+
+ 1595, "The type '" + name + "' is defined in an existing assembly;"+
" Using the new definition from: " + tc.Location);
Report.Warning (1595, "Previously defined in: " + prev.Assembly.FullName);
}
/// <summary>
- /// Returns the TypeContainer whose Type is `t' or null if there is no
- /// TypeContainer for `t' (ie, the Type comes from a library)
+ /// Returns the TypeContainer whose Type is 't' or null if there is no
+ /// TypeContainer for 't' (ie, the Type comes from a library)
/// </summary>
public static TypeContainer LookupTypeContainer (Type t)
{
n [top] = a;
assemblies = n;
+
+ foreach(Type type in a.GetTypes()) {
+ if (type.IsPublic ) // && type. attributed as standard module
+ AddStandardModule(type);
+ }
}
/// <summary>
modules = n;
}
+
+ private class StandardModule {
+ public readonly string Namespace;
+ public readonly string Name;
+ public StandardModule(string _namespace, string name) { Namespace = _namespace; Name = name; }
+ public override string ToString() { return ((Namespace != null && Namespace.Length > 0)?(Namespace + "."):"") + Name; }
+ }
+
+ private static StandardModule[] standardModules;
+
+ /// <summary>
+ /// Registers a new 'standard module' to lookup short-qualified or unqualified members
+ /// </summary>
+ internal static void AddStandardModule(Module module)
+ {
+ int top = standardModules != null ? standardModules.Length : 0;
+ StandardModule [] n = new StandardModule [top + 1];
+
+ if (standardModules != null)
+ standardModules.CopyTo (n, 0);
+ string name = module.Name;
+ int split = name.LastIndexOf('.');
+ if (split > 0)
+ name = name.Substring(split+1);
+ n [top] = new StandardModule(module.Namespace.Name, name);
+ //Console.WriteLine("Standard Module added:" + module.Name + " [" + n [top] + "]");
+ standardModules = n;
+ }
+
+ ///
+ /// Registers a existing 'standard module' to lookup short-qualified or unqualified members
+ ///
+ private static void AddStandardModule(Type type)
+ {
+ object[] attributes = type.GetCustomAttributes(false);
+ for (int i = 0; i < attributes.Length; i ++) {
+ if (attributes[i].ToString() == "Microsoft.VisualBasic.CompilerServices.StandardModuleAttribute") {
+ int top = standardModules != null ? standardModules.Length : 0;
+ StandardModule [] n = new StandardModule [top + 1];
+
+ if (standardModules != null)
+ standardModules.CopyTo (n, 0);
+ n [top] = new StandardModule(type.Namespace, type.Name) ;
+ standardModules = n;
+
+ return;
+ }
+ }
+ }
+
+ //
+ //
+ //
+ public static Type[] GetPertinentStandardModules(string[] namespaces)
+ {
+ ArrayList list = new ArrayList();
+ foreach(string Namespace in namespaces)
+ {
+ for(int i = 0; i < standardModules.Length; i++)
+ if (standardModules[i].Namespace == Namespace) {
+ string name = standardModules[i].ToString();
+ Type t = LookupType(name);
+ if (t == null) {
+ System.Console.WriteLine("Could not find standard module '" + name + "'");
+ }
+ else {
+ list.Add(t);
+ }
+ }
+ }
+ return (Type[])list.ToArray(typeof(Type));
+ }
+
//
// Low-level lookup, cache-less
//
{
Type t;
- foreach (Assembly a in assemblies){
- t = a.GetType (name, false, true);
- if (t != null)
- return t;
- }
+ try {
+ foreach (Assembly a in assemblies){
+ t = a.GetType (name, false, true);
+ if (t != null)
+ return t;
+ }
- foreach (ModuleBuilder mb in modules) {
- t = mb.GetType (name, false, true);
- if (t != null){
- return t;
+ foreach (ModuleBuilder mb in modules) {
+ t = mb.GetType (name, false, true);
+ if (t != null){
+ return t;
+ }
}
+ } catch (Exception e) {
+ System.Console.WriteLine("\nERROR: " + e.ToString() + "WHILE EXECUTING LookupTypeReflection(\"" + name + "\")\n");
}
return null;
}
{
CaseInsensitiveHashtable namespaces = new CaseInsensitiveHashtable ();
- foreach (Assembly a in assemblies){
- foreach (Type t in a.GetTypes ()){
+ foreach (Assembly a in assemblies) {
+ foreach (Type t in a.GetTypes ()) {
string ns = t.Namespace;
if (namespaces.Contains (ns))
}
}
- foreach (ModuleBuilder mb in modules){
- foreach (Type t in mb.GetTypes ()){
+ foreach (ModuleBuilder mb in modules) {
+ foreach (Type t in mb.GetTypes ()) {
string ns = t.Namespace;
if (namespaces.Contains (ns))
namespaces [ns] = ns;
}
}
+
return namespaces;
}
{
return Regex.Replace (t.FullName,
@"^System\." +
- @"(Int32|UInt32|Int16|Uint16|Int64|UInt64|" +
- @"Single|Double|Char|Decimal|Byte|SByte|Object|" +
- @"Boolean|String|Void)" +
+ @"(Int32|Int16|Int64|Single|Double|Char|Decimal|Byte|Object|Boolean|String|DateTime)" +
@"(\W+|\b)",
new MatchEvaluator (MonoBASIC_NameMatch));
}
{
string s = match.Groups [1].Captures [0].Value;
return s.ToLower ().
- Replace ("int32", "int").
- Replace ("uint32", "uint").
+ Replace ("int32", "integer").
Replace ("int16", "short").
- Replace ("uint16", "ushort").
Replace ("int64", "long").
- Replace ("uint64", "ulong").
- Replace ("single", "float").
- Replace ("boolean", "bool")
+ Replace ("datetime", "date")
+ match.Groups [2].Captures [0].Value;
}
Type t = LookupType (name);
if (t == null){
- Report.Error (518, "The predefined type `" + name + "' is not defined or imported");
+ Report.Error (518, "The predefined type '" + name + "' is not defined or imported");
Environment.Exit (0);
}
}
/// <summary>
- /// Returns the MethodInfo for a method named `name' defined
- /// in type `t' which takes arguments of types `args'
+ /// Returns the MethodInfo for a method named 'name' defined
+ /// in type 't' which takes arguments of types 'args'
/// </summary>
static MethodInfo GetMethod (Type t, string name, Type [] args)
{
list = FindMembers (t, MemberTypes.Method, instance_and_static | BindingFlags.Public| BindingFlags.IgnoreCase,
signature_filter, sig);
if (list.Count == 0) {
- Report.Error (-19, "Can not find the core function `" + name + "'");
+ Report.Error (-19, "Can not find the core function '" + name + "'");
return null;
}
MethodInfo mi = list [0] as MethodInfo;
if (mi == null) {
- Report.Error (-19, "Can not find the core function `" + name + "'");
+ Report.Error (-19, "Can not find the core function '" + name + "'");
return null;
}
instance_and_static | BindingFlags.Public | BindingFlags.DeclaredOnly | BindingFlags.IgnoreCase,
signature_filter, sig);
if (list.Count == 0){
- Report.Error (-19, "Can not find the core constructor for type `" + t.Name + "'");
+ Report.Error (-19, "Can not find the core constructor for type '" + t.Name + "'");
return null;
}
ConstructorInfo ci = list [0] as ConstructorInfo;
if (ci == null){
- Report.Error (-19, "Can not find the core constructor for type `" + t.Name + "'");
+ Report.Error (-19, "Can not find the core constructor for type '" + t.Name + "'");
return null;
}
array_type = CoreLookupType ("System.Array");
void_type = CoreLookupType ("System.Void");
+ date_type = CoreLookupType ("System.DateTime");
type_type = CoreLookupType ("System.Type");
runtime_field_handle_type = CoreLookupType ("System.RuntimeFieldHandle");
void_decimal_ctor_five_args = GetConstructor (
decimal_type, dec_arg);
+ // DateTime constructor
+ Type [] ticks_arg = { int64_type };
+ void_datetime_ctor_ticks_arg = GetConstructor ( date_type, ticks_arg);
+
//
// Attributes
//
DeclSpace decl = (DeclSpace) builder_to_declspace [t];
bf |= BindingFlags.IgnoreCase;
//
- // `builder_to_declspace' contains all dynamic types.
+ // 'builder_to_declspace' contains all dynamic types.
//
if (decl != null) {
MemberList list;
/// <summary>
/// This method is only called from within MemberLookup. It tries to use the member
- /// cache if possible and falls back to the normal FindMembers if not. The `used_cache'
+ /// cache if possible and falls back to the normal FindMembers if not. The 'used_cache'
/// flag tells the caller whether we used the cache or not. If we used the cache, then
/// our return value will already contain all inherited members and the caller don't need
/// to check base classes and interfaces anymore.
}
//
- // If this is a dynamic type, it's always in the `builder_to_declspace' hash table
+ // If this is a dynamic type, it's always in the 'builder_to_declspace' hash table
// and we can ask the DeclSpace for the MemberCache.
//
if (t is TypeBuilder) {
if (t == object_type || t == string_type || t == int32_type || t == uint32_type ||
t == int64_type || t == uint64_type || t == float_type || t == double_type ||
t == char_type || t == short_type || t == decimal_type || t == bool_type ||
- t == sbyte_type || t == byte_type || t == ushort_type || t == void_type)
+ t == sbyte_type || t == byte_type || t == ushort_type || t == void_type ||
+ t == date_type)
return true;
else
return false;
}
//
- // Checks whether `type' is a subclass or nested child of `parent'.
+ // Checks whether 'type' is a subclass or nested child of 'parent'.
//
public static bool IsSubclassOrNestedChildOf (Type type, Type parent)
{
}
//
- // Checks whether `type' is a nested child of `parent'.
+ // Checks whether 'type' is a nested child of 'parent'.
//
public static bool IsNestedChildOf (Type type, Type parent)
{
return (Type []) indexer_arguments [indexer];
else if (indexer is PropertyBuilder)
// If we're a PropertyBuilder and not in the
- // `indexer_arguments' hash, then we're a property and
+ // 'indexer_arguments' hash, then we're a property and
// not an indexer.
return NoTypes;
else {
return (MethodInfo) de.Second;
} else
- return pi.GetSetMethod ();
+ return pi.GetSetMethod (true);
}
static public MethodInfo GetPropertySetter (PropertyInfo pi)
return (MethodInfo) de.First;
} else
- return pi.GetGetMethod ();
+ return pi.GetGetMethod (true);
}
/// <summary>
}
/// <summary>
- /// This function returns the interfaces in the type `t'. Works with
+ /// This function returns the interfaces in the type 't'. Works with
/// both types and TypeBuilders.
/// </summary>
public static Type [] GetInterfaces (Type t)
//
// FIXME OPTIMIZATION:
// as soon as we hit a non-TypeBuiler in the interface
- // chain, we could return, as the `Type.GetInterfaces'
+ // chain, we could return, as the 'Type.GetInterfaces'
// will return all the interfaces implement by the type
// or its parents.
//
NumberFormatInfo provider = ci.NumberFormat;
//
- // We must use Type.Equals() here since `conversionType' is
+ // We must use Type.Equals() here since 'conversionType' is
// the TypeBuilder created version of a system type and not
// the system type itself. You cannot use Type.GetTypeCode()
// on such a type - it'd always return TypeCode.Object.
return TypeManager.uint64_type;
case TypeCode.String:
return TypeManager.string_type;
+ case TypeCode.DateTime:
+ return TypeManager.date_type;
default:
if (t == typeof (void))
return TypeManager.void_type;
/// Returns the name of the indexer in a given type.
/// </summary>
/// <remarks>
- /// The default is not always `Item'. The user can change this behaviour by
+ /// The default is not always 'Item'. The user can change this behaviour by
/// using the DefaultMemberAttribute in the class.
///
- /// For example, the String class indexer is named `Chars' not `Item'
+ /// For example, the String class indexer is named 'Chars' not 'Item'
/// </remarks>
public static string IndexerPropertyName (Type t)
{
}
//
- // We copy methods from `new_members' into `target_list' if the signature
+ // We copy methods from 'new_members' into 'target_list' if the signature
// for the method from in the new list does not exist in the target_list
//
// The name is assumed to be the same.
string method_desc = TypeManager.MonoBASIC_Signature (mb);
if (oa.IsError) {
- Report.Error (619, loc, "Method `" + method_desc +
- "' is obsolete: `" + oa.Message + "'");
+ Report.Error (619, loc, "Method '" + method_desc +
+ "' is obsolete: '" + oa.Message + "'");
return MethodFlags.IsObsoleteError;
} else
- Report.Warning (618, loc, "Method `" + method_desc +
- "' is obsolete: `" + oa.Message + "'");
+ Report.Warning (618, loc, "Method '" + method_desc +
+ "' is obsolete: '" + oa.Message + "'");
flags |= MethodFlags.IsObsolete;
static internal bool FilterWithClosure (MemberInfo m, object filter_criteria)
{
//
- // Hack: we know that the filter criteria will always be in the `closure'
+ // Hack: we know that the filter criteria will always be in the 'closure'
// fields.
//
return true;
//
- // Ugly: we need to find out the type of `m', and depending
+ // Ugly: we need to find out the type of 'm', and depending
// on this, tell whether we accept or not
//
if (m is MethodBase){
static MemberFilter FilterWithClosure_delegate = new MemberFilter (FilterWithClosure);
//
- // Looks up a member called `name' in the `queried_type'. This lookup
- // is done by code that is contained in the definition for `invocation_type'.
+ // Looks up a member called 'name' in the 'queried_type'. This lookup
+ // is done by code that is contained in the definition for 'invocation_type'.
//
- // The binding flags are `bf' and the kind of members being looked up are `mt'
+ // The binding flags are 'bf' and the kind of members being looked up are 'mt'
//
// Returns an array of a single element for everything but Methods/Constructors
// that might return multiple matches.
ArrayList method_list = null;
Type current_type = queried_type;
+ if (queried_type == null)
+ throw new ArgumentNullException("queried_type");
bool searching = (original_bf & BindingFlags.DeclaredOnly) == 0;
bool private_ok;
bool always_ok_flag = false;
MemberList list;
//
- // `NonPublic' is lame, because it includes both protected and
+ // 'NonPublic' is lame, because it includes both protected and
// private methods, so we need to control this behavior by
// explicitly tracking if a private method is ok or not.
//
closure_queried_type = current_type;
Timer.StopTimer (TimerType.MemberLookup);
-bf |= BindingFlags.IgnoreCase;
+ bf |= BindingFlags.IgnoreCase;
list = MemberLookup_FindMembers (current_type, mt, bf, name, out used_cache);
Timer.StartTimer (TimerType.MemberLookup);
continue;
//
- // Events and types are returned by both `static' and `instance'
+ // Events and types are returned by both 'static' and 'instance'
// searches, which means that our above FindMembers will
// return two copies of the same.
//