-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLabeledStatement.cs
More file actions
30 lines (25 loc) · 1012 Bytes
/
LabeledStatement.cs
File metadata and controls
30 lines (25 loc) · 1012 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
namespace MiniSharpCompiler
{
using LLVMSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
public partial class LLVMIRGenerationVisitor
{
public override void VisitLabeledStatement(LabeledStatementSyntax node)
{
var identifier = node.Identifier.Text;
var basicBlocks = this.labels.Peek();
LLVMBasicBlockRef gotoBB;
if (!basicBlocks.TryGetValue(identifier, out gotoBB))
{
gotoBB = LLVM.AppendBasicBlock(this.function, identifier);
basicBlocks.Add(identifier, gotoBB);
}
LLVM.BuildBr(this.builder, gotoBB);
LLVM.PositionBuilderAtEnd(this.builder, gotoBB);
this.Visit(node.Statement);
LLVMBasicBlockRef postGotoBB = LLVM.AppendBasicBlock(this.function, string.Concat("Post", identifier));
LLVM.BuildBr(this.builder, postGotoBB);
LLVM.PositionBuilderAtEnd(this.builder, postGotoBB);
}
}
}