Permalink
Browse files

AdventureSample - support RUN

  • Loading branch information...
bobbymcr committed Apr 23, 2018
1 parent 428cee7 commit b55b89658b2d90046545048c3ea01d0b287fdab5
@@ -126,6 +126,9 @@ public void Void(string name)
case "Return":
this.AddReturn();
break;
case "Run":
this.AddRun();
break;
default:
throw new NotImplementedException("Void:" + name);
}
@@ -248,6 +251,12 @@ private void AddReturn()
this.lines.AddReturn(this.lineNumber);
}
private void AddRun()
{
var ret = this.generator.ReturnStatement(this.generator.LiteralExpression(1));
this.lines.Add(this.lineNumber, ret);
}
private void AddCls()
{
string name = "CLS";
@@ -0,0 +1,50 @@
// <copyright file="Subroutines.cs" company="Brian Rogers">
// Copyright (c) Brian Rogers. All rights reserved.
// </copyright>
namespace GWBas2CS.Test
{
using FluentAssertions;
using Xunit;
public sealed class Subroutines
{
[Fact]
public void WithRun()
{
const string Input =
@"10 GOSUB 30
20 GOTO 10
30 RUN
40 RETURN";
const string Expected = @"*
private int Sub_30()
{
return 1;
return 0;
}
private int Main()
{
this.Init();
L10:
;
switch (Sub_30())
{
case 1:
return 1;
case 2:
return 2;
}
goto L10;
return 2;
}
*";
string actual = Test.Translate("MyProg", Input);
actual.Should().Match(Expected);
}
}
}

0 comments on commit b55b896

Please sign in to comment.