diff --git a/data/transactions/logic/README.md b/data/transactions/logic/README.md index 521f9b57b7..2fda903c98 100644 --- a/data/transactions/logic/README.md +++ b/data/transactions/logic/README.md @@ -594,7 +594,7 @@ Account fields used in the `acct_params_get` opcode. | `assert` | immediately fail unless A is a non-zero number | | `callsub target` | branch unconditionally to TARGET, saving the next instruction on the call stack | | `retsub` | pop the top instruction from the call stack and branch to it | -| `switchi target ...` | branch to the Ath label. Continue at following instruction if index A exceeds the number of labels. | +| `switch target ...` | branch to the Ath label. Continue at following instruction if index A exceeds the number of labels. | ### State Access diff --git a/data/transactions/logic/TEAL_opcodes.md b/data/transactions/logic/TEAL_opcodes.md index 45cba65d05..05cb20b96d 100644 --- a/data/transactions/logic/TEAL_opcodes.md +++ b/data/transactions/logic/TEAL_opcodes.md @@ -1053,7 +1053,7 @@ The call stack is separate from the data stack. Only `callsub` and `retsub` mani The call stack is separate from the data stack. Only `callsub` and `retsub` manipulate it. -## switchi target ... +## switch target ... - Opcode: 0x8a {uint8 branch count} [{int16 branch offset, big-endian}, ...] - Stack: ..., A: uint64 → ... diff --git a/data/transactions/logic/assembler_test.go b/data/transactions/logic/assembler_test.go index 8a2928731b..e614a722c6 100644 --- a/data/transactions/logic/assembler_test.go +++ b/data/transactions/logic/assembler_test.go @@ -397,7 +397,7 @@ replace3 const switchNonsense = ` switch_label0: pushint 1 -switchi switch_label0 switch_label1 +switch switch_label0 switch_label1 switch_label1: pushint 1 ` @@ -2774,7 +2774,7 @@ func TestAssembleSwitch(t *testing.T) { // fail when target doesn't correspond to existing label source := ` pushint 1 - switchi label1 label2 + switch label1 label2 label1: ` testProg(t, source, AssemblerMaxVersion, NewExpect(3, "reference to undefined label \"label2\"")) @@ -2782,21 +2782,21 @@ func TestAssembleSwitch(t *testing.T) { // fail when target index != uint64 testProg(t, ` byte "fail" - switchi label1 + switch label1 labe11: - `, AssemblerMaxVersion, Expect{3, "switchi label1 arg 0 wanted type uint64..."}) + `, AssemblerMaxVersion, Expect{3, "switch label1 arg 0 wanted type uint64..."}) // No labels is pretty degenerate, but ok, I suppose. It's just a no-op testProg(t, ` int 0 -switchi +switch int 1 `, AssemblerMaxVersion) // confirm arg limit source = ` pushint 1 - switchi label1 label2 + switch label1 label2 label1: label2: ` @@ -2811,7 +2811,7 @@ int 1 // test that 255 labels is ok source = fmt.Sprintf(` pushint 1 - switchi %s + switch %s %s `, strings.Join(labels, " "), strings.Join(labels, ":\n")+":\n") ops = testProg(t, source, AssemblerMaxVersion) @@ -2820,15 +2820,15 @@ int 1 // 256 is too many source = fmt.Sprintf(` pushint 1 - switchi %s extra + switch %s extra %s `, strings.Join(labels, " "), strings.Join(labels, ":\n")+":\n") - ops = testProg(t, source, AssemblerMaxVersion, Expect{3, "switchi cannot take more than 255 labels"}) + ops = testProg(t, source, AssemblerMaxVersion, Expect{3, "switch cannot take more than 255 labels"}) // allow duplicate label reference source = ` pushint 1 - switchi label1 label1 + switch label1 label1 label1: ` testProg(t, source, AssemblerMaxVersion) diff --git a/data/transactions/logic/doc.go b/data/transactions/logic/doc.go index cbb754f3ae..bfcf927f0a 100644 --- a/data/transactions/logic/doc.go +++ b/data/transactions/logic/doc.go @@ -194,7 +194,7 @@ var opDocByName = map[string]string{ "vrf_verify": "Verify the proof B of message A against pubkey C. Returns vrf output and verification flag.", "block": "field F of block A. Fail unless A falls between txn.LastValid-1002 and txn.FirstValid (exclusive)", - "switchi": "branch to the Ath label. Continue at following instruction if index A exceeds the number of labels.", + "switch": "branch to the Ath label. Continue at following instruction if index A exceeds the number of labels.", } // OpDoc returns a description of the op @@ -264,7 +264,7 @@ var opcodeImmediateNotes = map[string]string{ "vrf_verify": "{uint8 parameters index}", "block": "{uint8 block field}", - "switchi": "{uint8 branch count} [{int16 branch offset, big-endian}, ...]", + "switch": "{uint8 branch count} [{int16 branch offset, big-endian}, ...]", } // OpImmediateNote returns a short string about immediate data which follows the op byte @@ -343,7 +343,7 @@ var OpGroups = map[string][]string{ "Byte Array Arithmetic": {"b+", "b-", "b/", "b*", "b<", "b>", "b<=", "b>=", "b==", "b!=", "b%", "bsqrt"}, "Byte Array Logic": {"b|", "b&", "b^", "b~"}, "Loading Values": {"intcblock", "intc", "intc_0", "intc_1", "intc_2", "intc_3", "pushint", "bytecblock", "bytec", "bytec_0", "bytec_1", "bytec_2", "bytec_3", "pushbytes", "bzero", "arg", "arg_0", "arg_1", "arg_2", "arg_3", "args", "txn", "gtxn", "txna", "txnas", "gtxna", "gtxnas", "gtxns", "gtxnsa", "gtxnsas", "global", "load", "loads", "store", "stores", "gload", "gloads", "gloadss", "gaid", "gaids"}, - "Flow Control": {"err", "bnz", "bz", "b", "return", "pop", "dup", "dup2", "dig", "cover", "uncover", "swap", "select", "assert", "callsub", "retsub", "switchi"}, + "Flow Control": {"err", "bnz", "bz", "b", "return", "pop", "dup", "dup2", "dig", "cover", "uncover", "swap", "select", "assert", "callsub", "retsub", "switch"}, "State Access": {"balance", "min_balance", "app_opted_in", "app_local_get", "app_local_get_ex", "app_global_get", "app_global_get_ex", "app_local_put", "app_global_put", "app_local_del", "app_global_del", "asset_holding_get", "asset_params_get", "app_params_get", "acct_params_get", "log", "block"}, "Inner Transactions": {"itxn_begin", "itxn_next", "itxn_field", "itxn_submit", "itxn", "itxna", "itxnas", "gitxn", "gitxna", "gitxnas"}, } diff --git a/data/transactions/logic/eval.go b/data/transactions/logic/eval.go index f87b844240..5e4cf4c377 100644 --- a/data/transactions/logic/eval.go +++ b/data/transactions/logic/eval.go @@ -2096,7 +2096,7 @@ func opB(cx *EvalContext) error { return nil } -func opSwitchInt(cx *EvalContext) error { +func opSwitch(cx *EvalContext) error { last := len(cx.stack) - 1 branchIdx := cx.stack[last].Uint diff --git a/data/transactions/logic/eval_test.go b/data/transactions/logic/eval_test.go index 26e8a8c718..64c6c04808 100644 --- a/data/transactions/logic/eval_test.go +++ b/data/transactions/logic/eval_test.go @@ -5535,7 +5535,7 @@ func TestSwitchInt(t *testing.T) { // take the 0th label testAccepts(t, ` int 0 -switchi zero one +switch zero one err zero: int 1; return one: int 0; @@ -5544,7 +5544,7 @@ one: int 0; // take the 1th label testRejects(t, ` int 1 -switchi zero one +switch zero one err zero: int 1; return one: int 0; @@ -5553,7 +5553,7 @@ one: int 0; // same, but jumping to end of program testAccepts(t, ` int 1; dup -switchi zero one +switch zero one zero: err one: `, 8) @@ -5561,7 +5561,7 @@ one: // no match testAccepts(t, ` int 2 -switchi zero one +switch zero one int 1; return // falls through to here zero: int 0; return one: int 0; return @@ -5576,7 +5576,7 @@ int 1 dup int 1 - -switchi start end +switch start end err end: int 2 @@ -5588,23 +5588,23 @@ int 1 // 0 labels are allowed, but weird! testAccepts(t, ` int 0 -switchi +switch int 1 `, 8) - testPanics(t, notrack("switchi; int 1"), 8) + testPanics(t, notrack("switch; int 1"), 8) // make the switch the final instruction testAccepts(t, ` int 1 int 0 -switchi done1 done2; done1: ; done2: ; +switch done1 done2; done1: ; done2: ; `, 8) // make the switch the final instruction, and don't match testAccepts(t, ` int 1 int 88 -switchi done1 done2; done1: ; done2: ; +switch done1 done2; done1: ; done2: ; `, 8) } diff --git a/data/transactions/logic/langspec.json b/data/transactions/logic/langspec.json index 5db44dfefb..58f3ded24a 100644 --- a/data/transactions/logic/langspec.json +++ b/data/transactions/logic/langspec.json @@ -1578,7 +1578,7 @@ }, { "Opcode": 138, - "Name": "switchi", + "Name": "switch", "Args": "U", "Size": 0, "Doc": "branch to the Ath label. Continue at following instruction if index A exceeds the number of labels.", diff --git a/data/transactions/logic/opcodes.go b/data/transactions/logic/opcodes.go index ec88ea5ca5..1e3dcfc5b6 100644 --- a/data/transactions/logic/opcodes.go +++ b/data/transactions/logic/opcodes.go @@ -544,7 +544,7 @@ var OpSpecs = []OpSpec{ // "Function oriented" {0x88, "callsub", opCallSub, proto(":"), 4, detBranch()}, {0x89, "retsub", opRetSub, proto(":"), 4, detDefault()}, - {0x8a, "switchi", opSwitchInt, proto("i:"), 8, detSwitch()}, + {0x8a, "switch", opSwitch, proto("i:"), 8, detSwitch()}, // 0x8b will likely be a switch on pairs of values/targets // More math diff --git a/data/transactions/logic/teal.tmLanguage.json b/data/transactions/logic/teal.tmLanguage.json index 1f2925f983..863d0a0c43 100644 --- a/data/transactions/logic/teal.tmLanguage.json +++ b/data/transactions/logic/teal.tmLanguage.json @@ -64,7 +64,7 @@ }, { "name": "keyword.control.teal", - "match": "^(assert|b|bnz|bz|callsub|cover|dig|dup|dup2|err|pop|retsub|return|select|swap|switchi|uncover)\\b" + "match": "^(assert|b|bnz|bz|callsub|cover|dig|dup|dup2|err|pop|retsub|return|select|swap|switch|uncover)\\b" }, { "name": "keyword.other.teal",