More private members
This commit is contained in:
18
state.go
18
state.go
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user