本文整理汇总了C#中Analyzer.IsThisCodeUnreachable方法的典型用法代码示例。如果您正苦于以下问题:C# Analyzer.IsThisCodeUnreachable方法的具体用法?C# Analyzer.IsThisCodeUnreachable怎么用?C# Analyzer.IsThisCodeUnreachable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Analyzer
的用法示例。
在下文中一共展示了Analyzer.IsThisCodeUnreachable方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Analyze
/// <include file='Doc/Nodes.xml' path='doc/method[@name="Statement.Analyze"]/*'/>
internal override Statement Analyze(Analyzer/*!*/ analyzer)
{
if (analyzer.IsThisCodeUnreachable())
{
analyzer.ReportUnreachableCode(position);
return EmptyStmt.Unreachable;
}
ExInfoFromParent info = ExInfoFromParent.DefaultExInfo;
for (int i = 0; i < parameters.Count; i++)
{
parameters[i] = parameters[i].Analyze(analyzer, info).Literalize();
}
return this;
}
示例2: Analyze
/// <include file='Doc/Nodes.xml' path='doc/method[@name="Statement.Analyze"]/*'/>
internal override Statement Analyze(Analyzer/*!*/ analyzer)
{
if (analyzer.IsThisCodeUnreachable())
{
analyzer.ReportUnreachableCode(position);
return EmptyStmt.Unreachable;
}
switchValue = switchValue.Analyze(analyzer, ExInfoFromParent.DefaultExInfo).Literalize();
analyzer.EnterSwitchBody();
foreach (SwitchItem item in switchItems)
item.Analyze(analyzer);
analyzer.LeaveSwitchBody();
return this;
}
示例3: Analyze
/// <include file='Doc/Nodes.xml' path='doc/method[@name="Statement.Analyze"]/*'/>
internal override Statement/*!*/ Analyze(Analyzer/*!*/ analyzer)
{
if (analyzer.IsThisCodeUnreachable())
{
analyzer.ReportUnreachableCode(position);
return EmptyStmt.Unreachable;
}
if (expr != null)
{
ExInfoFromParent sinfo = ExInfoFromParent.DefaultExInfo;
if (type == Types.Return
&& analyzer.CurrentRoutine != null && analyzer.CurrentRoutine.Signature.AliasReturn
&& expr is VarLikeConstructUse)
{
sinfo.Access = AccessType.ReadRef;
}
expr = expr.Analyze(analyzer, sinfo).Literalize();
if (type != Types.Return && expr.HasValue)
{
int level = Convert.ObjectToInteger(expr.Value);
if (level > analyzer.LoopNestingLevel || level < 0)
{
analyzer.ErrorSink.Add(Errors.InvalidBreakLevelCount, analyzer.SourceUnit, position, level);
}
}
}
else if (type != Types.Return && analyzer.LoopNestingLevel == 0)
{
analyzer.ErrorSink.Add(Errors.InvalidBreakLevelCount, analyzer.SourceUnit, position, 1);
}
// code in the same block after return, break, continue is unreachable
analyzer.EnterUnreachableCode();
return this;
}
示例4: Analyze
/// <include file='Doc/Nodes.xml' path='doc/method[@name="Statement.Analyze"]/*'/>
internal override Statement Analyze(Analyzer/*!*/ analyzer)
{
if (analyzer.IsThisCodeUnreachable())
{
analyzer.ReportUnreachableCode(position);
return EmptyStmt.Unreachable;
}
foreach (StaticVarDecl svd in stVarList)
svd.Analyze(analyzer);
return this;
}
示例5: Analyze
/// <include file='Doc/Nodes.xml' path='doc/method[@name="Statement.Analyze"]/*'/>
internal override Statement/*!*/ Analyze(Analyzer/*!*/ analyzer)
{
// functions in incomplete (not emitted) class can't be emitted
function.Declaration.IsInsideIncompleteClass = analyzer.IsInsideIncompleteClass();
attributes.Analyze(analyzer, this);
// function is analyzed even if it is unreachable in order to discover more errors at compile-time:
function.Declaration.IsUnreachable = analyzer.IsThisCodeUnreachable();
if (function.Declaration.IsUnreachable)
analyzer.ReportUnreachableCode(position);
analyzer.EnterFunctionDeclaration(function);
typeSignature.Analyze(analyzer);
signature.Analyze(analyzer);
function.Validate(analyzer.ErrorSink);
this.Body.Analyze(analyzer);
// validate function and its body:
function.ValidateBody(analyzer.ErrorSink);
/*
if (docComment != null)
AnalyzeDocComment(analyzer);
*/
analyzer.LeaveFunctionDeclaration();
if (function.Declaration.IsUnreachable)
{
return EmptyStmt.Unreachable;
}
else
{
// add entry point if applicable:
analyzer.SetEntryPoint(function, position);
return this;
}
}
示例6: Analyze
/// <include file='Doc/Nodes.xml' path='doc/method[@name="Statement.Analyze"]/*'/>
internal override Statement Analyze(Analyzer/*!*/ analyzer)
{
// remove classes that has been merged to the aggregate from the further processing:
if (IsPartialMergeResiduum)
return EmptyStmt.PartialMergeResiduum;
// functions in incomplete (not emitted) class can't be emitted
type.Declaration.IsInsideIncompleteClass = analyzer.IsInsideIncompleteClass();
// the ClassDecl is fully analyzed even if it will be replaced in the AST by EvalEx
// and even if it is unreachable in order to discover all possible errors in compile-time
type.Declaration.IsUnreachable = analyzer.IsThisCodeUnreachable();
if (type.Declaration.IsUnreachable)
analyzer.ReportUnreachableCode(position);
attributes.Analyze(analyzer, this);
typeSignature.Analyze(analyzer);
analyzer.EnterTypeDecl(type);
foreach (var member in members)
{
member.EnterAnalyzer(analyzer);
member.Analyze(analyzer);
member.LeaveAnalyzer(analyzer);
}
analyzer.LeaveTypeDecl();
AnalyzeDocComments(analyzer);
// validate the type after all members has been analyzed and validated:
type.Validate(analyzer.ErrorSink);
if (type.Declaration.IsUnreachable)
{
// only a conditional declaration can be unreachable
// => not emiting the declaration is ok
return EmptyStmt.Unreachable;
}
else if (!type.IsComplete)
{
// mark all functions declared in incomplete class as 'non-compilable'
// convert incomplete class to an eval if applicable:
if (analyzer.SourceUnit.CompilationUnit.IsPure && analyzer.CurrentType == null &&
analyzer.CurrentRoutine == null)
{
// error, since there is no place for global code in pure mode:
analyzer.ErrorSink.Add(Errors.IncompleteClass, analyzer.SourceUnit, position, this.name);
return this;
}
if (analyzer.SourceUnit.CompilationUnit.IsTransient)
{
TransientCompilationUnit transient_unit = (TransientCompilationUnit)analyzer.SourceUnit.CompilationUnit;
// report an error only for synthetic evals as we are 100% sure that the class cannot be completed;
// note that a synthetic eval can be created even in transient code as some base types could be
// declared there conditionally:
if (transient_unit.EvalKind == EvalKinds.SyntheticEval)
{
analyzer.ErrorSink.Add(Errors.IncompleteClass, analyzer.SourceUnit, position, this.name);
return this;
}
}
// report the warning, incomplete_class
analyzer.ErrorSink.Add(Warnings.IncompleteClass, analyzer.SourceUnit, position, this.name);
this.typeDefinitionCode = analyzer.SourceUnit.GetSourceCode(entireDeclarationPosition);
//// we return an eval
//EvalEx evalEx = new EvalEx(
// entireDeclarationPosition, this.typeDefinitionCode,
// (this.Namespace != null && this.Namespace.QualifiedName.Namespaces.Length > 0) ? this.Namespace.QualifiedName : (QualifiedName?)null,
// this.validAliases);
//Statement stmt = new ExpressionStmt(entireDeclarationPosition, evalEx);
//// this annotation is for the duck-type generation - we need to know the original typedecl
//evalEx.Annotations.Set<TypeDecl>(this);
//return stmt;
// we emit eval
return this;
}
else
{
return this;
}
}