Lines Matching refs:dec

71 	dec := &execDecoder{target: target, data: exec}
72 dec.parse()
73 if dec.err != nil {
74 return ExecProg{}, dec.err
76 if uint64(len(dec.vars)) != dec.numVars {
78 len(dec.vars), dec.numVars)
81 Calls: dec.calls,
82 Vars: dec.vars,
97 func (dec *execDecoder) parse() {
98 for dec.err == nil {
99 switch instr := dec.read(); instr {
101 dec.commitCall()
102 dec.call.Copyin = append(dec.call.Copyin, ExecCopyin{
103 Addr: dec.read(),
104 Arg: dec.readArg(),
107 dec.call.Copyout = append(dec.call.Copyout, ExecCopyout{
108 Index: dec.read(),
109 Addr: dec.read(),
110 Size: dec.read(),
113 dec.commitCall()
114 if instr >= uint64(len(dec.target.Syscalls)) {
115 dec.setErr(fmt.Errorf("bad syscall %v", instr))
118 dec.call.Meta = dec.target.Syscalls[instr]
119 dec.call.Index = dec.read()
120 for i := dec.read(); i > 0; i-- {
121 switch arg := dec.readArg(); arg.(type) {
123 dec.call.Args = append(dec.call.Args, arg)
125 dec.setErr(fmt.Errorf("bad call arg %+v", arg))
130 dec.commitCall()
136 func (dec *execDecoder) readArg() ExecArg {
137 switch typ := dec.read(); typ {
139 meta := dec.read()
141 Value: dec.read(),
149 meta := dec.read()
153 Index: dec.read(),
154 DivOp: dec.read(),
155 AddOp: dec.read(),
156 Default: dec.read(),
158 for uint64(len(dec.vars)) <= arg.Index {
159 dec.vars = append(dec.vars, 0)
161 dec.vars[arg.Index] = arg.Default
165 Data: dec.readBlob(dec.read()),
168 size := dec.read()
169 switch kind := dec.read(); kind {
171 chunks := make([]ExecCsumChunk, dec.read())
174 Kind: dec.read(),
175 Value: dec.read(),
176 Size: dec.read(),
185 dec.setErr(fmt.Errorf("unknown csum kind %v", kind))
189 dec.setErr(fmt.Errorf("bad argument type %v", typ))
194 func (dec *execDecoder) read() uint64 {
195 if len(dec.data) < 8 {
196 dec.setErr(fmt.Errorf("exec program overflow"))
198 if dec.err != nil {
203 v |= uint64(dec.data[i]) << uint(i*8)
205 dec.data = dec.data[8:]
209 func (dec *execDecoder) readBlob(size uint64) []byte {
211 if uint64(len(dec.data)) < padded {
212 dec.setErr(fmt.Errorf("exec program overflow"))
214 if dec.err != nil {
217 data := dec.data[:size]
218 dec.data = dec.data[padded:]
222 func (dec *execDecoder) setErr(err error) {
223 if dec.err == nil {
224 dec.err = err
228 func (dec *execDecoder) commitCall() {
229 if dec.call.Meta == nil {
232 if dec.call.Index != ExecNoCopyout && dec.numVars < dec.call.Index+1 {
233 dec.numVars = dec.call.Index + 1
235 for _, copyout := range dec.call.Copyout {
236 if dec.numVars < copyout.Index+1 {
237 dec.numVars = copyout.Index + 1
240 dec.calls = append(dec.calls, dec.call)
241 dec.call = ExecCall{}