forked from UbiquityDotNET/Llvm.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReplEngine.cs
More file actions
41 lines (34 loc) · 1.14 KB
/
Copy pathReplEngine.cs
File metadata and controls
41 lines (34 loc) · 1.14 KB
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
31
32
33
34
35
36
37
38
39
40
41
// Copyright (c) Ubiquity.NET Contributors. All rights reserved.
// Licensed under the Apache-2.0 WITH LLVM-exception license. See the LICENSE.md file in the project root for full license information.
using System;
using Kaleidoscope.Grammar;
using Kaleidoscope.Runtime;
using Ubiquity.NET.Llvm.Values;
using Ubiquity.NET.Runtime.Utils;
namespace Kaleidoscope.Chapter3_5
{
internal class ReplEngine
: ReadEvaluatePrintLoopBase<Value>
{
public ReplEngine( )
: base( LanguageLevel.SimpleExpressions )
{
}
public override ICodeGenerator<Value> CreateGenerator( DynamicRuntimeState state )
{
return new CodeGenerator( state );
}
public override void ProcessResults( Value resultValue )
{
switch(resultValue)
{
case Function function:
Console.WriteLine( "Defined function: {0}", function.Name );
Console.WriteLine( function.ParentModule.WriteToString() );
break;
default:
throw new InvalidOperationException();
}
}
}
}