Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into add-cairo-runner
Browse files Browse the repository at this point in the history
  • Loading branch information
entropidelic committed Jul 11, 2023
2 parents 4c4d0f5 + 15b6d49 commit fceb0b0
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 25 deletions.
22 changes: 11 additions & 11 deletions pkg/vm/instruction.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ package vm
// Some instructions spread over two words when they use an immediate value, so
// representing the first one with this struct is enougth.
type Instruction struct {
off_dst int
off_op0 int
off2_op1 int
dst_reg Register
op0_reg Register
op1_addr Op1Src
res_logic ResLogic
pc_update PcUpdate
ap_update ApUpdate
fp_update FpUpdate
opcode Opcode
offDst int
offOp0 int
offOp1 int
dstReg Register
op0Reg Register
op1Addr Op1Src
resLogic ResLogic
pcUpdate PcUpdate
apUpdate ApUpdate
fpUpdate FpUpdate
opcode Opcode
}

// x-----------------------------x
Expand Down
4 changes: 2 additions & 2 deletions pkg/vm/memory/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func (m *Memory) Insert(addr *Relocatable, val *MaybeRelocatable) error {
// FIXME: There should be a special handling if the key
// segment index is negative. This is an edge
// case, so for now let's raise an error.
if addr.segment_index < 0 {
if addr.segmentIndex < 0 {
return errors.New("Segment index of key is negative - unimplemented")
}

Expand Down Expand Up @@ -61,7 +61,7 @@ func (m *Memory) Get(addr *Relocatable) (*MaybeRelocatable, error) {
// FIXME: There should be a special handling if the key
// segment index is negative. This is an edge
// case, so for now let's raise an error.
if addr.segment_index < 0 {
if addr.segmentIndex < 0 {
return nil, errors.New("Segment index of key is negative - unimplemented")
}

Expand Down
10 changes: 5 additions & 5 deletions pkg/vm/memory/relocatable.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ package memory
// these values are replaced by real memory addresses,
// represented by a field element.
type Relocatable struct {
segment_index int
offset uint
segmentIndex int
offset uint
}

// Creates a new Relocatable struct with the specified segment index
Expand All @@ -18,12 +18,12 @@ func NewRelocatable(segment_idx int, offset uint) *Relocatable {
// Get the the indexes of the Relocatable struct.
// Returns a tuple with both values (segment_index, offset)
func (r *Relocatable) into_indexes() (uint, uint) {
if r.segment_index < 0 {
corrected_segment_idx := uint(-(r.segment_index + 1))
if r.segmentIndex < 0 {
corrected_segment_idx := uint(-(r.segmentIndex + 1))
return corrected_segment_idx, r.offset
}

return uint(r.segment_index), r.offset
return uint(r.segmentIndex), r.offset
}

// Int in the Cairo VM represents a value in memory that
Expand Down
4 changes: 2 additions & 2 deletions pkg/vm/memory/segments.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ package memory
// Also holds metadata useful for the relocation process of
// the memory at the end of the VM run.
type MemorySegmentManager struct {
segment_sizes map[uint]uint
memory Memory
segmentSizes map[uint]uint
memory Memory
}
3 changes: 1 addition & 2 deletions pkg/vm/program.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package vm

type Program struct {
// FIXME: Should be a list of felts or MaybeRelocatables.
data []uint
Data []uint
}
6 changes: 3 additions & 3 deletions pkg/vm/vm_core.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "github.com/lambdaclass/cairo-vm.go/pkg/vm/memory"
// VirtualMachine represents the Cairo VM.
// Runs Cairo assembly and produces an execution trace.
type VirtualMachine struct {
run_context RunContext
current_step uint
segments memory.MemorySegmentManager
runContext RunContext
currentStep uint
segments memory.MemorySegmentManager
}

0 comments on commit fceb0b0

Please sign in to comment.