Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic teal #2126

Merged
merged 19 commits into from
May 14, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Allow labels to proceed instructions on a line
  • Loading branch information
jannotti committed Apr 27, 2021
commit c6ddaa17d35a47f94268d1ec148eb4c6037e67fb
17 changes: 12 additions & 5 deletions data/transactions/logic/assembler.go
Original file line number Diff line number Diff line change
Expand Up @@ -1033,11 +1033,22 @@ func (ops *OpStream) assemble(fin io.Reader) error {
ops.trace("%d: no fields\n", ops.sourceLine)
continue
}
// we're going to process opcodes, so fix the Version
// we're about to begin processing opcodes, so fix the Version
if ops.Version == assemblerNoVersion {
ops.Version = AssemblerDefaultVersion
}
opstring := fields[0]

if opstring[len(opstring)-1] == ':' {
ops.createLabel(opstring[:len(opstring)-1])
fields = fields[1:]
if len(fields) == 0 {
// There was a label, not need to ops.trace this
continue
}
opstring = fields[0]
}

spec, ok := OpsByName[ops.Version][opstring]
if !ok {
spec, ok = keywords[opstring]
Expand All @@ -1053,10 +1064,6 @@ func (ops *OpStream) assemble(fin io.Reader) error {
ops.trace("\n")
continue
}
if opstring[len(opstring)-1] == ':' {
ops.createLabel(opstring[:len(opstring)-1])
continue
}
// unknown opcode, let's report a good error if version problem
spec, ok = OpsByName[AssemblerMaxVersion][opstring]
if ok {
Expand Down
4 changes: 2 additions & 2 deletions data/transactions/logic/eval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4010,10 +4010,10 @@ func TestPush(t *testing.T) {
func TestLoop(t *testing.T) {
t.Parallel()
// Double until > 10. Should be 16
testAccepts(t, "int 1; loop:; int 2; *; dup; int 10; <; bnz loop; int 16; ==", 4)
testAccepts(t, "int 1; loop: int 2; *; dup; int 10; <; bnz loop; int 16; ==", 4)

// Why does this label on line with instruction cause trouble?
testAccepts(t, "int 1; loop:; int 2; *; dup; int 10; <; bnz loop; int 16; ==", 4)
testAccepts(t, "int 1; loop: int 2; *; dup; int 10; <; bnz loop; int 16; ==", 4)

// Infinite loop because multiply by one instead of two
testPanics(t, "int 1; loop:; int 1; *; dup; int 10; <; bnz loop; int 16; ==", 4)
Expand Down