Restrict global and function references to memory size
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package vm
|
||||
|
||||
const FunctionMemorySize = 16
|
||||
|
||||
type stackFrame struct {
|
||||
previousFunctionIndex int64
|
||||
previousInstructionIndex int64
|
||||
@@ -10,6 +12,6 @@ func newStackFrame(state *State) *stackFrame {
|
||||
return &stackFrame{
|
||||
previousFunctionIndex: state.functionIndex,
|
||||
previousInstructionIndex: state.instructionIndex,
|
||||
functionMemory: NewMemory(16),
|
||||
functionMemory: NewMemory(FunctionMemorySize),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ package vm
|
||||
|
||||
import "fmt"
|
||||
|
||||
const GlobalMemorySize = 16
|
||||
|
||||
type State struct {
|
||||
running bool
|
||||
err error
|
||||
@@ -18,7 +20,7 @@ type State struct {
|
||||
func NewState(prog *Program) (*State, error) {
|
||||
return &State{
|
||||
program: prog,
|
||||
globalMemory: NewMemory(16),
|
||||
globalMemory: NewMemory(GlobalMemorySize),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user