MCPcopy Index your code
hub / github.com/goccy/go-json / ToOpcode

Method ToOpcode

internal/encoder/code.go:758–787  ·  view source on GitHub ↗
(ctx *compileContext, isFirstField, isEndField bool)

Source from the content-addressed store, hash-verified

756}
757
758func (c *StructFieldCode) ToOpcode(ctx *compileContext, isFirstField, isEndField bool) Opcodes {
759 field := &Opcode{
760 Idx: opcodeOffset(ctx.ptrIndex),
761 Flags: c.flags(),
762 Key: c.structKey(ctx),
763 Offset: uint32(c.offset),
764 Type: c.typ,
765 DisplayIdx: ctx.opcodeIndex,
766 Indent: ctx.indent,
767 DisplayKey: c.key,
768 }
769 ctx.incIndex()
770 valueCodes := c.toValueOpcodes(ctx)
771 if isFirstField {
772 codes := c.headerOpcodes(ctx, field, valueCodes)
773 if isEndField {
774 codes = c.addStructEndCode(ctx, codes)
775 }
776 return codes
777 }
778 codes := c.fieldOpcodes(ctx, field, valueCodes)
779 if isEndField {
780 if isEnableStructEndOptimization(c.value) {
781 field.Op = field.Op.FieldToEnd()
782 } else {
783 codes = c.addStructEndCode(ctx, codes)
784 }
785 }
786 return codes
787}
788
789func (c *StructFieldCode) ToAnonymousOpcode(ctx *compileContext, isFirstField, isEndField bool) Opcodes {
790 field := &Opcode{

Callers

nothing calls this directly

Calls 10

flagsMethod · 0.95
structKeyMethod · 0.95
toValueOpcodesMethod · 0.95
headerOpcodesMethod · 0.95
addStructEndCodeMethod · 0.95
fieldOpcodesMethod · 0.95
opcodeOffsetFunction · 0.85
incIndexMethod · 0.80
FieldToEndMethod · 0.80

Tested by

no test coverage detected