github.com/cloudwego/frugal@v0.1.15/internal/binary/decoder/mapassign_emu.go (about) 1 /* 2 * Copyright 2022 ByteDance Inc. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package decoder 18 19 import ( 20 `unsafe` 21 22 `github.com/cloudwego/frugal/internal/atm/hir` 23 `github.com/cloudwego/frugal/internal/rt` 24 ) 25 26 func emu_string(ctx hir.CallContext, i int) (v string) { 27 (*rt.GoString)(unsafe.Pointer(&v)).Ptr = ctx.Ap(i) 28 (*rt.GoString)(unsafe.Pointer(&v)).Len = int(ctx.Au(i + 1)) 29 return 30 } 31 32 func emu_gcall_mapassign(ctx hir.CallContext) { 33 if !ctx.Verify("***", "*") { 34 panic("invalid mapassign call") 35 } else { 36 ctx.Rp(0, mapassign((*rt.GoMapType)(ctx.Ap(0)), (*rt.GoMap)(ctx.Ap(1)), ctx.Ap(2))) 37 } 38 } 39 40 func emu_gcall_mapassign_fast32(ctx hir.CallContext) { 41 if !ctx.Verify("**i", "*") { 42 panic("invalid mapassign_fast32 call") 43 } else { 44 ctx.Rp(0, mapassign_fast32((*rt.GoMapType)(ctx.Ap(0)), (*rt.GoMap)(ctx.Ap(1)), uint32(ctx.Au(2)))) 45 } 46 } 47 48 func emu_gcall_mapassign_fast64(ctx hir.CallContext) { 49 if !ctx.Verify("**i", "*") { 50 panic("invalid mapassign_fast64 call") 51 } else { 52 ctx.Rp(0, mapassign_fast64((*rt.GoMapType)(ctx.Ap(0)), (*rt.GoMap)(ctx.Ap(1)), ctx.Au(2))) 53 } 54 } 55 56 func emu_gcall_mapassign_faststr(ctx hir.CallContext) { 57 if !ctx.Verify("***i", "*") { 58 panic("invalid mapassign_faststr call") 59 } else { 60 ctx.Rp(0, mapassign_faststr((*rt.GoMapType)(ctx.Ap(0)), (*rt.GoMap)(ctx.Ap(1)), emu_string(ctx, 2))) 61 } 62 } 63 64 func emu_gcall_mapassign_fast64ptr(ctx hir.CallContext) { 65 if !ctx.Verify("***", "*") { 66 panic("invalid mapassign_fast64 call") 67 } else { 68 ctx.Rp(0, mapassign_fast64ptr((*rt.GoMapType)(ctx.Ap(0)), (*rt.GoMap)(ctx.Ap(1)), ctx.Ap(2))) 69 } 70 }