本文整理汇总了C#中LookupMode类的典型用法代码示例。如果您正苦于以下问题:C# LookupMode类的具体用法?C# LookupMode怎么用?C# LookupMode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LookupMode类属于命名空间,在下文中一共展示了LookupMode类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:exodrifter,项目名称:mcs-ICodeCompiler,代码行数:29,代码来源:namespace.cs
示例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;
}
开发者ID:exodrifter,项目名称:mcs-ICodeCompiler,代码行数:89,代码来源:namespace.cs
示例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;
//.........这里部分代码省略.........
开发者ID:exodrifter,项目名称:mcs-ICodeCompiler,代码行数:101,代码来源:namespace.cs
示例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;
}
开发者ID:fvalette,项目名称:mono,代码行数:40,代码来源:class.cs
示例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;
}
//.........这里部分代码省略.........
开发者ID:johnv315,项目名称:playscript-mono,代码行数:101,代码来源:namespace.cs
示例6: LookupNamespaceOrType
public FullNamedExpression LookupNamespaceOrType (string name, int arity, LookupMode mode, Location loc)
{
return MemberContext.LookupNamespaceOrType (name, arity, mode, loc);
}
开发者ID:KAW0,项目名称:Alter-Native,代码行数:4,代码来源:context.cs
示例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);
}
开发者ID:KAW0,项目名称:Alter-Native,代码行数:17,代码来源:doc.cs
示例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);
}
开发者ID:rlfqudxo,项目名称:playscript-mono,代码行数:13,代码来源:method.cs
示例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;
}
}
开发者ID:johnv315,项目名称:playscript-mono,代码行数:8,代码来源:decl.cs
示例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;
}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:84,代码来源:namespace.cs
示例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);
}
开发者ID:exodrifter,项目名称:mcs-ICodeCompiler,代码行数:26,代码来源:namespace.cs
示例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);
}
开发者ID:crazyjncsu,项目名称:mono,代码行数:13,代码来源:method.cs
示例13: LookupNamespaceOrType
public FullNamedExpression LookupNamespaceOrType (string name, int arity, LookupMode mode, Location loc)
{
throw new NotImplementedException ();
}
开发者ID:jordanbtucker,项目名称:mono,代码行数:4,代码来源:pending.cs
示例14: LookupNamespaceOrType
public virtual FullNamedExpression LookupNamespaceOrType (string name, int arity, LookupMode mode, Location loc)
{
return Parent.LookupNamespaceOrType (name, arity, mode, loc);
}
开发者ID:johnluetke,项目名称:mono,代码行数:4,代码来源:decl.cs
示例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;
}
开发者ID:0xd4d,项目名称:NRefactory,代码行数:44,代码来源:class.cs
示例16: 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);
}
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) {
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;
}
开发者ID:GirlD,项目名称:mono,代码行数:84,代码来源:namespace.cs
示例17: LookupNamespaceOrType
public override FullNamedExpression LookupNamespaceOrType (string name, int arity, LookupMode mode, bool absolute_ns, Location loc)
{
//
// Only simple names (no dots) will be looked up with this function
//
FullNamedExpression resolved;
for (NamespaceContainer container = this; container != null; container = container.Parent) {
resolved = container.Lookup (name, arity, mode, absolute_ns, loc);
if (resolved != null || container.MemberName == null)
return resolved;
var container_ns = container.ns.Parent;
var mn = container.MemberName.Left;
while (mn != null) {
// If PlayScript/ActionScript we need to avoid lookup up the first identifier in a namespace relatively. This means we only
// do namespace lookup for the first identifier from the global namespace.
if (absolute_ns)
resolved = container_ns.LookupType (this, name, arity, mode, loc);
else
resolved = container_ns.LookupTypeOrNamespace (this, name, arity, mode, loc);
if (resolved != null)
return resolved;
mn = mn.Left;
container_ns = container_ns.Parent;
}
}
return null;
}
开发者ID:johnv315,项目名称:playscript-mono,代码行数:30,代码来源:namespace.cs
注:本文中的LookupMode类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论