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