Skip to content
This repository has been archived by the owner on Oct 12, 2024. It is now read-only.

Commit

Permalink
This is sort of working. Kinda.
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanbeattie committed Jul 12, 2024
1 parent bd8b85d commit 098fce0
Show file tree
Hide file tree
Showing 9 changed files with 323 additions and 185 deletions.
4 changes: 4 additions & 0 deletions Starship/Rockstar.Engine/Statements/Block.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ public Block(IEnumerable<Block> blocks) : this(blocks.SelectMany(b => b.Statemen
public static Block Empty => new();
public bool IsEmpty => !statements.Any();

public Block Concat(IEnumerable<Statement> tail) {
Statements.AddRange(tail);
return this;
}
public Block Concat(IEnumerable<Block> tail) {
Statements.AddRange(tail.SelectMany(t => t.Statements));
return this;
Expand Down
21 changes: 20 additions & 1 deletion Starship/Rockstar.Engine/Statements/Statement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,23 @@

namespace Rockstar.Engine.Statements;

public abstract class Statement(Source source) : Expression(source);
public abstract class Statement(Source source) : Expression(source) {
public Block Concat(IList<Statement> list)
=> new Block(new List<Statement> { this }.Concat(list));

public Block Concat(Statement tail)
=> new Block(new List<Statement> { this }.Concat([ tail ]));

};

public class Noop() : Statement(Source.None) {
public static Noop Instance => new Noop();
}

public class Break(Source source) : Statement(source) {

}

public class Continue(Source source) : Statement(source) {

}
Loading

0 comments on commit 098fce0

Please sign in to comment.