本文整理汇总了C#中LookupMode类的典型用法代码示例。如果您正苦于以下问题:C# LookupMode类的具体用法?C# LookupMode怎么用?C# LookupMode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LookupMode类属于命名空间,在下文中一共展示了LookupMode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LookupNamespaceOrType
public FullNamedExpression LookupNamespaceOrType(string name, int arity, LookupMode mode, Location loc)
{
var fne = ns.NS.LookupTypeOrNamespace (ns, name, arity, mode, loc);
if (fne != null)
return fne;
//
// Only extern aliases are allowed in this context
//
fne = ns.LookupExternAlias (name);
if (fne != null || ns.MemberName == null)
return fne;
var container_ns = ns.NS.Parent;
var mn = ns.MemberName.Left;
while (mn != null) {
fne = container_ns.LookupTypeOrNamespace (this, name, arity, mode, loc);
if (fne != null)
return fne;
mn = mn.Left;
container_ns = container_ns.Parent;
}
if (ns.Parent != null)
return ns.Parent.LookupNamespaceOrType (name, arity, mode, loc);
return null;
}
示例2: LookupType
public TypeSpec LookupType(IMemberContext ctx, string name, int arity, LookupMode mode, Location loc)
{
if (types == null)
return null;
TypeSpec best = null;
if (arity == 0 && cached_types.TryGetValue (name, out best)) {
if (best != null || mode != LookupMode.IgnoreAccessibility)
return best;
}
IList<TypeSpec> found;
if (!types.TryGetValue (name, out found))
return null;
foreach (var ts in found) {
if (ts.Arity == arity) {
if (best == null) {
if ((ts.Modifiers & Modifiers.INTERNAL) != 0 && !ts.MemberDefinition.IsInternalAsPublic (ctx.Module.DeclaringAssembly) && mode != LookupMode.IgnoreAccessibility)
continue;
best = ts;
continue;
}
if (best.MemberDefinition.IsImported && ts.MemberDefinition.IsImported) {
if (ts.Kind == MemberKind.MissingType)
continue;
if (best.Kind == MemberKind.MissingType) {
best = ts;
continue;
}
if (mode == LookupMode.Normal) {
ctx.Module.Compiler.Report.SymbolRelatedToPreviousError (best);
ctx.Module.Compiler.Report.SymbolRelatedToPreviousError (ts);
ctx.Module.Compiler.Report.Error (433, loc, "The imported type `{0}' is defined multiple times", ts.GetSignatureForError ());
}
break;
}
if (ts.Kind == MemberKind.MissingType)
continue;
if (best.MemberDefinition.IsImported)
best = ts;
if ((best.Modifiers & Modifiers.INTERNAL) != 0 && !best.MemberDefinition.IsInternalAsPublic (ctx.Module.DeclaringAssembly))
continue;
if (mode != LookupMode.Normal)
continue;
if (ts.MemberDefinition.IsImported) {
ctx.Module.Compiler.Report.SymbolRelatedToPreviousError (best);
ctx.Module.Compiler.Report.SymbolRelatedToPreviousError (ts);
}
ctx.Module.Compiler.Report.Warning (436, 2, loc,
"The type `{0}' conflicts with the imported type of same name'. Ignoring the imported type definition",
best.GetSignatureForError ());
}
//
// Lookup for the best candidate with the closest arity match
//
if (arity < 0) {
if (best == null) {
best = ts;
} else if (System.Math.Abs (ts.Arity + arity) < System.Math.Abs (best.Arity + arity)) {
best = ts;
}
}
}
// TODO MemberCache: Cache more
if (arity == 0 && mode == LookupMode.Normal)
cached_types.Add (name, best);
if (best != null) {
var dep = best.GetMissingDependencies ();
if (dep != null)
ImportedTypeDefinition.Error_MissingDependency (ctx, dep, loc);
}
return best;
}
示例3: Lookup
FullNamedExpression Lookup(string name, int arity, LookupMode mode, Location loc)
{
//
// Check whether it's in the namespace.
//
FullNamedExpression fne = ns.LookupTypeOrNamespace (this, name, arity, mode, loc);
//
// Check aliases.
//
if (aliases != null && arity == 0) {
UsingAliasNamespace uan;
if (aliases.TryGetValue (name, out uan)) {
if (fne != null && mode != LookupMode.Probing) {
// TODO: Namespace has broken location
//Report.SymbolRelatedToPreviousError (fne.Location, null);
Compiler.Report.SymbolRelatedToPreviousError (uan.Location, null);
Compiler.Report.Error (576, loc,
"Namespace `{0}' contains a definition with same name as alias `{1}'",
GetSignatureForError (), name);
}
if (uan.ResolvedExpression == null)
uan.Define (this);
return uan.ResolvedExpression;
}
}
if (fne != null)
return fne;
//
// Lookup can be called before the namespace is defined from different namespace using alias clause
//
if (namespace_using_table == null) {
DoDefineNamespace ();
}
//
// Check using entries.
//
FullNamedExpression match = null;
foreach (Namespace using_ns in namespace_using_table) {
//
// A using directive imports only types contained in the namespace, it
// does not import any nested namespaces
//
var t = using_ns.LookupType (this, name, arity, mode, loc);
if (t == null)
continue;
fne = new TypeExpression (t, loc);
if (match == null) {
match = fne;
continue;
}
// Prefer types over namespaces
var texpr_fne = fne as TypeExpr;
var texpr_match = match as TypeExpr;
if (texpr_fne != null && texpr_match == null) {
match = fne;
continue;
} else if (texpr_fne == null) {
continue;
}
// It can be top level accessibility only
var better = Namespace.IsImportedTypeOverride (Module, texpr_match.Type, texpr_fne.Type);
if (better == null) {
if (mode == LookupMode.Normal) {
Error_AmbiguousReference (name, texpr_match, texpr_fne, loc);
}
return match;
}
if (better == texpr_fne.Type)
match = texpr_fne;
}
if (types_using_table != null) {
foreach (var using_type in types_using_table) {
var members = MemberCache.FindMembers (using_type, name, true);
if (members == null)
continue;
foreach (var member in members) {
if (arity > 0 && member.Arity != arity)
continue;
if ((member.Kind & MemberKind.NestedMask) != 0) {
// non-static nested type is included with using static
} else {
if ((member.Modifiers & Modifiers.STATIC) == 0)
continue;
if ((member.Modifiers & Modifiers.METHOD_EXTENSION) != 0)
continue;
//.........这里部分代码省略.........
示例4: LookupNamespaceOrType
//
// Public function used to locate types.
//
// Set 'ignore_cs0104' to true if you want to ignore cs0104 errors.
//
// Returns: Type or null if they type can not be found.
//
public override FullNamedExpression LookupNamespaceOrType (string name, int arity, LookupMode mode, Location loc)
{
FullNamedExpression e;
if (arity == 0 && Cache.TryGetValue (name, out e) && mode != LookupMode.IgnoreAccessibility)
return e;
e = null;
if (arity == 0) {
var tp = CurrentTypeParameters;
if (tp != null) {
TypeParameter tparam = tp.Find (name);
if (tparam != null)
e = new TypeParameterExpr (tparam, Location.Null);
}
}
if (e == null) {
TypeSpec t = LookupNestedTypeInHierarchy (name, arity);
if (t != null && (t.IsAccessible (this) || mode == LookupMode.IgnoreAccessibility))
e = new TypeExpression (t, Location.Null);
else {
e = Parent.LookupNamespaceOrType (name, arity, mode, loc);
}
}
// TODO MemberCache: How to cache arity stuff ?
if (arity == 0 && mode == LookupMode.Normal)
Cache[name] = e;
return e;
}
示例5: Lookup
FullNamedExpression Lookup (string name, int arity, LookupMode mode, bool absolute_ns, Location loc)
{
//
// Check whether it's in the namespace.
//
FullNamedExpression fne;
// For PlayScript/ActionScript we only search for namespaces for simple names when we're at the top level namespace. ActionScript does not
// use relative package name resolution.
if (absolute_ns && this.MemberName != null && this.MemberName.Left != null)
fne = ns.LookupType (this, name, arity, mode, loc);
else
fne = ns.LookupTypeOrNamespace (this, name, arity, mode, loc);
//
// Check aliases.
//
if (aliases != null && arity == 0) {
UsingAliasNamespace uan;
if (aliases.TryGetValue (name, out uan)) {
if (fne != null) {
// TODO: Namespace has broken location
//Report.SymbolRelatedToPreviousError (fne.Location, null);
Compiler.Report.SymbolRelatedToPreviousError (uan.Location, null);
Compiler.Report.Error (576, loc,
"Namespace `{0}' contains a definition with same name as alias `{1}'",
GetSignatureForError (), name);
}
return uan.ResolvedExpression;
}
}
if (fne != null)
return fne;
//
// Lookup can be called before the namespace is defined from different namespace using alias clause
//
if (namespace_using_table == null) {
DoDefineNamespace ();
}
FullNamedExpression match = null;
//
// Check using types.
//
foreach (Tuple<TypeExpr,TypeSpec> using_type in type_using_table) {
var texpr = using_type.Item1;
var tspec = using_type.Item2;
if (tspec.Name == name && tspec.Arity == arity) {
match = texpr;
}
}
//
// Check using entries.
//
foreach (Namespace using_ns in namespace_using_table) {
//
// A using directive imports only types contained in the namespace, it
// does not import any nested namespaces
//
fne = using_ns.LookupType (this, name, arity, mode, loc);
if (fne == null)
continue;
if (match == null) {
match = fne;
continue;
}
// Prefer types over namespaces
var texpr_fne = fne as TypeExpr;
var texpr_match = match as TypeExpr;
if (texpr_fne != null && texpr_match == null) {
match = fne;
continue;
} else if (texpr_fne == null) {
continue;
}
// It can be top level accessibility only
var better = Namespace.IsImportedTypeOverride (Module, texpr_match.Type, texpr_fne.Type);
if (better == null) {
if (mode == LookupMode.Normal) {
Compiler.Report.SymbolRelatedToPreviousError (texpr_match.Type);
Compiler.Report.SymbolRelatedToPreviousError (texpr_fne.Type);
Compiler.Report.Error (104, loc, "`{0}' is an ambiguous reference between `{1}' and `{2}'",
name, texpr_match.GetSignatureForError (), texpr_fne.GetSignatureForError ());
}
return match;
}
if (better == texpr_fne.Type)
match = texpr_fne;
}
//.........这里部分代码省略.........
示例6: LookupNamespaceOrType
public FullNamedExpression LookupNamespaceOrType (string name, int arity, LookupMode mode, Location loc)
{
return MemberContext.LookupNamespaceOrType (name, arity, mode, loc);
}
示例7: LookupNamespaceOrType
public FullNamedExpression LookupNamespaceOrType (string name, int arity, LookupMode mode, Location loc)
{
if (arity == 0) {
var tp = CurrentTypeParameters;
if (tp != null) {
for (int i = 0; i < tp.Count; ++i) {
var t = tp[i];
if (t.Name == name) {
t.Type.DeclaredPosition = i;
return new TypeParameterExpr (t, loc);
}
}
}
}
return host.Parent.LookupNamespaceOrType (name, arity, mode, loc);
}
示例8: LookupNamespaceOrType
public override FullNamedExpression LookupNamespaceOrType (string name, int arity, LookupMode mode, bool absolute_ns, Location loc)
{
if (arity == 0) {
var tp = CurrentTypeParameters;
if (tp != null) {
TypeParameter t = tp.Find (name);
if (t != null)
return new TypeParameterExpr (t, loc);
}
}
return base.LookupNamespaceOrType (name, arity, mode, absolute_ns, loc);
}
示例9: LookupNamespaceOrType
public virtual FullNamedExpression LookupNamespaceOrType (string name, int arity, LookupMode mode, bool absolute_ns, Location loc)
{
if (Parent != null) {
return Parent.LookupNamespaceOrType (name, arity, mode, absolute_ns, loc);
} else {
return null;
}
}
示例10: Lookup
FullNamedExpression Lookup (string name, int arity, LookupMode mode, Location loc)
{
//
// Check whether it's in the namespace.
//
FullNamedExpression fne = ns.LookupTypeOrNamespace (this, name, arity, mode, loc);
//
// Check aliases.
//
if (using_aliases != null && arity == 0) {
foreach (NamespaceUsingAlias ue in using_aliases) {
if (ue.Alias == name) {
if (fne != null) {
if (Doppelganger != null) {
if (mode == LookupMode.Normal) {
// TODO: Namespace has broken location
//Report.SymbolRelatedToPreviousError (fne.Location, null);
Compiler.Report.SymbolRelatedToPreviousError (ue.Location, null);
Compiler.Report.Error (576, loc,
"Namespace `{0}' contains a definition with same name as alias `{1}'",
GetSignatureForError (), name);
}
} else {
return fne;
}
}
return ue.Resolve (Doppelganger ?? this, Doppelganger == null);
}
}
}
if (fne != null)
return fne;
if (IsImplicit)
return null;
//
// Check using entries.
//
FullNamedExpression match = null;
foreach (Namespace using_ns in GetUsingTable ()) {
// A using directive imports only types contained in the namespace, it
// does not import any nested namespaces
fne = using_ns.LookupType (this, name, arity, mode, loc);
if (fne == null)
continue;
if (match == null) {
match = fne;
continue;
}
// Prefer types over namespaces
var texpr_fne = fne as TypeExpr;
var texpr_match = match as TypeExpr;
if (texpr_fne != null && texpr_match == null) {
match = fne;
continue;
} else if (texpr_fne == null) {
continue;
}
// It can be top level accessibility only
var better = Namespace.IsImportedTypeOverride (module, texpr_match.Type, texpr_fne.Type);
if (better == null) {
if (mode == LookupMode.Normal) {
Compiler.Report.SymbolRelatedToPreviousError (texpr_match.Type);
Compiler.Report.SymbolRelatedToPreviousError (texpr_fne.Type);
Compiler.Report.Error (104, loc, "`{0}' is an ambiguous reference between `{1}' and `{2}'",
name, texpr_match.GetSignatureForError (), texpr_fne.GetSignatureForError ());
}
return match;
}
if (better == texpr_fne.Type)
match = texpr_fne;
}
return match;
}
示例11: LookupTypeOrNamespace
public FullNamedExpression LookupTypeOrNamespace(IMemberContext ctx, string name, int arity, LookupMode mode, Location loc)
{
var texpr = LookupType (ctx, name, arity, mode, loc);
Namespace ns;
if (arity == 0 && namespaces.TryGetValue (name, out ns)) {
if (texpr == null)
return new NamespaceExpression (ns, loc);
if (mode != LookupMode.Probing) {
//ctx.Module.Compiler.Report.SymbolRelatedToPreviousError (texpr.Type);
// ctx.Module.Compiler.Report.SymbolRelatedToPreviousError (ns.loc, "");
ctx.Module.Compiler.Report.Warning (437, 2, loc,
"The type `{0}' conflicts with the imported namespace `{1}'. Using the definition found in the source file",
texpr.GetSignatureForError (), ns.GetSignatureForError ());
}
if (texpr.MemberDefinition.IsImported)
return new NamespaceExpression (ns, loc);
}
if (texpr == null)
return null;
return new TypeExpression (texpr, loc);
}
示例12: LookupNamespaceOrType
public override FullNamedExpression LookupNamespaceOrType (string name, int arity, LookupMode mode, Location loc)
{
if (arity == 0) {
TypeParameter[] tp = CurrentTypeParameters;
if (tp != null) {
TypeParameter t = TypeParameter.FindTypeParameter (tp, name);
if (t != null)
return new TypeParameterExpr (t, loc);
}
}
return base.LookupNamespaceOrType (name, arity, mode, loc);
}
示例13: LookupNamespaceOrType
public FullNamedExpression LookupNamespaceOrType (string name, int arity, LookupMode mode, Location loc)
{
throw new NotImplementedException ();
}
示例14: LookupNamespaceOrType
public virtual FullNamedExpression LookupNamespaceOrType (string name, int arity, LookupMode mode, Location loc)
{
return Parent.LookupNamespaceOrType (name, arity, mode, loc);
}
示例15: LookupNamespaceOrType
//
// Public function used to locate types.
//
// Returns: Type or null if they type can not be found.
//
public override FullNamedExpression LookupNamespaceOrType (string name, int arity, LookupMode mode, Location loc)
{
FullNamedExpression e;
if (arity == 0 && Cache.TryGetValue (name, out e) && mode != LookupMode.IgnoreAccessibility)
return e;
e = null;
if (arity == 0) {
var tp = CurrentTypeParameters;
if (tp != null) {
TypeParameter tparam = tp.Find (name);
if (tparam != null)
e = new TypeParameterExpr (tparam, Location.Null);
}
}
if (e == null) {
TypeSpec t = LookupNestedTypeInHierarchy (name, arity);
if (t != null && (t.IsAccessible (this) || mode == LookupMode.IgnoreAccessibility))
e = new TypeExpression (t, Location.Null);
else {
var errors = Compiler.Report.Errors;
e = Parent.LookupNamespaceOrType (name, arity, mode, loc);
// TODO: LookupNamespaceOrType does more than just lookup. The result
// cannot be cached or the error reporting won't happen
if (errors != Compiler.Report.Errors)
return e;
}
}
// TODO MemberCache: How to cache arity stuff ?
if (arity == 0 && mode == LookupMode.Normal)
Cache[name] = e;
return e;
}