Skip to content

Commit

Permalink
rebasing some more
Browse files Browse the repository at this point in the history
  • Loading branch information
mbellotti committed Apr 14, 2023
1 parent 8dc2748 commit 27773a6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
13 changes: 5 additions & 8 deletions listener/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -669,17 +669,12 @@ func (l *FaultListener) ExitRunBlock(c *parser.RunBlockContext) {
for i := len(steps) - 1; i >= 0; i-- {
ex := l.pop()

if sw, ok := ex.(*ast.InfixExpression); ok && sw.TokenLiteral() == "SWAP" {
i++
orphanSwaps = append(orphanSwaps, sw)
continue
if ex.TokenLiteral() == "SWAP" {
i++ //Swaps are the same step as the instance that initializes them
}

switch t := ex.(type) {
case *ast.Instance:
swaps, orphanSwaps = l.filterSwaps(t.Name, orphanSwaps)
t.Swaps = append(t.Swaps, swaps...)

token2 := ex.GetToken()

s := &ast.ExpressionStatement{
Expand Down Expand Up @@ -753,7 +748,7 @@ func (l *FaultListener) ExitRunInit(c *parser.RunInitContext) {
token2 := util.GenerateToken("IDENT", "IDENT", c.GetStart(), c.GetStop())

// Check for swaps
orphanSwaps = l.getSwaps()
swaps := l.getSwaps()

ident := &ast.Identifier{Token: token2}
switch len(txt) {
Expand Down Expand Up @@ -793,6 +788,8 @@ func (l *FaultListener) ExitRunInit(c *parser.RunInitContext) {
Order: order,
Swaps: swaps,
})

l.pushN(swaps)
}

func (l *FaultListener) ExitRunSwap(c *parser.SwapContext) {
Expand Down
2 changes: 1 addition & 1 deletion listener/listener_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1746,7 +1746,7 @@ func TestUnknown(t *testing.T) {

}

func TestSysSpec(t *testing.T) {
func TestSwap(t *testing.T) {
test := `system test1;
import "foo.fspec";
Expand Down

0 comments on commit 27773a6

Please sign in to comment.