本文整理汇总了C#中Resolver.Visit方法的典型用法代码示例。如果您正苦于以下问题:C# Resolver.Visit方法的具体用法?C# Resolver.Visit怎么用?C# Resolver.Visit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Resolver
的用法示例。
在下文中一共展示了Resolver.Visit方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CompileParseTree
public override Node CompileParseTree(Node node, Scope scope, Module targetModule, ErrorNodeList errorNodes){
TrivialHashtable ambiguousTypes = new TrivialHashtable();
TrivialHashtable referencedLabels = new TrivialHashtable();
TrivialHashtable scopeFor = new TrivialHashtable();
ErrorHandler errorHandler = new ErrorHandler(errorNodes);
SpecSharpCompilation ssCompilation = new SpecSharpCompilation();
// Setting the state
TypeNode thisType = null;
Method currentMethod = null;
BlockScope blockScope = scope as BlockScope;
if (blockScope != null){
Class baseScope = blockScope;
MethodScope methodScope = null;
while (baseScope != null){
methodScope = baseScope.BaseClass as MethodScope;
if (methodScope != null) break;
baseScope = baseScope.BaseClass;
}
if (methodScope != null){
thisType = methodScope.ThisType;
if (thisType == null && methodScope.BaseClass is TypeScope){
thisType = ((TypeScope) methodScope.BaseClass).Type;
}
currentMethod = methodScope.DeclaringMethod;
}
}
//Attach scope to namespaces and types
scopeFor[node.UniqueKey] = scope;
Scoper scoper = new Scoper(scopeFor);
scoper.currentScope = scope;
node = scoper.Visit(node);
//Walk IR looking up names
Looker looker = new Looker(scope, errorHandler, scopeFor, ambiguousTypes, referencedLabels);
// begin change by drunje (this is called from debugger only)
looker.AllowPointersToManagedStructures = true;
// end change by drunje
if (blockScope != null)
{
looker.currentType = thisType;
looker.currentMethod = currentMethod;
}
looker.currentAssembly = targetModule as AssemblyNode;
looker.currentModule = targetModule;
node = looker.Visit(node);
//Walk IR inferring types and resolving overloads
TypeSystem typeSystem = new TypeSystem(errorHandler);
Resolver resolver = new Resolver(errorHandler, typeSystem);
if (blockScope != null){
resolver.currentType = thisType;
resolver.currentMethod = currentMethod;
}
resolver.currentAssembly = targetModule as AssemblyNode;
resolver.currentModule = targetModule;
node = resolver.Visit(node);
//TODO: Need to set the state of the checker for compiling Expression, STOP using this method when the shift is complete
//Walk IR checking for semantic errors and repairing it so that the next walk will work
Checker checker = new Checker(ssCompilation, errorHandler, typeSystem, scopeFor, ambiguousTypes, referencedLabels);
if (blockScope != null){
checker.currentType = thisType;
checker.currentMethod = currentMethod;
}
checker.currentAssembly = targetModule as AssemblyNode;
checker.currentModule = targetModule;
node = checker.Visit(node);
//Walk IR reducing it to nodes that have predefined mappings to MD+IL
Normalizer normalizer = new Normalizer(typeSystem);
if (blockScope != null){
normalizer.currentType = thisType;
normalizer.currentMethod = currentMethod;
normalizer.WrapToBlockExpression = false;
}
normalizer.currentModule = targetModule;
node = normalizer.Visit(node);
return node;
}
示例2: Resolve
public override void Resolve(Member unresolvedMember, Member resolvedMember){
if (unresolvedMember == null || resolvedMember == null) return;
if (this.scopeFor == null) return;
ErrorHandler errorHandler = new ErrorHandler(new ErrorNodeList(0));
TrivialHashtable ambiguousTypes = new TrivialHashtable();
TrivialHashtable referencedLabels = new TrivialHashtable();
Looker looker = new Looker(null, errorHandler, this.scopeFor, ambiguousTypes, referencedLabels);
looker.currentAssembly = (looker.currentModule = this.currentSymbolTable) as AssemblyNode;
TypeNode currentType = resolvedMember.DeclaringType;
if (resolvedMember is TypeNode && unresolvedMember.DeclaringType != null &&
((TypeNode)resolvedMember).FullName == unresolvedMember.DeclaringType.FullName){
unresolvedMember.DeclaringType = (TypeNode)resolvedMember;
currentType = (TypeNode)resolvedMember;
looker.scope = this.scopeFor[resolvedMember.UniqueKey] as Scope;
}else if (unresolvedMember is TypeNode && resolvedMember.DeclaringType != null){
if (((TypeNode)unresolvedMember).FullName != resolvedMember.DeclaringType.FullName) return; //Too many changes since last time entire file was compiled
resolvedMember = resolvedMember.DeclaringType;
currentType = resolvedMember.DeclaringType;
Scope scope = this.scopeFor[resolvedMember.UniqueKey] as Scope;
if (scope != null) this.scopeFor[unresolvedMember.UniqueKey] = scope;
looker.scope = scope;
}else if (resolvedMember.DeclaringType != null){
unresolvedMember.DeclaringType = resolvedMember.DeclaringType;
looker.scope = this.scopeFor[resolvedMember.DeclaringType.UniqueKey] as Scope;
if (looker.scope == null && resolvedMember.DeclaringType.IsDefinedBy != null && resolvedMember.DeclaringType.IsDefinedBy.Count > 0)
looker.scope = this.GetScopeFromPartialType(resolvedMember.DeclaringType, resolvedMember);
Scope scope = this.scopeFor[resolvedMember.UniqueKey] as Scope;
if (scope != null) this.scopeFor[unresolvedMember.UniqueKey] = scope;
}else if (resolvedMember.DeclaringNamespace != null){
unresolvedMember.DeclaringNamespace = resolvedMember.DeclaringNamespace;
looker.scope = this.scopeFor[resolvedMember.DeclaringNamespace.UniqueKey] as Scope;
Scope scope = this.scopeFor[resolvedMember.UniqueKey] as Scope;
if (scope != null) this.scopeFor[unresolvedMember.UniqueKey] = scope;
}
if (looker.scope == null) return;
looker.currentType = currentType;
looker.identifierInfos = this.identifierInfos = new NodeList();
looker.identifierPositions = this.identifierPositions = new Int32List();
looker.identifierLengths = this.identifierLengths = new Int32List();
looker.identifierContexts = this.identifierContexts = new Int32List();
looker.identifierScopes = this.identifierScopes = new ScopeList();
looker.allScopes = this.allScopes = new ScopeList();
looker.Visit(unresolvedMember);
//Walk IR inferring types and resolving overloads
Resolver resolver = new Resolver(errorHandler, new TypeSystem(errorHandler));
resolver.currentAssembly = (resolver.currentModule = this.currentSymbolTable) as AssemblyNode;
resolver.currentType = currentType;
if (currentType != null){
if (resolver.currentType.Template == null && resolver.currentType.ConsolidatedTemplateParameters != null && resolver.currentType.ConsolidatedTemplateParameters.Count > 0)
resolver.currentTypeInstance = resolver.GetDummyInstance(resolver.currentType);
else
resolver.currentTypeInstance = resolver.currentType;
}
resolver.Visit(unresolvedMember);
}
示例3: GetAuthoringScopeForMethodBody
public override Cci.AuthoringScope GetAuthoringScopeForMethodBody(string text, Compilation/*!*/ compilation, Method/*!*/ method, AuthoringSink asink) {
this.parsingStatement = true;
if (text == null || compilation == null || method == null || method.Body == null || method.Body.SourceContext.Document == null)
throw new ArgumentNullException();
if (compilation != null && compilation.CompilerParameters is SpecSharpCompilerOptions)
this.allowSpecSharpExtensions = !((SpecSharpCompilerOptions)compilation.CompilerParameters).Compatibility;
this.currentSymbolTable = compilation.TargetModule;
SourceContext sctx = method.Body.SourceContext;
DocumentText docText = new DocumentText(text);
Document doc = Compiler.CreateSpecSharpDocument(sctx.Document.Name, 1, docText);
ErrorNodeList errors = new ErrorNodeList(0);
Parser p = new Parser(doc, errors, compilation.TargetModule, compilation.CompilerParameters as SpecSharpCompilerOptions);
p.ParseMethodBody(method, sctx.StartPos, asink);
ErrorHandler errorHandler = new ErrorHandler(errors);
TrivialHashtable ambiguousTypes = new TrivialHashtable();
TrivialHashtable referencedLabels = new TrivialHashtable();
Looker looker = new Looker(null, errorHandler, this.scopeFor, ambiguousTypes, referencedLabels);
looker.currentAssembly = (looker.currentModule = compilation.TargetModule) as AssemblyNode;
TypeNode currentType = method.DeclaringType;
looker.currentType = currentType;
looker.scope = method.Scope;
if (looker.scope != null) looker.scope = looker.scope.OuterScope;
looker.identifierInfos = this.identifierInfos = new NodeList();
looker.identifierPositions = this.identifierPositions = new Int32List();
looker.identifierLengths = this.identifierLengths = new Int32List();
looker.identifierContexts = this.identifierContexts = new Int32List();
looker.identifierScopes = this.identifierScopes = new ScopeList();
looker.allScopes = this.allScopes = new ScopeList();
looker.Visit(method);
Resolver resolver = new Resolver(errorHandler, new TypeSystem(errorHandler));
resolver.currentAssembly = (resolver.currentModule = this.currentSymbolTable) as AssemblyNode;
resolver.currentType = currentType;
if (currentType != null) {
if (resolver.currentType.Template == null && resolver.currentType.ConsolidatedTemplateParameters != null && resolver.currentType.ConsolidatedTemplateParameters.Count > 0)
resolver.currentTypeInstance = resolver.GetDummyInstance(resolver.currentType);
else
resolver.currentTypeInstance = resolver.currentType;
}
resolver.Visit(method);
method.Body.Statements = null;
return this.GetAuthoringScope();
}