-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReturnStatement.cs
More file actions
28 lines (26 loc) · 858 Bytes
/
ReturnStatement.cs
File metadata and controls
28 lines (26 loc) · 858 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
namespace MiniSharpCompiler
{
using LLVMSharp;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
public partial class LLVMIRGenerationVisitor
{
/// <summary>
/// 8.9.4
/// </summary>
public override void VisitReturnStatement(ReturnStatementSyntax node)
{
var returnType = this.semanticModel.GetTypeInfo(node.Expression);
if (returnType.Type.SpecialType == SpecialType.System_Void)
{
LLVM.BuildRetVoid(this.builder);
}
else
{
LLVM.BuildRet(this.builder, this.Pop(node.Expression));
}
LLVM.PositionBuilderAtEnd(this.builder, LLVM.AppendBasicBlock(this.function, "UnreachableReturn"));
}
}
}