func (e *Emitter) addInstr(fn *bytecode.Fn, op bytecode.Opcode, flg bytecode.Flag, ix uint64) { if e.err != nil { return } switch op { case bytecode.OP_PUSH: e.stackSz[fn] += 1 case bytecode.OP_NEW: e.stackSz[fn] += (1 - (2 * int64(ix))) case bytecode.OP_POP, bytecode.OP_RET, bytecode.OP_UNM, bytecode.OP_NOT, bytecode.OP_TEST, bytecode.OP_LT, bytecode.OP_LTE, bytecode.OP_GT, bytecode.OP_GTE, bytecode.OP_EQ, bytecode.OP_ADD, bytecode.OP_SUB, bytecode.OP_MUL, bytecode.OP_DIV, bytecode.OP_MOD, bytecode.OP_GFLD, bytecode.OP_NEQ: e.stackSz[fn] -= 1 case bytecode.OP_SFLD: e.stackSz[fn] -= 3 case bytecode.OP_CALL: e.stackSz[fn] -= (int64(ix) + 1) case bytecode.OP_CFLD: e.stackSz[fn] -= (int64(ix) + 2) } if e.stackSz[fn] > fn.Header.StackSz { fn.Header.StackSz = e.stackSz[fn] } fn.Is = append(fn.Is, bytecode.NewInstr(op, flg, ix)) }
func (a *Asm) readIs(fn *bytecode.Fn) { var l string var ok bool // While a new F section is not reached for l, ok = a.getLine(false); ok && l != "[f]"; l, ok = a.getLine(false) { // Split in three parts parts := strings.SplitN(l, " ", 3) if a.assertIParts(parts) { var ix uint64 o := bytecode.NewOpcode(parts[0]) f := bytecode.NewFlag(parts[1]) ix, a.err = strconv.ParseUint(parts[2], 10, 64) fn.Is = append(fn.Is, bytecode.NewInstr(o, f, ix)) } } if ok { a.readFn() } }