More private members

This commit is contained in:
Ian Gulliver
2021-11-16 15:27:30 -10:00
parent f39a856361
commit 7ab0aba088
3 changed files with 32 additions and 20 deletions

View File

@@ -23,21 +23,11 @@ func NewState(byteCodes [][]byte) (*State, error) {
state := &State{}
for i, byteCode := range byteCodes {
instrs := []*Instruction{}
for start := 0; start < len(byteCode); start += InstructionBytes {
chunk := byteCode[start : start+InstructionBytes]
instr, err := NewInstruction(chunk)
if err != nil {
return nil, errors.Wrapf(err, "At function index %d, byte offset %d", i, start)
}
instrs = append(instrs, instr)
instrs, err := NewInstructionsFromByteCode(byteCode)
if err != nil {
return nil, errors.Wrapf(err, "At function index %d", i)
}
instrs = append(instrs, &Instruction{
OpCode: OpReturn,
})
state.functions = append(state.functions, instrs)
}
@@ -70,7 +60,7 @@ func (state *State) setError(err error) {
func (state *State) setHandlers() {
for _, fnc := range state.functions {
for _, instr := range fnc {
handler, found := OpHandlers[instr.OpCode]
handler, found := opHandlers[instr.OpCode]
if !found {
state.setError(fmt.Errorf("Invalid OpCode: 0x%08x", instr.OpCode))
return