From 67cb2b9a75b049a3271a5f28043d2961fd339811 Mon Sep 17 00:00:00 2001 From: Masaaki Goshima Date: Sat, 27 Nov 2021 22:33:45 +0900 Subject: [PATCH] refactor --- internal/encoder/code.go | 3 +++ internal/encoder/opcode.go | 16 ---------------- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/internal/encoder/code.go b/internal/encoder/code.go index 1c079cf..9dbeca2 100644 --- a/internal/encoder/code.go +++ b/internal/encoder/code.go @@ -732,6 +732,9 @@ func (c *InterfaceCode) ToOpcode(ctx *compileContext) Opcodes { default: code = newOpCode(ctx.withType(c.typ), OpInterface) } + if c.typ.NumMethod() > 0 { + code.Flags |= NonEmptyInterfaceFlags + } ctx.incIndex() return Opcodes{code} } diff --git a/internal/encoder/opcode.go b/internal/encoder/opcode.go index 309cfe6..5b16f00 100644 --- a/internal/encoder/opcode.go +++ b/internal/encoder/opcode.go @@ -697,22 +697,6 @@ func newMapEndCode(ctx *compileContext, head *Opcode) *Opcode { } } -func newInterfaceCode(ctx *compileContext) *Opcode { - var flag OpFlags - if ctx.typ.NumMethod() > 0 { - flag |= NonEmptyInterfaceFlags - } - return &Opcode{ - Op: OpInterface, - Idx: opcodeOffset(ctx.ptrIndex), - Next: newEndOp(ctx), - Type: ctx.typ, - DisplayIdx: ctx.opcodeIndex, - Indent: ctx.indent, - Flags: flag, - } -} - func newRecursiveCode(ctx *compileContext, jmp *CompiledCode) *Opcode { return &Opcode{ Op: OpRecursive,