本文整理汇总了C#中ErrorNodeList类的典型用法代码示例。如果您正苦于以下问题:C# ErrorNodeList类的具体用法?C# ErrorNodeList怎么用?C# ErrorNodeList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ErrorNodeList类属于命名空间,在下文中一共展示了ErrorNodeList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ErrorHandler
Expression IContractDeserializer.ParseContract (MethodContract mc, string text, ErrorNodeList errs)
{
Expression expression = null;
currentMethodContract = mc;
currentMethod = null;
currentType = null;
if (mc != null){
currentMethod = mc.DeclaringMethod;
currentType = currentMethod.DeclaringType;
}
try{
Parser.ParseContract(this.assembly, text, out expression);
}catch (Exception e){
ErrorNodeList eList = errs != null ? errs : this.ErrorList;
if (eList != null){
#if OLDERRORS
ErrorHandler eh = new ErrorHandler(eList);
eh.HandleError(mc,System.Compiler.Error.GenericError,"Deserializer error: " + e.Message);
#else
this.assembly.MetadataImportErrors.Add(e);
#endif
}
throw e;
}
return expression;
}
示例2: CompileAssemblyFromDomBatch
public override CompilerResults CompileAssemblyFromDomBatch(CompilerParameters options, CodeCompileUnit[] compilationUnits, ErrorNodeList errorNodes)
{
if (options == null) { Debug.Assert(false); return null; }
this.Options = options;
int n = compilationUnits == null ? 0 : compilationUnits.Length;
if (options.OutputAssembly == null || options.OutputAssembly.Length == 0)
{
for (int i = 0; i < n; i++)
{
CodeSnippetCompileUnit csu = compilationUnits[i] as CodeSnippetCompileUnit;
if (csu == null || csu.LinePragma == null || csu.LinePragma.FileName == null) continue;
this.SetOutputFileName(options, csu.LinePragma.FileName);
break;
}
}
CompilerResults results = new CompilerResults(options.TempFiles);
AssemblyNode assem = this.CreateAssembly(options, errorNodes);
Compilation compilation = new Compilation(assem, new CompilationUnitList(n), options, this.GetGlobalScope(assem));
CodeDomTranslator cdt = new CodeDomTranslator();
SnippetParser sp = new SnippetParser(this, assem, errorNodes, options);
for (int i = 0; i < n; i++)
{
CompilationUnit cu = cdt.Translate(this, compilationUnits[i], assem, errorNodes);
sp.Visit(cu);
compilation.CompilationUnits.Add(cu);
cu.Compilation = compilation;
}
this.CompileParseTree(compilation, errorNodes);
this.ProcessErrors(options, results, errorNodes);
if (results.NativeCompilerReturnValue == 0)
this.SetEntryPoint(compilation, results);
// The following line is different from the base class method...
this.SaveOrLoadAssembly(this.targetModule as AssemblyNode, options, results, errorNodes);
return results;
}
示例3: Parse
//IDebugExpressionEvaluator
public HRESULT Parse(
[In,MarshalAs(UnmanagedType.LPWStr)]
string pszExpression,
PARSEFLAGS flags,
uint radix,
out string pbstrErrorMessages,
out uint perrorCount,
out IDebugParsedExpression ppparsedExpression
)
{
HRESULT hr = (HRESULT)HResult.S_OK;
perrorCount = 0;
pbstrErrorMessages = null;
ppparsedExpression = null;
ErrorNodeList errors = new ErrorNodeList();
Module symbolTable = new Module();
Document doc = this.cciEvaluator.ExprCompiler.CreateDocument(null, 1, pszExpression);
IParser exprParser = this.cciEvaluator.ExprCompiler.CreateParser(doc.Name, doc.LineNumber, doc.Text, symbolTable, errors, null);
Expression parsedExpression = exprParser.ParseExpression();
perrorCount = (uint)errors.Count;
if (perrorCount > 0)
pbstrErrorMessages = errors[0].GetMessage();
else
ppparsedExpression = new BaseParsedExpression(pszExpression, parsedExpression, this);
return hr;
}
示例4: Init
private void Init(){
ErrorNodeList tempErrors = new ErrorNodeList();
ErrorHandler tempErrorHandler = new ErrorHandler(tempErrors);
tempTypeSystem = new TypeSystem(tempErrorHandler);
// Here we ignore the errors generated by this temporary checker on purpose!
tempChecker = new Checker(tempErrorHandler, tempTypeSystem, null, null, null);
if (errorHandler == null) {
errors = new ErrorNodeList();
errorHandler = new ErrorHandler(errors);
}
}
示例5: Translate
/// <summary>
/// Walks the supplied System.CodeDom.CodeCompileUnit and produces a corresponding CompilationUnit.
/// Enters declarations into the supplied Module and errors into the supplied ErrorNodeList.
/// Calls back to the supplied compiler to resolve assembly references and to create appropriate documents for code snippets.
/// </summary>
/// <param name="compiler">Called upon to resolve assembly references and to create Documents for snippets.</param>
/// <param name="compilationUnit">The root of the CodeDOM tree to be translated into an IR CompileUnit.</param>
/// <param name="targetModule">The module or assembly to which the compilation unit will be compiled.</param>
/// <param name="errorNodes">Errors in the CodeDOM tree that are found during translation are added to this list.</param>
/// <returns></returns>
public CompilationUnit Translate(Compiler compiler, CodeCompileUnit compilationUnit, Module targetModule, ErrorNodeList errorNodes){
Debug.Assert(compiler != null);
Debug.Assert(compilationUnit != null);
Debug.Assert(targetModule != null);
Debug.Assert(errorNodes != null);
this.compiler = compiler;
this.errorNodes = errorNodes;
this.targetModule = targetModule;
CodeSnippetCompileUnit cscu = compilationUnit as CodeSnippetCompileUnit;
CompilationUnit cunit = cscu != null ? new CompilationUnitSnippet() : new CompilationUnit();
this.Translate(compilationUnit.AssemblyCustomAttributes, targetModule.Attributes);
StringCollection references = compilationUnit.ReferencedAssemblies;
if (references != null && references.Count > 0){
AssemblyReferenceList arefs = targetModule.AssemblyReferences;
TrivialHashtable alreadyReferencedAssemblies = new TrivialHashtable();
for (int i = 0, n = arefs.Count; i < n; i++)
alreadyReferencedAssemblies[arefs[i].Assembly.UniqueKey] = this;
foreach (string rAssemblyName in references)
compiler.AddAssemblyReferenceToModule(null, targetModule, rAssemblyName, null, errorNodes, alreadyReferencedAssemblies, false);
}
Namespace defaultNamespace = new Namespace(Identifier.Empty, Identifier.Empty, null, null, new NamespaceList(), null);
NamespaceList nspaceList = defaultNamespace.NestedNamespaces;
CodeNamespaceCollection nspaces = compilationUnit.Namespaces;
if (nspaces != null)
foreach (CodeNamespace cns in nspaces)
nspaceList.Add(this.Translate(cns));
if (cscu == null) return cunit;
Document doc = null;
if (cscu.LinePragma == null)
doc = compiler.CreateDocument(targetModule.Name, 1, cscu.Value);
else{
doc = compiler.CreateDocument(cscu.LinePragma.FileName, cscu.LinePragma.LineNumber, cscu.Value);
cunit.Name = Identifier.For(cscu.LinePragma.FileName);
}
cunit.SourceContext = new SourceContext(doc);
defaultNamespace.SourceContext = cunit.SourceContext;
return cunit;
}
示例6: CreateParser
public IParser CreateParser(string fileName, int lineNumber, DocumentText text, Module symbolTable, ErrorNodeList errorNodes, CompilerParameters options){
return new XamlParserStub(errorNodes, options as CompilerOptions);
}
示例7: Parser
public Parser(Document document, ErrorNodeList errors, Module symbolTable, SpecSharpCompilerOptions options){
this.scanner = new Scanner(document, errors, options);
this.ProcessOptions(options);
this.errors = errors;
this.module = symbolTable;
}
示例8: ConstructSymbolTable
public virtual void ConstructSymbolTable(Compilation compilation, ErrorNodeList errors, TrivialHashtable scopeFor){
if (compilation == null || scopeFor == null){Debug.Assert(false); return;}
this.CurrentCompilation = compilation;
Module symbolTable = compilation.TargetModule = this.CreateModule(compilation.CompilerParameters, errors, compilation);
Scoper scoper = new Scoper(scopeFor);
scoper.currentModule = symbolTable;
ErrorHandler errorHandler = new ErrorHandler(errors);
Looker looker = new Looker(this.GetGlobalScope(symbolTable), errorHandler, scopeFor);
// begin change by drunje
SpecSharpCompilerOptions options = compilation.CompilerParameters as SpecSharpCompilerOptions;
if (options != null)
looker.AllowPointersToManagedStructures = options.AllowPointersToManagedStructures;
// end change by drunje
looker.currentAssembly = (looker.currentModule = symbolTable) as AssemblyNode;
looker.ignoreMethodBodies = true;
Scope globalScope = compilation.GlobalScope = this.GetGlobalScope(symbolTable);
CompilationUnitList sources = compilation.CompilationUnits;
if (sources == null) return;
int n = sources.Count;
for (int i = 0; i < n; i++){
CompilationUnitSnippet compilationUnitSnippet = sources[i] as CompilationUnitSnippet;
if (compilationUnitSnippet == null){Debug.Assert(false); continue;}
compilationUnitSnippet.ChangedMethod = null;
Document doc = compilationUnitSnippet.SourceContext.Document;
if (doc == null || doc.Text == null){Debug.Assert(false); continue;}
IParserFactory factory = compilationUnitSnippet.ParserFactory;
if (factory == null){Debug.Assert(false); return;}
IParser p = factory.CreateParser(doc.Name, doc.LineNumber, doc.Text, symbolTable, errors, compilation.CompilerParameters);
if (p is ResgenCompilerStub) continue;
if (p == null){Debug.Assert(false); continue;}
Parser specSharpParser = p as Parser;
if (specSharpParser == null)
p.ParseCompilationUnit(compilationUnitSnippet);
else
specSharpParser.ParseCompilationUnit(compilationUnitSnippet, true, false);
//TODO: this following is a good idea only if the files will not be frequently reparsed from source
//StringSourceText stringSourceText = doc.Text.TextProvider as StringSourceText;
//if (stringSourceText != null && stringSourceText.IsSameAsFileContents)
// doc.Text.TextProvider = new CollectibleSourceText(doc.Name, doc.Text.Length);
//else if (doc.Text.TextProvider != null)
// doc.Text.TextProvider.MakeCollectible();
}
CompilationUnitList compilationUnits = new CompilationUnitList();
for (int i = 0; i < n; i++){
CompilationUnit cUnit = sources[i];
compilationUnits.Add(scoper.VisitCompilationUnit(cUnit));
}
for (int i = 0; i < n; i++){
CompilationUnit cUnit = compilationUnits[i];
if (cUnit == null) continue;
looker.VisitCompilationUnit(cUnit);
}
//Run resolver over symbol table so that custom attributes on member signatures are known and can be used
//to error check the the given file.
TypeSystem typeSystem = new TypeSystem(errorHandler);
Resolver resolver = new Resolver(errorHandler, typeSystem);
resolver.currentAssembly = (resolver.currentModule = symbolTable) as AssemblyNode;
for (int i = 0; i < n; i++) {
CompilationUnit cUnit = compilationUnits[i];
if (cUnit == null) continue;
resolver.VisitCompilationUnit(cUnit);
}
this.CurrentCompilation = null;
}
示例9: ParseAndAnalyzeCompilationUnit
public abstract void ParseAndAnalyzeCompilationUnit(string fname, string source, int line, int col, ErrorNodeList errors, Compilation compilation, AuthoringSink sink);
示例10: ReportErrors
public virtual void ReportErrors(string fileName, ErrorNodeList errors, AuthoringSink sink){
if (sink == null) return;
for (int n = errors.Count, i = n-1; i >= 0; i--){ //Scan backwards so that early errors trump later errors
ErrorNode enode = errors[i];
if (enode == null || enode.Severity < 0) continue;
//TODO: suppress warnings of level > set in options
SourceContext context = enode.SourceContext;
if (context.Document == null) continue;
if (context.Document.Name != fileName) continue;
sink.AddError(enode);
}
}
示例11: ParseSource
public AuthoringScope ParseSource(string text, int line, int col, string fname, AuthoringSink asink, ParseReason reason){
this.currentAst = null;
Compilation compilation = this.GetCompilationFor(fname);
Debug.Assert(compilation != null, "no compilation for: "+fname);
this.currentSymbolTable = compilation.TargetModule;
switch (reason){
case ParseReason.CollapsibleRegions:
case ParseReason.CompleteWord:
case ParseReason.MatchBraces:
case ParseReason.HighlightBraces:
case ParseReason.MemberSelect:
case ParseReason.MemberSelectExplicit:
case ParseReason.MethodTip:
case ParseReason.QuickInfo:
case ParseReason.Autos:{
return this.ParsePartialCompilationUnit(fname, text, line, col, asink, reason);
}
case ParseReason.Check:{
ErrorNodeList errors = new ErrorNodeList();
this.ParseAndAnalyzeCompilationUnit(fname, text, line, col, errors, compilation, asink);
this.ReportErrors(fname, errors, asink);
return this.GetAuthoringScope();
}
}
return null;
}
示例12: SaveCompilation
protected override void SaveCompilation(Compilation compilation, AssemblyNode assem, CompilerParameters options, CompilerResults results, ErrorNodeList errorNodes) {
CompilerOptions ccioptions = options as CompilerOptions;
if (ccioptions != null && ccioptions.EmitSourceContextsOnly) {
SourceContextWriter.Write(compilation, assem, options);
if (ccioptions.XMLDocFileName != null && ccioptions.XMLDocFileName.Length > 0)
assem.WriteDocumentation(new StreamWriter(ccioptions.XMLDocFileName));
}
else{
base.SaveCompilation (compilation, assem, options, results, errorNodes);
}
}
示例13: ResolveSymbolTable
public virtual void ResolveSymbolTable(Compilation/*!*/ parsedCompilation, ErrorNodeList/*!*/ errors, out TrivialHashtable scopeFor){
scopeFor = new TrivialHashtable();
if (parsedCompilation == null) { Debug.Assert(false); return; }
if (errors == null){Debug.Assert(false); return;}
Scoper scoper = new Scoper(scopeFor);
scoper.currentModule = parsedCompilation.TargetModule;
scoper.VisitCompilation(parsedCompilation);
ErrorHandler errorHandler = new ErrorHandler(errors);
TrivialHashtable ambiguousTypes = new TrivialHashtable();
TrivialHashtable referencedLabels = new TrivialHashtable();
Looker looker = new Looker(null, errorHandler, scopeFor, ambiguousTypes, referencedLabels);
// begin change by drunje
SpecSharpCompilerOptions options = parsedCompilation.CompilerParameters as SpecSharpCompilerOptions;
if (options != null)
looker.AllowPointersToManagedStructures = options.AllowPointersToManagedStructures;
// end change by drunje
looker.currentAssembly = (looker.currentModule = parsedCompilation.TargetModule) as AssemblyNode;
looker.VisitCompilation(parsedCompilation);
}
示例14: ProcessErrors
public override void ProcessErrors(CompilerParameters options, CompilerResults results, ErrorNodeList errorNodes)
{
if(errorNodes != null &&
(options is SpecSharpCompilerOptions &&
((SpecSharpCompilerOptions)options).RunProgramVerifier))
errorNodes.Sort(0, errorNodes.Count); // sort the Boogie errors to make test deterministic
base.ProcessErrors(options, results, errorNodes);
}
示例15: XamlParserStub
public XamlParserStub(ErrorNodeList errorNodes, CompilerOptions options){
this.errorNodes = errorNodes;
this.options = options;
}