public override bool Equals(object obj) { if (this == obj) { return(true); } ISwitchStatement statement = obj as ISwitchStatement; if (statement == null || (!Expression.Equals(statement.Expression)) || Cases.Count != statement.Cases.Count) { return(false); } for (int i = 0; i < Cases.Count; i++) { if (!(Cases[i].Equals(statement.Cases[i]))) { return(false); } } return(true); }
public override void Visit(ISwitchStatement switchStatement) { if (Process(switchStatement)) { visitor.Visit(switchStatement); } base.Visit(switchStatement); }
public virtual void VisitSwitchStatement <TExpression, TSwitchCaseStatement, TDefaultCaseStatement>( ISwitchStatement <TExpression, TSwitchCaseStatement, TDefaultCaseStatement> switchStatement) where TExpression : IExpression where TSwitchCaseStatement : ISwitchCaseStatement where TDefaultCaseStatement : IDefaultCaseStatement { Visit(switchStatement); }
public override void Visit(ISwitchStatement expr) { HashSet <IExpression> cmp = new HashSet <IExpression>(); cmp.Add(expr.Expression); cmp.UnionWith(expr.Cases.Select(c => c.Expression)); Mark(Expand(cmp)); }
private void FixSpacingAroundKeywordSwitch(ISwitchStatement item) { List<string> keywordSearch = new List<string> { "switch" }; foreach (var key in keywordSearch) { item.Text = this.whiteSpaceHelper.RemoveWhiteSpaceAroundKeyword(item.Text, key); } }
public static void VisitSwitchStatementChildren <TExpression, TSwitchCaseStatement, TDefaultCaseStatement>( ISwitchStatement <TExpression, TSwitchCaseStatement, TDefaultCaseStatement> switchStatement, IGenericStatementVisitor visitor) where TExpression : IExpression where TSwitchCaseStatement : ISwitchCaseStatement where TDefaultCaseStatement : IDefaultCaseStatement { VisitCollection(switchStatement.Cases, visitor); VisitIfNotNull(switchStatement.DefaultCase, visitor); }
public override void VisitSwitchStatement(ISwitchStatement operation) { var caseCountStr = $"{operation.Cases.Length} cases"; LogString($"{nameof(ISwitchStatement)} ({caseCountStr})"); LogCommonPropertiesAndNewLine(operation); Visit(operation.Value, header: "Switch expression"); VisitArray(operation.Cases); }
private void FixSpacingAroundKeywordSwitch(ISwitchStatement item) { List <string> keywordSearch = new List <string> { "switch" }; foreach (var key in keywordSearch) { item.Text = this.whiteSpaceHelper.RemoveWhiteSpaceAroundKeyword(item.Text, key); } }
public override void TraverseChildren(ISwitchStatement switchStatement) { this.sourceEmitterOutput.Write("switch(", true); this.Traverse(switchStatement.Expression); this.sourceEmitterOutput.WriteLine("){"); this.sourceEmitterOutput.IncreaseIndent(); this.Traverse(switchStatement.Cases); this.sourceEmitterOutput.DecreaseIndent(); this.sourceEmitterOutput.WriteLine("}", true); }
public override void Visit(ISwitchStatement expr) { var exprType = expr.Expression.Type.ResolvedType; if (exprType.IsEnum) { foreach (var c in expr.Cases) { ResolveEnum(expr.Expression, c.Expression); } } }
public override void TraverseChildren(ISwitchStatement switchStatement) { var eTraverser = this.factory.MakeExpressionTraverser(this.sink, this, this.contractContext); eTraverser.Traverse(switchStatement.Expression); var conditionExpr = eTraverser.TranslatedExpressions.Pop(); // Can't depend on default case existing or its index in the collection. var switchCases = new List <ISwitchCase>(); ISwitchCase defaultCase = null; foreach (var switchCase in switchStatement.Cases) { if (switchCase.IsDefault) { defaultCase = switchCase; } else { switchCases.Add(switchCase); } } Bpl.StmtList defaultStmts = null; if (defaultCase != null) { var defaultBodyTraverser = this.factory.MakeStatementTraverser(this.sink, this.PdbReader, this.contractContext); defaultBodyTraverser.Traverse(defaultCase.Body); defaultStmts = defaultBodyTraverser.StmtBuilder.Collect(defaultCase.Token()); } Bpl.IfCmd ifCmd = null; for (int i = switchCases.Count - 1; 0 <= i; i--) { var switchCase = switchCases[i]; var scTraverser = this.factory.MakeExpressionTraverser(this.sink, this, this.contractContext); scTraverser.Traverse(switchCase.Expression); var scConditionExpr = scTraverser.TranslatedExpressions.Pop(); var condition = Bpl.Expr.Eq(conditionExpr, scConditionExpr); var scBodyTraverser = this.factory.MakeStatementTraverser(this.sink, this.PdbReader, this.contractContext); scBodyTraverser.Traverse(switchCase.Body); ifCmd = new Bpl.IfCmd(switchCase.Token(), condition, scBodyTraverser.StmtBuilder.Collect(switchCase.Token()), ifCmd, defaultStmts); defaultStmts = null; // default body goes only into the innermost if-then-else } StmtBuilder.Add(ifCmd); }
public override bool Visit(ISwitchStatement statement, IStatement context) { _stack.Push(statement); try { return(base.Visit(statement, context)); } finally { _stack.Pop(); } }
private bool SwitchIsIncomplete( ISwitchStatement switchStatement, out bool missingCases, out bool missingDefaultCase) { var missingEnumMembers = PopulateSwitchHelpers.GetMissingEnumMembers(switchStatement); missingCases = missingEnumMembers.Count > 0; missingDefaultCase = !PopulateSwitchHelpers.HasDefaultCase(switchStatement); // The switch is incomplete if we're missing any cases or we're missing a default case. return missingDefaultCase || missingCases; }
public static bool HasDefaultCase(ISwitchStatement switchStatement) { for (var index = switchStatement.Cases.Length - 1; index >= 0; index--) { if (HasDefaultCase(switchStatement.Cases[index])) { return(true); } } return(false); }
public static bool HasDefaultCase(ISwitchStatement switchStatement) { for (var index = switchStatement.Cases.Length - 1; index >= 0; index--) { if (HasDefaultCase(switchStatement.Cases[index])) { return true; } } return false; }
private bool SwitchIsIncomplete( ISwitchStatement switchStatement, out bool missingCases, out bool missingDefaultCase) { var missingEnumMembers = PopulateSwitchHelpers.GetMissingEnumMembers(switchStatement); missingCases = missingEnumMembers.Count > 0; missingDefaultCase = !PopulateSwitchHelpers.HasDefaultCase(switchStatement); // The switch is incomplete if we're missing any cases or we're missing a default case. return(missingDefaultCase || missingCases); }
public SwitchAnalysisContext([NotNull] ISwitchStatement switchStatement, [NotNull] INamedTypeSymbol systemBoolean, OperationAnalysisContext context) { Guard.NotNull(switchStatement, nameof(switchStatement)); Guard.NotNull(systemBoolean, nameof(systemBoolean)); SwitchStatement = switchStatement; compilation = context.Compilation; CancellationToken = context.CancellationToken; BooleanTrue = systemBoolean.GetMembers("TrueString").Single(); BooleanFalse = systemBoolean.GetMembers("FalseString").Single(); }
public override void VisitSwitchStatement(ISwitchStatement block, IList <IStatement> body) { AddIf(block, CompletionCase.EmptyCompletionBefore, body); var switchBlock = new SwitchBlock { Reference = _exprVisitor.ToVariableRef(block.Condition, body) }; foreach (var section in block.Sections) { IKaVEList <IStatement> currentSection = null; foreach (var label in section.CaseLabels) { currentSection = new KaVEList <IStatement>(); if (label.IsDefault) { switchBlock.DefaultSection = currentSection; } else { switchBlock.Sections.Add( new CaseBlock { Label = _exprVisitor.ToSimpleExpression(label.ValueExpression, body), Body = currentSection }); } AddIf(label, CompletionCase.InBody, currentSection); } AddIf(section, CompletionCase.InBody, currentSection); foreach (var statement in section.Statements) { statement.Accept(this, currentSection); } switch (1) { case 1 * 2: case 0: break; } } body.Add(switchBlock); AddIf(block, CompletionCase.EmptyCompletionAfter, body); }
private void ProcessSwitchStatement(ISwitchStatement pStatement) { //if (mCurrentBlock.Terminated) mCurrentBlock = CreateBlock(CreateLabel()); HLLocation locationCondition = ProcessExpression(pStatement.Expression); HLInstructionBlock blockParent = mCurrentBlock; List <HLInstructionBlock> blocksStarts = new List <HLInstructionBlock>(); List <HLInstructionBlock> blocksEnds = new List <HLInstructionBlock>(); HLInstructionBlock blockDefaultCase = null; List <Tuple <HLLiteralLocation, HLLabel> > cases = new List <Tuple <HLLiteralLocation, HLLabel> >(); foreach (ISwitchCase switchCase in pStatement.Cases) { HLInstructionBlock blockCase = CreateBlock(CreateLabel()); mCurrentBlock = blockCase; blocksStarts.Add(blockCase); if (switchCase.IsDefault) { blockDefaultCase = blockCase; } else { HLLiteralLocation locationCase = (HLLiteralLocation)ProcessCompileTimeConstantExpression(switchCase.Expression); cases.Add(new Tuple <HLLiteralLocation, HLLabel>(locationCase, blockCase.StartLabel)); } foreach (IStatement statementCase in switchCase.Body) { ProcessStatement(statementCase); } blocksEnds.Add(mCurrentBlock); } if (blockDefaultCase == null) { blockDefaultCase = CreateBlock(CreateLabel()); mCurrentBlock = blockDefaultCase; blocksStarts.Add(blockDefaultCase); blocksEnds.Add(blockDefaultCase); } blockParent.EmitSwitch(locationCondition, blockDefaultCase.StartLabel, cases); if (!blocksEnds.TrueForAll(b => b.Terminated)) { mCurrentBlock = CreateBlock(CreateLabel()); blocksEnds.ForEach(b => b.Terminate(mCurrentBlock.StartLabel)); } }
public override void VisitSwitchStatement <TExpression, TSwitchCaseStatement, TDefaultCaseStatement>( ISwitchStatement <TExpression, TSwitchCaseStatement, TDefaultCaseStatement> switchStatement) { Steps.Add(new WriteSwitchKeyword()); Steps.Add(new WriteWhitespace()); Steps.Add(new WriteStartParenthesis()); Steps.Add(new WriteExpression <TExpression>(switchStatement.Expression)); Steps.Add(new WriteEndParenthesis()); Steps.Add(new IncrementIndent()); Steps.AddStatementStepsOnNewLines(switchStatement.Cases); if (switchStatement.DefaultCase != null) { Steps.Add(new WriteIndentedNewLine()); Steps.Add(new WriteStatement <TDefaultCaseStatement>(switchStatement.DefaultCase)); } }
public static ICollection<ISymbol> GetMissingEnumMembers(ISwitchStatement switchStatement) { var switchExpression = switchStatement.Value; var switchExpressionType = switchExpression?.Type; var enumMembers = new Dictionary<long, ISymbol>(); if (switchExpressionType?.TypeKind == TypeKind.Enum) { if (!TryGetAllEnumMembers(switchExpressionType, enumMembers) || !TryRemoveExistingEnumMembers(switchStatement, enumMembers)) { return SpecializedCollections.EmptyCollection<ISymbol>(); } } return enumMembers.Values; }
private void AnalyzeSwitchStatement(ISwitchStatement source, int idx) { // Switch statement is a block. Need to introduce the faked scope. using (m_currentLocationStack.AutoPush("__switch__" + idx.ToString())) { AnalyzeExpression(source.Expression, idx); foreach (var caseClause in source.CaseBlock.GetCaseClauses()) { AnalyzeExpression(caseClause.Expression, idx); AnalyzeStatements(caseClause.Statements); } AnalyzeStatements(source.CaseBlock.GetDefaultClause()?.Statements); } }
public static ICollection <ISymbol> GetMissingEnumMembers(ISwitchStatement switchStatement) { var switchExpression = switchStatement.Value; var switchExpressionType = switchExpression?.Type; var enumMembers = new Dictionary <long, ISymbol>(); if (switchExpressionType?.TypeKind == TypeKind.Enum) { if (!TryGetAllEnumMembers(switchExpressionType, enumMembers) || !TryRemoveExistingEnumMembers(switchStatement, enumMembers)) { return(SpecializedCollections.EmptyCollection <ISymbol>()); } } return(enumMembers.Values); }
public override void VisitSwitchStatement(ISwitchStatement value) { _formatter.WriteLine(); _formatter.WriteKeyword("switch"); WriteWhitespace(); _formatter.Write("("); VisitExpression(value.Expression); _formatter.Write(")"); _formatter.WriteLine(); using (new IndentedCodeBlock(_formatter)) { foreach (ISwitchCase switchCase in value.Cases) { VisitSwitchCase(switchCase); } } _formatter.WriteLine(); }
private int InsertPosition(ISwitchStatement switchStatement) { // If the last section has a default label, then we want to be above that. // Otherwise, we just get inserted at the end. var cases = switchStatement.Cases; if (cases.Length > 0) { var lastCase = cases.Last(); if (lastCase.Clauses.Any(c => c.CaseKind == CaseKind.Default)) { return(cases.Length - 1); } } return(cases.Length); }
protected override IStatement ConvertSwitch(ISwitchStatement iss) { ISwitchStatement ss = Builder.SwitchStmt(); context.SetPrimaryOutput(ss); ss.Expression = ConvertExpression(iss.Expression); foreach (ISwitchCase isc in iss.Cases) { if (isc is IConditionCase icc) { IExpression cond = icc.Condition; if ((cond is ILiteralExpression ile) && (ile.Value is int i) && (i < 0)) { continue; } } ConvertSwitchCase(ss.Cases, isc); } return(ss); }
private static void WriteSwitch(LanguageWriter w, ISwitchStatement state) { w.WriteKeyword("switch"); w.Write(" ("); ExpressionWriter.WriteExpression(w, state.Expression, false); w.Write(") {"); w.WriteLine(); w.WriteIndent(); foreach (ISwitchCase _case in state.Cases) { IConditionCase case1 = _case as IConditionCase; if (case1 != null) { WriteSwitch_case(w, case1.Condition); w.WriteIndent(); if (case1.Body != null) { WriteStatement(w, case1.Body); } w.WriteOutdent(); } IDefaultCase case2 = _case as IDefaultCase; if (case2 != null) { w.WriteKeyword("default"); w.Write(":"); w.WriteLine(); w.WriteIndent(); if (case2.Body != null) { WriteStatement(w, case2.Body); } w.WriteOutdent(); //this.Write("}"); //this.WriteLine(); } } w.WriteOutdent(); w.Write("}"); w.WriteLine(); }
private static bool TryRemoveExistingEnumMembers(ISwitchStatement switchStatement, Dictionary <long, ISymbol> enumValues) { foreach (var switchCase in switchStatement.Cases) { foreach (var clause in switchCase.Clauses) { switch (clause.CaseKind) { default: case CaseKind.None: case CaseKind.Relational: case CaseKind.Range: // This was some sort of complex switch. For now just ignore // these and assume that they're complete. return(false); case CaseKind.Default: // ignore the 'default/else' clause. continue; case CaseKind.SingleValue: var value = ((ISingleValueCaseClause)clause).Value; if (value == null || !value.ConstantValue.HasValue) { // We had a case which didn't resolve properly. // Assume the switch is complete. return(false); } var caseValue = IntegerUtilities.ToInt64(value.ConstantValue.Value); enumValues.Remove(caseValue); break; } } } return(true); }
private static bool TryRemoveExistingEnumMembers(ISwitchStatement switchStatement, Dictionary<long, ISymbol> enumValues) { foreach (var switchCase in switchStatement.Cases) { foreach (var clause in switchCase.Clauses) { switch (clause.CaseKind) { default: case CaseKind.None: case CaseKind.Relational: case CaseKind.Range: // This was some sort of complex switch. For now just ignore // these and assume that they're complete. return false; case CaseKind.Default: // ignore the 'default/else' clause. continue; case CaseKind.SingleValue: var value = ((ISingleValueCaseClause)clause).Value; if (value == null || !value.ConstantValue.HasValue) { // We had a case which didn't resolve properly. // Assume the switch is complete. return false; } var caseValue = IntegerUtilities.ToInt64(value.ConstantValue.Value); enumValues.Remove(caseValue); break; } } } return true; }
/// <inheritdoc /> public override Expression VisitSwitchStatement(ISwitchStatement operation, LocalBinder argument) { ImmutableArray <ISwitchCase> cases = operation.Cases; SwitchCase[] switchCases = new SwitchCase[cases.Length]; Expression defaultBody = null; for (int i = 0; i < switchCases.Length; i++) { var @case = cases[i]; var block = Expression.Block(@case.Body.Select(x => x.Accept(this, argument))); Expression[] values = new Expression[@case.Clauses.Length]; for (int j = 0; j < values.Length; j++) { var clause = @case.Clauses[j]; switch (clause.CaseKind) { case CaseKind.SingleValue: values[i] = Expression.Constant(clause.ConstantValue.Value); break; case CaseKind.Default: defaultBody = block; values[i] = null; break; default: throw NotSupported(operation); } } switchCases[i] = Expression.SwitchCase(block, values); } return(Expression.Switch(operation.Value.Accept(this, argument), defaultBody, switchCases)); }
protected CognitiveComplexityHintBase(ITreeNode node, DocumentOffset offset, int value) { _node = node; _offset = offset; Value = value; Description = node switch { IWhileStatement _ => "While-Statement (increases nesting)", ISwitchStatement _ => "Switch-Statement (increases nesting)", IDoStatement _ => "Do-While-Statement (increases nesting)", IIfStatement _ => "If-Statement (increases nesting)", IForStatement _ => "For-Statement (increases nesting)", IForeachStatement _ => "Foreach-Statement (increases nesting)", ICatchClause _ => "Catch-Clause (increases nesting)", IGotoStatement _ => "Goto-Statement", IBreakStatement _ => "Break-Statement", IConditionalOrExpression _ => "First/alternating conditional Expression", IConditionalAndExpression _ => "First/alternating conditional Expression", ICSharpStatement _ => "If-Statement (increases nesting)", ICSharpExpression _ => "Recursive Call", _ => throw new NotSupportedException(node.GetType().FullName) }; }
/// <summary> /// Visits the specified switch statement. /// </summary> /// <param name="switchStatement">The switch statement.</param> public override void Visit(ISwitchStatement switchStatement) { SwitchStatement mutableSwitchStatement = new SwitchStatement(switchStatement); this.resultStatement = this.myCodeCopier.DeepCopy(mutableSwitchStatement); }
/// <summary> /// Generates IL for the specified switch statement. /// </summary> /// <param name="switchStatement">The switch statement.</param> public override void TraverseChildren(ISwitchStatement switchStatement) { this.EmitSequencePoint(switchStatement.Locations); this.Traverse(switchStatement.Expression); uint numberOfCases; uint maxValue = GetMaxCaseExpressionValueAsUInt(switchStatement.Cases, out numberOfCases); if (numberOfCases == 0) { this.generator.Emit(OperationCode.Pop); return; } //if (maxValue < uint.MaxValue && maxValue/2 < numberOfCases) this.GenerateSwitchInstruction(switchStatement.Cases, maxValue); //TODO: generate binary search //TemporaryVariable switchVar = new TemporaryVariable(switchStatement.Expression.Type); //this.VisitAssignmentTo(switchVar); //List<ISwitchCase> switchCases = this.GetSortedListOfSwitchCases(switchStatement.Cases); //TODO: special handling for switch over strings this.lastStatementWasUnconditionalTransfer = false; }
public override void Visit(ISwitchStatement switchStatement) { if(Process(switchStatement)){visitor.Visit(switchStatement);} base.Visit(switchStatement); }
public virtual void VisitSwitchStatement(ISwitchStatement s) { }
private void WriteSwitchStatement(ISwitchStatement statement, IFormatter formatter) { this.WriteStatementSeparator(formatter); formatter.WriteKeyword("switch"); formatter.Write(" ("); this.WriteExpression(statement.Expression, formatter); formatter.Write(") "); formatter.Write("{"); formatter.WriteLine(); foreach (ISwitchCase switchCase in statement.Cases) { IConditionCase conditionCase = switchCase as IConditionCase; if (conditionCase != null) { this.WriteSwitchCaseCondition(conditionCase.Condition, formatter); } IDefaultCase defaultCase = switchCase as IDefaultCase; if (defaultCase != null) { formatter.WriteKeyword("default"); formatter.Write(":"); } formatter.WriteIndent(); if (switchCase.Body != null) { this.WriteStatement(switchCase.Body, formatter); this.WritePendingOutdent(formatter); } else { formatter.WriteLine(); } formatter.WriteOutdent(); } formatter.WriteKeyword("}"); }
public void Visit(ISwitchStatement switchStatement) { this.result = this.copier.Copy(switchStatement); }
/// <summary> /// Rewrites the given switch statement. /// </summary> /// <param name="switchStatement"></param> public virtual IStatement Rewrite(ISwitchStatement switchStatement) { return switchStatement; }
public virtual void onASTElement(ISwitchStatement switchStatement) { }
//^ ensures this.path.Count == old(this.path.Count); /// <summary> /// Traverses the given switch statement. /// </summary> /// <param name="switchStatement"></param> public virtual void Visit(ISwitchStatement switchStatement) { if (this.stopTraversal) return; //^ int oldCount = this.path.Count; this.path.Push(switchStatement); this.Visit(switchStatement.Expression); this.Visit(switchStatement.Cases); //^ assume this.path.Count == oldCount+1; //True because all of the virtual methods of this class promise not decrease this.path.Count. this.path.Pop(); }
public override void VisitSwitchStatement(ISwitchStatement operation) { base.VisitSwitchStatement(operation); }
/// <summary> /// Returns a shallow copy of the given switch statement. /// </summary> /// <param name="switchStatement"></param> public SwitchStatement Copy(ISwitchStatement switchStatement) { return new SwitchStatement(switchStatement); }
public virtual void VisitSwitchStatement(ISwitchStatement operation) { DefaultVisit(operation); }
/// <summary> /// Returns a deep copy of the given switch statement. /// </summary> /// <param name="switchStatement"></param> public SwitchStatement Copy(ISwitchStatement switchStatement) { var mutableCopy = this.shallowCopier.Copy(switchStatement); mutableCopy.Expression = this.Copy(mutableCopy.Expression); mutableCopy.Cases = this.Copy(mutableCopy.Cases); return mutableCopy; }
/// <summary> /// Returns a deep copy of the given switch statement. /// </summary> /// <param name="switchStatement"></param> public SwitchStatement Copy(ISwitchStatement switchStatement) { Contract.Requires(switchStatement != null); Contract.Ensures(Contract.Result<SwitchStatement>() != null); var mutableCopy = this.shallowCopier.Copy(switchStatement); mutableCopy.Expression = this.Copy(mutableCopy.Expression); mutableCopy.Cases = this.Copy(mutableCopy.Cases); return mutableCopy; }
/// <summary> /// /// </summary> /// <param name="switchStatement"></param> public SwitchStatement(ISwitchStatement switchStatement) : base(switchStatement) { this.cases = new List<ISwitchCase>(switchStatement.Cases); this.expression = switchStatement.Expression; }
public void Visit(ISwitchStatement switchStatement) { throw new NotImplementedException(); }
/// <summary> /// Traverses the children of the switch statement. /// </summary> public virtual void TraverseChildren(ISwitchStatement switchStatement) { Contract.Requires(switchStatement != null); this.TraverseChildren((IStatement)switchStatement); if (this.StopTraversal) return; this.Traverse(switchStatement.Expression); if (this.StopTraversal) return; this.Traverse(switchStatement.Cases); }
public override void TraverseChildren(ISwitchStatement switchStatement) { MethodEnter(switchStatement); base.TraverseChildren(switchStatement); MethodExit(); }
public void Visit(ISwitchStatement switchStatement) { this.traverser.Traverse(switchStatement); }
/// <summary> /// Performs some computation with the given switch statement. /// </summary> /// <param name="switchStatement"></param> public virtual void Visit(ISwitchStatement switchStatement) { this.Visit((IStatement)switchStatement); }
private int InsertPosition(ISwitchStatement switchStatement) { // If the last section has a default label, then we want to be above that. // Otherwise, we just get inserted at the end. var cases = switchStatement.Cases; if (cases.Length > 0) { var lastCase = cases.Last(); if (lastCase.Clauses.Any(c => c.CaseKind == CaseKind.Default)) { return cases.Length - 1; } } return cases.Length; }
public void Visit(ISwitchStatement switchStatement) { Contract.Requires(switchStatement != null); throw new NotImplementedException(); }
/// <summary> /// Performs some computation with the given switch statement. /// </summary> /// <param name="switchStatement"></param> public virtual void Visit(ISwitchStatement switchStatement) { }
/// <summary> /// Returns a shallow copy of the given switch statement. /// </summary> /// <param name="switchStatement"></param> public SwitchStatement Copy(ISwitchStatement switchStatement) { Contract.Requires(switchStatement != null); Contract.Ensures(Contract.Result<SwitchStatement>() != null); return new SwitchStatement(switchStatement); }
/// <summary> /// Traverses the switch statement. /// </summary> public void Traverse(ISwitchStatement switchStatement) { Contract.Requires(switchStatement != null); if (this.preorderVisitor != null) this.preorderVisitor.Visit(switchStatement); if (this.StopTraversal) return; this.TraverseChildren(switchStatement); if (this.StopTraversal) return; if (this.postorderVisitor != null) this.postorderVisitor.Visit(switchStatement); }