Skip to content

Commit d92ed63

Browse files
authored
Run go fmt
1 parent b7e2ba5 commit d92ed63

12 files changed

Lines changed: 51 additions & 52 deletions

File tree

base.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,10 @@ var baseLibrary = []RegistryFunction{
178178
return l.Top() // return all arguments
179179
}
180180
CheckAny(l, 1)
181-
l.Remove(1) // remove condition
182-
l.PushString("assertion failed!") // default message
183-
l.SetTop(1) // leave only message (default if no other one)
184-
return baseError(l) // call 'error'
181+
l.Remove(1) // remove condition
182+
l.PushString("assertion failed!") // default message
183+
l.SetTop(1) // leave only message (default if no other one)
184+
return baseError(l) // call 'error'
185185
}},
186186
{"collectgarbage", func(l *State) int {
187187
switch opt, _ := OptString(l, 1, "collect"), OptInteger(l, 2, 0); opt {

code.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,9 @@ type function struct {
138138
freeRegisterCount int
139139
activeVariableCount int
140140
firstLocal int
141-
firstLabel int // Lua 5.4: first label index for this function (like C Lua's fs->firstlabel)
142-
previousLine int // Lua 5.4: for relative line info encoding (per-function, like C Lua's FuncState)
143-
iwthabs int // instructions without absolute line info
141+
firstLabel int // Lua 5.4: first label index for this function (like C Lua's fs->firstlabel)
142+
previousLine int // Lua 5.4: for relative line info encoding (per-function, like C Lua's FuncState)
143+
iwthabs int // instructions without absolute line info
144144
needClose bool // Lua 5.4: function has TBC variables (affects RETURN k-bit)
145145
}
146146

@@ -488,8 +488,8 @@ func (f *function) assertEqual(a, b interface{}) {
488488

489489
const (
490490
lineInfoAbs = -0x80 // marker for absolute line info in lineInfo
491-
limLineDiff = 0x80 // max absolute delta that fits in int8
492-
maxIWthAbs = 128 // max instructions without absolute line info
491+
limLineDiff = 0x80 // max absolute delta that fits in int8
492+
maxIWthAbs = 128 // max instructions without absolute line info
493493
)
494494

495495
func (f *function) encode(i instruction) int {
@@ -601,7 +601,7 @@ func (f *function) Jump() int {
601601
return f.Concatenate(f.encodeJ(opJump, noJump), jumpPC)
602602
}
603603

604-
func (f *function) JumpTo(target int) { f.PatchList(f.Jump(), target) }
604+
func (f *function) JumpTo(target int) { f.PatchList(f.Jump(), target) }
605605
func (f *function) ReturnNone() {
606606
k := 0
607607
if f.needClose {
@@ -1011,7 +1011,6 @@ func (f *function) ExpressionToValue(e exprDesc) exprDesc {
10111011
return f.DischargeVariables(e)
10121012
}
10131013

1014-
10151014
// exp2K tries to convert expression to a constant index in range.
10161015
// Returns (constant index, true) if successful, (0, false) otherwise.
10171016
func (f *function) exp2K(e exprDesc) (int, bool) {
@@ -1191,8 +1190,8 @@ func (f *function) Indexed(t, k exprDesc) exprDesc {
11911190
if t.kind == kindUpValue {
11921191
f.assert(f.isKstr(k))
11931192
r := makeExpression(kindIndexUp, 0)
1194-
r.table = t.info // upvalue index
1195-
r.index = k.info // string constant index
1193+
r.table = t.info // upvalue index
1194+
r.index = k.info // string constant index
11961195
return r
11971196
}
11981197
// table is in a register

coroutine.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ var coroutineLibrary = []RegistryFunction{
1616
co.hasError = false
1717
// Reset call info to base (like C Lua)
1818
co.callInfo = &co.baseCallInfo
19-
co.errorFunction = 0 // clear any xpcall error handler
19+
co.errorFunction = 0 // clear any xpcall error handler
2020
co.status = threadStatusOK // temporarily OK so __close handlers can run
2121
// Close TBC variables in protected mode with error chaining
2222
closeErrVal := co.closeTBCProtected(0, nil)
@@ -47,9 +47,9 @@ var coroutineLibrary = []RegistryFunction{
4747
{"create", func(l *State) int {
4848
CheckType(l, 1, TypeFunction)
4949
co := l.NewThread()
50-
l.PushValue(1) // push function
51-
XMove(l, co, 1) // move function to coroutine stack
52-
return 1 // return the thread
50+
l.PushValue(1) // push function
51+
XMove(l, co, 1) // move function to coroutine stack
52+
return 1 // return the thread
5353
}},
5454
{"resume", coroutineResume},
5555
{"yield", func(l *State) int {
@@ -81,8 +81,8 @@ var coroutineLibrary = []RegistryFunction{
8181
{"wrap", func(l *State) int {
8282
CheckType(l, 1, TypeFunction)
8383
l.NewThread()
84-
l.PushValue(1) // push function
85-
XMove(l, l.ToThread(-2), 1) // move function to coroutine stack
84+
l.PushValue(1) // push function
85+
XMove(l, l.ToThread(-2), 1) // move function to coroutine stack
8686
l.PushGoClosure(coroutineWrapHelper, 1)
8787
return 1
8888
}},

instructions.go

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,12 @@ var opNames = []string{
187187
}
188188

189189
// Lua 5.4 instruction layout:
190-
// iABC: op(7) | A(8) | k(1) | B(8) | C(8)
191-
// iABx: op(7) | A(8) | Bx(17)
192-
// iAsBx: op(7) | A(8) | sBx(17)
193-
// iAx: op(7) | Ax(25)
194-
// isJ: op(7) | sJ(25)
190+
//
191+
// iABC: op(7) | A(8) | k(1) | B(8) | C(8)
192+
// iABx: op(7) | A(8) | Bx(17)
193+
// iAsBx: op(7) | A(8) | sBx(17)
194+
// iAx: op(7) | Ax(25)
195+
// isJ: op(7) | sJ(25)
195196
const (
196197
sizeC = 8
197198
sizeB = 8
@@ -312,12 +313,13 @@ func (i instruction) String() string {
312313
}
313314

314315
// Lua 5.4 opmode format:
315-
// bits 0-2: op mode (iABC=0, iABx=1, iAsBx=2, iAx=3, isJ=4)
316-
// bit 3: instruction sets register A
317-
// bit 4: operator is a test (next instruction must be a jump)
318-
// bit 5: instruction uses 'L->top' set by previous instruction (when B == 0)
319-
// bit 6: instruction sets 'L->top' for next instruction (when C == 0)
320-
// bit 7: instruction is an MM instruction (call a metamethod)
316+
//
317+
// bits 0-2: op mode (iABC=0, iABx=1, iAsBx=2, iAx=3, isJ=4)
318+
// bit 3: instruction sets register A
319+
// bit 4: operator is a test (next instruction must be a jump)
320+
// bit 5: instruction uses 'L->top' set by previous instruction (when B == 0)
321+
// bit 6: instruction sets 'L->top' for next instruction (when C == 0)
322+
// bit 7: instruction is an MM instruction (call a metamethod)
321323
func opmode(mm, ot, it, t, a, m int) byte {
322324
return byte(mm<<7 | ot<<6 | it<<5 | t<<4 | a<<3 | m)
323325
}

io.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -424,10 +424,10 @@ var ioLibrary = []RegistryFunction{
424424
// iterator, file_stream, nil, file_stream (TBC)
425425
forceOpen(l, CheckString(l, 1), "r")
426426
l.Replace(1)
427-
lines(l, true) // pushes iterator closure
428-
l.PushValue(1) // push file stream as 2nd result
429-
l.PushNil() // push nil as 3rd result
430-
l.PushValue(1) // push file stream as 4th result (to-be-closed)
427+
lines(l, true) // pushes iterator closure
428+
l.PushValue(1) // push file stream as 2nd result
429+
l.PushNil() // push nil as 3rd result
430+
l.PushValue(1) // push file stream as 4th result (to-be-closed)
431431
return 4
432432
}},
433433
{"open", func(l *State) int {

isolate_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,4 +393,3 @@ func TestIsolateCallLine(t *testing.T) {
393393
}
394394
}
395395
}
396-

lua.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ type Function func(state *State) int
211211
type threadStatus byte
212212

213213
const (
214-
threadStatusOK threadStatus = iota
214+
threadStatusOK threadStatus = iota
215215
threadStatusYield
216216
threadStatusDead
217217
)
@@ -722,7 +722,7 @@ func (l *State) finishOp() {
722722
l.concat(total) // concat remaining (may yield again)
723723
}
724724
ci.frame[a] = l.stack[l.top-1] // move final result
725-
l.top = ci.top // restore top
725+
l.top = ci.top // restore top
726726
case opClose, opReturn0, opReturn1:
727727
// yielded closing variables — repeat instruction to close others
728728
ci.savedPC--

scanner.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ var tokens []string = []string{
6969
type token struct {
7070
t rune
7171
n float64
72-
i int64 // Lua 5.3: integer value
72+
i int64 // Lua 5.3: integer value
7373
s string
7474
raw string // original source text for error messages (txtToken)
7575
}
@@ -90,9 +90,9 @@ func (s *scanner) assert(cond bool) { s.l.assert(cond) }
9090
func (s *scanner) syntaxError(message string) { s.scanError(message, s.t) }
9191
func (s *scanner) errorExpected(t rune) { s.syntaxError(s.tokenToString(t) + " expected") }
9292
func (s *scanner) numberError() { s.scanError("malformed number", tkNumber) }
93-
func isNewLine(c rune) bool { return c == '\n' || c == '\r' }
94-
func isDecimal(c rune) bool { return '0' <= c && c <= '9' }
95-
func isAlpha(c rune) bool { return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') }
93+
func isNewLine(c rune) bool { return c == '\n' || c == '\r' }
94+
func isDecimal(c rune) bool { return '0' <= c && c <= '9' }
95+
func isAlpha(c rune) bool { return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') }
9696

9797
func (s *scanner) tokenToString(t rune) string {
9898
switch {

string.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ func scanFormat(l *State, fs string) string {
571571
for i < len(fs) && strings.ContainsRune(allFlags, rune(fs[i])) {
572572
i++
573573
}
574-
i++ // include the conversion specifier
574+
i++ // include the conversion specifier
575575
if i > 22 { // MAX_FORMAT - 10
576576
Errorf(l, "invalid format (too long)")
577577
}

types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ type prototype struct {
234234
constants []value
235235
code []instruction
236236
prototypes []prototype
237-
lineInfo []int8 // Lua 5.4: relative line info
237+
lineInfo []int8 // Lua 5.4: relative line info
238238
absLineInfos []absLineInfo // Lua 5.4: absolute line info
239239
localVariables []localVariable
240240
upValues []upValueDesc

0 commit comments

Comments
 (0)