Skip to content

Commit

Permalink
AdventureSample - support DIM of 2 arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbymcr committed Apr 22, 2018
1 parent c61c6bf commit d31c296
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
10 changes: 9 additions & 1 deletion projects/AdventureSample/src/GWBas2CS/BasicVisitor.cs
Expand Up @@ -98,7 +98,7 @@ public void Many(string name, BasicExpression[] list)
this.AddPrint(list[0]);
break;
case "Dim":
this.AddDim(list[0]);
this.AddDim(list);
break;
default:
throw new NotImplementedException("Many:" + name);
Expand Down Expand Up @@ -233,6 +233,14 @@ private void AddCls()
this.methods.Add(name, clsMethod);
}

private void AddDim(BasicExpression[] exprs)
{
foreach (BasicExpression expr in exprs)
{
this.AddDim(expr);
}
}

private void AddDim(BasicExpression expr)
{
ExpressionNode node = new ExpressionNode(this.generator, this.vars, this.methods);
Expand Down
19 changes: 19 additions & 0 deletions projects/AdventureSample/test/GWBas2CS.Test/DimStatements.cs
Expand Up @@ -44,5 +44,24 @@ private bool Main()

actual.Should().Match(Expected);
}

[Fact]
public void TwoArrays()
{
const string Input = @"10 DIM A(1),B$(2)";
const string Expected = @"*
private bool Main()
{
this.Init();
DIM1_na(out A_na, 1);
DIM1_sa(out B_sa, 2);
return false;
}
*";

string actual = Test.Translate("MyProg", Input);

actual.Should().Match(Expected);
}
}
}

0 comments on commit d31c296

Please sign in to comment.