From b972a9bab3d0d7bac6a4d778f17f77c38405c010 Mon Sep 17 00:00:00 2001 From: Masaaki Goshima Date: Sat, 12 Jun 2021 22:38:52 +0900 Subject: [PATCH] Fix indent num --- internal/cmd/generator/vm.go.tmpl | 3 ++- internal/encoder/vm/vm.go | 3 ++- internal/encoder/vm_color/vm.go | 3 ++- internal/encoder/vm_color_indent/vm.go | 3 ++- internal/encoder/vm_indent/vm.go | 3 ++- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/internal/cmd/generator/vm.go.tmpl b/internal/cmd/generator/vm.go.tmpl index 8bb1681..242c3a4 100644 --- a/internal/cmd/generator/vm.go.tmpl +++ b/internal/cmd/generator/vm.go.tmpl @@ -484,7 +484,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b oldOffset := ptrOffset ptrOffset += code.Jmp.CurLen * uintptrSize oldBaseIndent := ctx.BaseIndent - ctx.BaseIndent += code.Indent + indentDiffFromTop := c.Indent - 1 + ctx.BaseIndent += code.Indent - indentDiffFromTop newLen := offsetNum + code.Jmp.CurLen + code.Jmp.NextLen if curlen < newLen { diff --git a/internal/encoder/vm/vm.go b/internal/encoder/vm/vm.go index 8bb1681..242c3a4 100644 --- a/internal/encoder/vm/vm.go +++ b/internal/encoder/vm/vm.go @@ -484,7 +484,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b oldOffset := ptrOffset ptrOffset += code.Jmp.CurLen * uintptrSize oldBaseIndent := ctx.BaseIndent - ctx.BaseIndent += code.Indent + indentDiffFromTop := c.Indent - 1 + ctx.BaseIndent += code.Indent - indentDiffFromTop newLen := offsetNum + code.Jmp.CurLen + code.Jmp.NextLen if curlen < newLen { diff --git a/internal/encoder/vm_color/vm.go b/internal/encoder/vm_color/vm.go index 8d7df85..0447c74 100644 --- a/internal/encoder/vm_color/vm.go +++ b/internal/encoder/vm_color/vm.go @@ -484,7 +484,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b oldOffset := ptrOffset ptrOffset += code.Jmp.CurLen * uintptrSize oldBaseIndent := ctx.BaseIndent - ctx.BaseIndent += code.Indent + indentDiffFromTop := c.Indent - 1 + ctx.BaseIndent += code.Indent - indentDiffFromTop newLen := offsetNum + code.Jmp.CurLen + code.Jmp.NextLen if curlen < newLen { diff --git a/internal/encoder/vm_color_indent/vm.go b/internal/encoder/vm_color_indent/vm.go index 834aadf..b142463 100644 --- a/internal/encoder/vm_color_indent/vm.go +++ b/internal/encoder/vm_color_indent/vm.go @@ -484,7 +484,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b oldOffset := ptrOffset ptrOffset += code.Jmp.CurLen * uintptrSize oldBaseIndent := ctx.BaseIndent - ctx.BaseIndent += code.Indent + indentDiffFromTop := c.Indent - 1 + ctx.BaseIndent += code.Indent - indentDiffFromTop newLen := offsetNum + code.Jmp.CurLen + code.Jmp.NextLen if curlen < newLen { diff --git a/internal/encoder/vm_indent/vm.go b/internal/encoder/vm_indent/vm.go index f9d7569..cbcf3d0 100644 --- a/internal/encoder/vm_indent/vm.go +++ b/internal/encoder/vm_indent/vm.go @@ -484,7 +484,8 @@ func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]b oldOffset := ptrOffset ptrOffset += code.Jmp.CurLen * uintptrSize oldBaseIndent := ctx.BaseIndent - ctx.BaseIndent += code.Indent + indentDiffFromTop := c.Indent - 1 + ctx.BaseIndent += code.Indent - indentDiffFromTop newLen := offsetNum + code.Jmp.CurLen + code.Jmp.NextLen if curlen < newLen {