public override BoundNode VisitLocalFunctionStatement(BoundLocalFunctionStatement node) { var oldContainingSymbol = _F.CurrentFunction; var oldAwaitFinallyFrame = _currentAwaitFinallyFrame; _F.CurrentFunction = node.Symbol; _currentAwaitFinallyFrame = new AwaitFinallyFrame(); var result = base.VisitLocalFunctionStatement(node); _F.CurrentFunction = oldContainingSymbol; _currentAwaitFinallyFrame = oldAwaitFinallyFrame; return(result); }
public AwaitFinallyFrame(AwaitFinallyFrame parent, HashSet <LabelSymbol> labelsOpt, StatementSyntax statementSyntax) { Debug.Assert(parent != null); Debug.Assert(statementSyntax != null); Debug.Assert(statementSyntax.Kind() == SyntaxKind.TryStatement || (statementSyntax.Kind() == SyntaxKind.UsingStatement && ((UsingStatementSyntax)statementSyntax).AwaitKeyword != default) || (statementSyntax.Kind() == SyntaxKind.ForEachStatement && ((CommonForEachStatementSyntax)statementSyntax).AwaitKeyword != default) || (statementSyntax.Kind() == SyntaxKind.ForEachVariableStatement && ((CommonForEachStatementSyntax)statementSyntax).AwaitKeyword != default) || (statementSyntax.Kind() == SyntaxKind.LocalDeclarationStatement && ((LocalDeclarationStatementSyntax)statementSyntax).AwaitKeyword != default)); this.ParentOpt = parent; this.LabelsOpt = labelsOpt; _statementSyntaxOpt = statementSyntax; }
public override BoundNode VisitLambda(BoundLambda node) { var oldContainingSymbol = this.F.CurrentMethod; var oldAwaitFinallyFrame = this.currentAwaitFinallyFrame; this.F.CurrentMethod = node.Symbol; this.currentAwaitFinallyFrame = new AwaitFinallyFrame(null, null); var result = base.VisitLambda(node); this.F.CurrentMethod = oldContainingSymbol; this.currentAwaitFinallyFrame = oldAwaitFinallyFrame; return(result); }
public AwaitFinallyFrame(AwaitFinallyFrame parent, HashSet<LabelSymbol> labelsOpt, TryStatementSyntax tryStatementSyntax) { Debug.Assert(parent != null); Debug.Assert(tryStatementSyntax != null); this.ParentOpt = parent; this.LabelsOpt = labelsOpt; _tryStatementSyntaxOpt = tryStatementSyntax; }
private void PopFrame() { var result = _currentAwaitFinallyFrame; _currentAwaitFinallyFrame = result.ParentOpt; }
private AwaitFinallyFrame PushFrame(BoundTryStatement statement) { var newFrame = new AwaitFinallyFrame(_currentAwaitFinallyFrame, _analysis.Labels(statement), (TryStatementSyntax)statement.Syntax); _currentAwaitFinallyFrame = newFrame; return newFrame; }
public override BoundNode VisitLocalFunctionStatement(BoundLocalFunctionStatement node) { var oldContainingSymbol = _F.CurrentMethod; var oldAwaitFinallyFrame = _currentAwaitFinallyFrame; _F.CurrentMethod = node.Symbol; _currentAwaitFinallyFrame = new AwaitFinallyFrame(); var result = base.VisitLocalFunctionStatement(node); _F.CurrentMethod = oldContainingSymbol; _currentAwaitFinallyFrame = oldAwaitFinallyFrame; return result; }
private BoundStatement UnpendBranches( AwaitFinallyFrame frame, SynthesizedLocal pendingBranchVar, SynthesizedLocal pendingException) { var parent = frame.ParentOpt; // handle proxy labels if have any var proxiedLabels = frame.proxiedLabels; var proxyLabels = frame.proxyLabels; // skip 0 - it means we took no explicit branches int i = 1; var cases = ArrayBuilder<BoundSwitchSection>.GetInstance(); if (proxiedLabels != null) { for (int cnt = proxiedLabels.Count; i <= cnt; i++) { var target = proxiedLabels[i - 1]; var parentProxy = parent.ProxyLabelIfNeeded(target); var caseStatement = _F.SwitchSection(i, _F.Goto(parentProxy)); cases.Add(caseStatement); } } if (frame.returnProxyLabel != null) { BoundLocal pendingValue = null; if (frame.returnValue != null) { pendingValue = _F.Local(frame.returnValue); } SynthesizedLocal returnValue; BoundStatement unpendReturn; var returnLabel = parent.ProxyReturnIfNeeded(_F.CurrentMethod, pendingValue, out returnValue); if (returnLabel == null) { unpendReturn = new BoundReturnStatement(_F.Syntax, pendingValue); } else { if (pendingValue == null) { unpendReturn = _F.Goto(returnLabel); } else { unpendReturn = _F.Block( _F.Assignment( _F.Local(returnValue), pendingValue), _F.Goto(returnLabel)); } } var caseStatement = _F.SwitchSection(i, unpendReturn); cases.Add(caseStatement); } return _F.Switch(_F.Local(pendingBranchVar), cases.ToImmutableAndFree()); }
private BoundBlock PendBranches( AwaitFinallyFrame frame, LocalSymbol pendingBranchVar, LabelSymbol finallyLabel) { var bodyStatements = ArrayBuilder<BoundStatement>.GetInstance(); // handle proxy labels if have any var proxiedLabels = frame.proxiedLabels; var proxyLabels = frame.proxyLabels; // skip 0 - it means we took no explicit branches int i = 1; if (proxiedLabels != null) { for (int cnt = proxiedLabels.Count; i <= cnt; i++) { var proxied = proxiedLabels[i - 1]; var proxy = proxyLabels[proxied]; PendBranch(bodyStatements, proxy, i, pendingBranchVar, finallyLabel); } } var returnProxy = frame.returnProxyLabel; if (returnProxy != null) { PendBranch(bodyStatements, returnProxy, i, pendingBranchVar, finallyLabel); } return _F.Block(bodyStatements.ToImmutableAndFree()); }
private void PopFrame() { var result = currentAwaitFinallyFrame; currentAwaitFinallyFrame = result.parent; }
private AwaitFinallyFrame PushFrame(BoundTryStatement statement) { var newFrame = new AwaitFinallyFrame(currentAwaitFinallyFrame, analysis.Labels(statement)); currentAwaitFinallyFrame = newFrame; return newFrame; }
public override BoundNode VisitLambda(BoundLambda node) { var oldContainingSymbol = this.F.CurrentMethod; var oldAwaitFinallyFrame = this.currentAwaitFinallyFrame; this.F.CurrentMethod = node.Symbol; this.currentAwaitFinallyFrame = new AwaitFinallyFrame(null, null); var result = base.VisitLambda(node); this.F.CurrentMethod = oldContainingSymbol; this.currentAwaitFinallyFrame = oldAwaitFinallyFrame; return result; }
private Statement UnpendBranches( AwaitFinallyFrame frame, InternalLocal pendingBranchVar, InternalLocal pendingException) { var parent = frame.ParentOpt; // handle proxy labels if have any var proxiedLabels = frame.proxiedLabels; // skip 0 - it means we took no explicit branches int i = 1; var cases = new List <Statement>(); if (proxiedLabels != null) { for (int cnt = proxiedLabels.Count; i <= cnt; i++) { var target = proxiedLabels[i - 1]; var parentProxy = parent.ProxyLabelIfNeeded(target); cases.Add(_F.CreateGoto(parentProxy, _tryDepth)); } } if (frame.returnProxyLabel != null) { Local pendingValue = null; if (frame.returnValue != null) { pendingValue = frame.returnValue.Local; } InternalLocal returnValue; Statement unpendReturn; var returnLabel = parent.ProxyReturnIfNeeded(_containingMethod, pendingValue, out returnValue); if (returnLabel == null) { unpendReturn = new ReturnStatement(_F.CreateLocalReference((InternalLocal)pendingValue.Entity)); } else { if (pendingValue == null) { unpendReturn = _F.CreateGoto(returnLabel, _tryDepth); } else { unpendReturn = new Block( new ExpressionStatement( _F.CreateAssignment(_F.CreateLocalReference(returnValue), _F.CreateLocalReference((InternalLocal)pendingValue.Entity))), _F.CreateGoto(returnLabel, _tryDepth)); } } cases.Add(unpendReturn); } var defaultLabel = _F.CreateLabel(_containingMethod, CompilerContext.Current.GetUniqueName("default"), _tryDepth); cases.Insert(0, _F.CreateGoto(defaultLabel, _tryDepth)); return(CreateSwitch(cases, defaultLabel, pendingBranchVar)); }
public AwaitFinallyFrame(AwaitFinallyFrame parent, HashSet <LabelSymbol> labels) { this.parent = parent; this.labels = labels; }
private BoundStatement UnpendBranches( AwaitFinallyFrame frame, SynthesizedLocal pendingBranchVar, SynthesizedLocal pendingException) { var parent = frame.ParentOpt; // handle proxy labels if have any var proxiedLabels = frame.proxiedLabels; // skip 0 - it means we took no explicit branches int i = 1; var cases = ArrayBuilder <BoundSwitchSection> .GetInstance(); if (proxiedLabels != null) { for (int cnt = proxiedLabels.Count; i <= cnt; i++) { var target = proxiedLabels[i - 1]; var parentProxy = parent.ProxyLabelIfNeeded(target); var caseStatement = _F.SwitchSection(i, _F.Goto(parentProxy)); cases.Add(caseStatement); } } if (frame.returnProxyLabel != null) { BoundLocal pendingValue = null; if (frame.returnValue != null) { pendingValue = _F.Local(frame.returnValue); } SynthesizedLocal returnValue; BoundStatement unpendReturn; var returnLabel = parent.ProxyReturnIfNeeded(_F.CurrentFunction, pendingValue, out returnValue); if (returnLabel == null) { unpendReturn = new BoundReturnStatement(_F.Syntax, RefKind.None, pendingValue); } else { if (pendingValue == null) { unpendReturn = _F.Goto(returnLabel); } else { unpendReturn = _F.Block( _F.Assignment( _F.Local(returnValue), pendingValue), _F.Goto(returnLabel)); } } var caseStatement = _F.SwitchSection(i, unpendReturn); cases.Add(caseStatement); } return(_F.Switch(_F.Local(pendingBranchVar), cases.ToImmutableAndFree())); }
public AwaitFinallyFrame(AwaitFinallyFrame parent, HashSet<LabelSymbol> labels) { this.parent = parent; this.labels = labels; }