Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Move GetNestedTypes() from TypeBuilder into TypeInfo.

  • Loading branch information...
commit a5044d06c062c96677b0be84d486b2bb8de6f4c6 1 parent 719c586
@VladD2 VladD2 authored
Showing with 37 additions and 39 deletions.
  1. +0 −38 ncc/hierarchy/TypeBuilder.n
  2. +37 −1 ncc/hierarchy/TypeInfo.n
View
38 ncc/hierarchy/TypeBuilder.n
@@ -852,29 +852,6 @@ public partial class TypeBuilder : TypeInfo
BindingFlags.Public %| BindingFlags.NonPublic)
}
- /** Searches for the types defined for the current TypeInfo, using the
- specified BindingFlags.
- */
- public GetNestedTypes (bindingAttr : BindingFlags) : list[TypeInfo]
- {
- def attr = bindingAttr | BindingFlags.Static | BindingFlags.Instance;
- def result = SCG.List();
-
- when (NamespaceNode.Children != null)
- foreach (x in NamespaceNode.Children.Values)
- when (x.LookupValue() is Some(t))
- when (constrain_member(t, attr))
- result.Add(t);
-
- result.NToList()
- }
-
- public GetNestedTypes () : list[TypeInfo]
- {
- GetNestedTypes (BindingFlags.Static %| BindingFlags.Instance %|
- BindingFlags.Public %| BindingFlags.NonPublic)
- }
-
public GetProperties (bindingAttr : BindingFlags) : list[IProperty]
{
def mems = get_members (bindingAttr, fun (x : IMember) {
@@ -1512,21 +1489,6 @@ public partial class TypeBuilder : TypeInfo
modifiers.custom_attrs += additional.GetCustomAttributes ();
}
-
- internal static constrain_member(m : IMember, flags : BindingFlags) : bool
- {
- def is_public = m.Attributes %&& NemerleModifiers.Public;
- // if flag is Public then always return all public members
- flags == BindingFlags.Public && is_public
- // if flag is NonPublic then always return all nonpublic members
- || flags == BindingFlags.NonPublic && !is_public
- // masks
- || (!m.IsStatic || flags %&& BindingFlags.Static)
- && (m.IsStatic || flags %&& BindingFlags.Instance)
- && (!is_public || flags %&& BindingFlags.Public)
- && (is_public || flags %&& BindingFlags.NonPublic)
- }
-
/** Note that [bindingAttr] is used only to check the case for DeclaredOnly
members, so you have to provide filter function to check other flags */
private get_members (bindingAttr : BindingFlags, filter : IMember -> bool) : list[IMember]
View
38 ncc/hierarchy/TypeInfo.n
@@ -34,6 +34,8 @@ using Nemerle.Imperative;
using Nemerle.Collections;
using Nemerle.Utility;
+using SCG = System.Collections.Generic;
+
namespace Nemerle.Compiler
{
@@ -311,7 +313,6 @@ public abstract class TypeInfo : MemberInfo, IMember,
protected set { code = value }
}
-
public NamespaceNode : NamespaceTree.Node
{
get { namespace_nd }
@@ -346,6 +347,41 @@ public abstract class TypeInfo : MemberInfo, IMember,
}
}
+ /// Searches for the types defined for the current TypeInfo, using the
+ /// specified BindingFlags.
+ public GetNestedTypes (bindingAttr : BindingFlags) : list[TypeInfo]
+ {
+ def attr = bindingAttr | BindingFlags.Static | BindingFlags.Instance;
+ def result = SCG.List();
+
+ when (NamespaceNode.Children != null)
+ foreach (x in NamespaceNode.Children.Values)
+ when (x.LookupValue() is Some(t))
+ when (constrain_member(t, attr))
+ result.Add(t);
+
+ result.NToList()
+ }
+
+ public GetNestedTypes () : list[TypeInfo]
+ {
+ GetNestedTypes (BindingFlags.Static %| BindingFlags.Instance %| BindingFlags.Public %| BindingFlags.NonPublic)
+ }
+
+ internal static constrain_member(m : IMember, flags : BindingFlags) : bool
+ {
+ def is_public = m.Attributes %&& NemerleModifiers.Public;
+ // if flag is Public then always return all public members
+ flags == BindingFlags.Public && is_public
+ // if flag is NonPublic then always return all nonpublic members
+ || flags == BindingFlags.NonPublic && !is_public
+ // masks
+ || (!m.IsStatic || flags %&& BindingFlags.Static)
+ && (m.IsStatic || flags %&& BindingFlags.Instance)
+ && (!is_public || flags %&& BindingFlags.Public)
+ && (is_public || flags %&& BindingFlags.NonPublic)
+ }
+
#region Builtins
protected mutable special_members : Hashtable [string, list [IMember]];
protected MakeSingleParm (name : string) : void
Please sign in to comment.
Something went wrong with that request. Please try again.